aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/purecalc/ut/test_eval.cpp
blob: 38ad7cc952d1596bf003c3947bcfcdb99212585d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <yql/essentials/public/purecalc/purecalc.h>
#include <yql/essentials/public/purecalc/io_specs/protobuf/spec.h>
#include <yql/essentials/public/purecalc/ut/protos/test_structs.pb.h>
#include <yql/essentials/public/purecalc/ut/empty_stream.h>

#include <library/cpp/testing/unittest/registar.h>

Y_UNIT_TEST_SUITE(TestEval) {
    Y_UNIT_TEST(TestEvalExpr) {
        using namespace NYql::NPureCalc;

        auto options = TProgramFactoryOptions();
        auto factory = MakeProgramFactory(options);

        auto program = factory->MakePullListProgram(
            TProtobufInputSpec<NPureCalcProto::TStringMessage>(),
            TProtobufOutputSpec<NPureCalcProto::TStringMessage>(),
            "SELECT Unwrap(cast(EvaluateExpr('foo' || 'bar') as Utf8)) AS X",
            ETranslationMode::SQL
        );

        auto stream = program->Apply(EmptyStream<NPureCalcProto::TStringMessage*>());

        NPureCalcProto::TStringMessage* message;

        UNIT_ASSERT(message = stream->Fetch());
        UNIT_ASSERT_EQUAL(message->GetX(), "foobar");
        UNIT_ASSERT(!stream->Fetch());
    }
}