test_eval.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #include <yql/essentials/public/purecalc/purecalc.h>
  2. #include <yql/essentials/public/purecalc/io_specs/protobuf/spec.h>
  3. #include <yql/essentials/public/purecalc/ut/protos/test_structs.pb.h>
  4. #include <yql/essentials/public/purecalc/ut/empty_stream.h>
  5. #include <library/cpp/testing/unittest/registar.h>
  6. Y_UNIT_TEST_SUITE(TestEval) {
  7. Y_UNIT_TEST(TestEvalExpr) {
  8. using namespace NYql::NPureCalc;
  9. auto options = TProgramFactoryOptions();
  10. auto factory = MakeProgramFactory(options);
  11. auto program = factory->MakePullListProgram(
  12. TProtobufInputSpec<NPureCalcProto::TStringMessage>(),
  13. TProtobufOutputSpec<NPureCalcProto::TStringMessage>(),
  14. "SELECT Unwrap(cast(EvaluateExpr('foo' || 'bar') as Utf8)) AS X",
  15. ETranslationMode::SQL
  16. );
  17. auto stream = program->Apply(EmptyStream<NPureCalcProto::TStringMessage*>());
  18. NPureCalcProto::TStringMessage* message;
  19. UNIT_ASSERT(message = stream->Fetch());
  20. UNIT_ASSERT_EQUAL(message->GetX(), "foobar");
  21. UNIT_ASSERT(!stream->Fetch());
  22. }
  23. }