diff options
author | vitya-smirnov <[email protected]> | 2025-10-07 09:34:39 +0300 |
---|---|---|
committer | vitya-smirnov <[email protected]> | 2025-10-07 09:52:14 +0300 |
commit | babe7533f18c11be1f8a195ed2324d2d9a89436a (patch) | |
tree | 45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/sql_match_recognize_ut.cpp | |
parent | 8fe7cfe254fde2772477a8933a163b5f303716b4 (diff) |
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/sql_match_recognize_ut.cpp')
-rw-r--r-- | yql/essentials/sql/v1/sql_match_recognize_ut.cpp | 841 |
1 files changed, 420 insertions, 421 deletions
diff --git a/yql/essentials/sql/v1/sql_match_recognize_ut.cpp b/yql/essentials/sql/v1/sql_match_recognize_ut.cpp index 2604dc17ea2..95f83ea7ea2 100644 --- a/yql/essentials/sql/v1/sql_match_recognize_ut.cpp +++ b/yql/essentials/sql/v1/sql_match_recognize_ut.cpp @@ -38,7 +38,7 @@ bool IsListOfSize(const NYql::TAstNode* node, ui32 size) { return true; } -template<typename Proj = std::identity> +template <typename Proj = std::identity> bool IsListOfAtoms(const NYql::TAstNode* node, std::vector<std::string_view> atoms, Proj proj = {}) { UNIT_ASSERT(IsListOfSize(node, atoms.size())); for (ui32 i = 0; i < atoms.size(); ++i) { @@ -61,7 +61,7 @@ bool IsLambda(const NYql::TAstNode* node, ui32 numberOfArgs) { } Y_UNIT_TEST_SUITE(MatchRecognize) { - auto minValidMatchRecognizeSql = R"( +auto minValidMatchRecognizeSql = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -69,20 +69,20 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - Y_UNIT_TEST(EnabledWithPragma) { - UNIT_ASSERT(not SqlToYql(minValidMatchRecognizeSql).IsOk()); - UNIT_ASSERT(MatchRecognizeSqlToYql(minValidMatchRecognizeSql).IsOk()); - } +Y_UNIT_TEST(EnabledWithPragma) { + UNIT_ASSERT(not SqlToYql(minValidMatchRecognizeSql).IsOk()); + UNIT_ASSERT(MatchRecognizeSqlToYql(minValidMatchRecognizeSql).IsOk()); +} - Y_UNIT_TEST(InputTableName) { - auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); - UNIT_ASSERT(r.IsOk()); - auto input = FindMatchRecognizeParam(r.Root, "input"); - UNIT_ASSERT(IsAtom(input, "core")); - } +Y_UNIT_TEST(InputTableName) { + auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); + UNIT_ASSERT(r.IsOk()); + auto input = FindMatchRecognizeParam(r.Root, "input"); + UNIT_ASSERT(IsAtom(input, "core")); +} - Y_UNIT_TEST(MatchRecognizeAndSample) { - auto matchRecognizeAndSample = R"( +Y_UNIT_TEST(MatchRecognizeAndSample) { + auto matchRecognizeAndSample = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -90,20 +90,20 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) TABLESAMPLE BERNOULLI(1.0) )"; - UNIT_ASSERT(not MatchRecognizeSqlToYql(matchRecognizeAndSample).IsOk()); - } + UNIT_ASSERT(not MatchRecognizeSqlToYql(matchRecognizeAndSample).IsOk()); +} - Y_UNIT_TEST(NoPartitionBy) { - auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); - UNIT_ASSERT(r.IsOk()); - auto partitionKeySelector = FindMatchRecognizeParam(r.Root, "partitionKeySelector"); - UNIT_ASSERT(IsListOfSize(GetQuoted(partitionKeySelector->GetChild(2)), 0)); //empty tuple - auto partitionColumns = FindMatchRecognizeParam(r.Root, "partitionColumns"); - UNIT_ASSERT(IsListOfSize(GetQuoted(partitionColumns), 0)); //empty tuple - } +Y_UNIT_TEST(NoPartitionBy) { + auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); + UNIT_ASSERT(r.IsOk()); + auto partitionKeySelector = FindMatchRecognizeParam(r.Root, "partitionKeySelector"); + UNIT_ASSERT(IsListOfSize(GetQuoted(partitionKeySelector->GetChild(2)), 0)); // empty tuple + auto partitionColumns = FindMatchRecognizeParam(r.Root, "partitionColumns"); + UNIT_ASSERT(IsListOfSize(GetQuoted(partitionColumns), 0)); // empty tuple +} - Y_UNIT_TEST(PartitionBy) { - auto stmt = R"( +Y_UNIT_TEST(PartitionBy) { + auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -112,24 +112,24 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto partitionKeySelector = FindMatchRecognizeParam(r.Root, "partitionKeySelector"); - UNIT_ASSERT(IsListOfSize(GetQuoted(partitionKeySelector->GetChild(2)), 3)); - auto partitionColumns = FindMatchRecognizeParam(r.Root, "partitionColumns"); - UNIT_ASSERT(IsListOfSize(GetQuoted(partitionColumns), 3)); - //TODO check partitioner lambdas(alias/no alias) - } + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto partitionKeySelector = FindMatchRecognizeParam(r.Root, "partitionKeySelector"); + UNIT_ASSERT(IsListOfSize(GetQuoted(partitionKeySelector->GetChild(2)), 3)); + auto partitionColumns = FindMatchRecognizeParam(r.Root, "partitionColumns"); + UNIT_ASSERT(IsListOfSize(GetQuoted(partitionColumns), 3)); + // TODO check partitioner lambdas(alias/no alias) +} - Y_UNIT_TEST(NoOrderBy) { - auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); - UNIT_ASSERT(r.IsOk()); - auto sortTraits = FindMatchRecognizeParam(r.Root, "sortTraits"); - UNIT_ASSERT(IsListOfAtoms(sortTraits, {"Void"})); - } +Y_UNIT_TEST(NoOrderBy) { + auto r = MatchRecognizeSqlToYql(minValidMatchRecognizeSql); + UNIT_ASSERT(r.IsOk()); + auto sortTraits = FindMatchRecognizeParam(r.Root, "sortTraits"); + UNIT_ASSERT(IsListOfAtoms(sortTraits, {"Void"})); +} - Y_UNIT_TEST(OrderBy) { - auto stmt = R"( +Y_UNIT_TEST(OrderBy) { + auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -138,16 +138,16 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto sortTraits = FindMatchRecognizeParam(r.Root, "sortTraits"); - UNIT_ASSERT(IsListOfSize(sortTraits, 4)); - UNIT_ASSERT(IsAtom(sortTraits->GetChild(0), "SortTraits")); - UNIT_ASSERT(IsListOfSize(GetQuoted(sortTraits->GetChild(2)), 3)); - UNIT_ASSERT(IsListOfSize(GetQuoted(sortTraits->GetChild(3)->GetChild(2)), 3)); - } - Y_UNIT_TEST(Measures) { - auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto sortTraits = FindMatchRecognizeParam(r.Root, "sortTraits"); + UNIT_ASSERT(IsListOfSize(sortTraits, 4)); + UNIT_ASSERT(IsAtom(sortTraits->GetChild(0), "SortTraits")); + UNIT_ASSERT(IsListOfSize(GetQuoted(sortTraits->GetChild(2)), 3)); + UNIT_ASSERT(IsListOfSize(GetQuoted(sortTraits->GetChild(3)->GetChild(2)), 3)); +} +Y_UNIT_TEST(Measures) { + auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -158,20 +158,20 @@ FROM Input MATCH_RECOGNIZE( DEFINE Y as true ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto measures = FindMatchRecognizeParam(r.Root, "measures"); - UNIT_ASSERT(IsListOfSize(measures, 5)); - const auto patternVars = measures->GetChild(2); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(patternVars), {"Y", "Q"}, GetQuoted)); - const auto measuresNames = measures->GetChild(3); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(measuresNames), {"T", "Key"}, GetQuoted)); - const auto measuresCallables = measures->GetChild(4); - UNIT_ASSERT(IsListOfSize(GetQuoted(measuresCallables), 2)); - } - Y_UNIT_TEST(RowsPerMatch) { - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto measures = FindMatchRecognizeParam(r.Root, "measures"); + UNIT_ASSERT(IsListOfSize(measures, 5)); + const auto patternVars = measures->GetChild(2); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(patternVars), {"Y", "Q"}, GetQuoted)); + const auto measuresNames = measures->GetChild(3); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(measuresNames), {"T", "Key"}, GetQuoted)); + const auto measuresCallables = measures->GetChild(4); + UNIT_ASSERT(IsListOfSize(GetQuoted(measuresCallables), 2)); +} +Y_UNIT_TEST(RowsPerMatch) { + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -180,13 +180,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto rowsPerMatch = FindMatchRecognizeParam(r.Root, "rowsPerMatch"); - UNIT_ASSERT(IsAtom(GetQuoted(rowsPerMatch), "RowsPerMatch_OneRow")); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto rowsPerMatch = FindMatchRecognizeParam(r.Root, "rowsPerMatch"); + UNIT_ASSERT(IsAtom(GetQuoted(rowsPerMatch), "RowsPerMatch_OneRow")); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -195,11 +195,11 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - } - { //default - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + } + { // default + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -207,16 +207,15 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto rowsPerMatch = FindMatchRecognizeParam(r.Root, "rowsPerMatch"); - UNIT_ASSERT(IsAtom(GetQuoted(rowsPerMatch), "RowsPerMatch_OneRow")); - } - + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto rowsPerMatch = FindMatchRecognizeParam(r.Root, "rowsPerMatch"); + UNIT_ASSERT(IsAtom(GetQuoted(rowsPerMatch), "RowsPerMatch_OneRow")); } - Y_UNIT_TEST(SkipAfterMatch) { - { - const auto stmt = R"( +} +Y_UNIT_TEST(SkipAfterMatch) { + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -225,13 +224,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_NextRow", ""}, GetQuoted)); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_NextRow", ""}, GetQuoted)); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -240,13 +239,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_PastLastRow", ""}, GetQuoted)); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_PastLastRow", ""}, GetQuoted)); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -255,13 +254,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_ToFirst", "Y"}, GetQuoted)); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_ToFirst", "Y"}, GetQuoted)); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -270,11 +269,11 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(not r.IsOk()); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(not r.IsOk()); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -283,13 +282,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_ToLast", "Y"}, GetQuoted)); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_ToLast", "Y"}, GetQuoted)); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -298,11 +297,11 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(not r.IsOk()); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(not r.IsOk()); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -311,13 +310,13 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_To", "Y"}, GetQuoted)); - } - { - const auto stmt = R"( + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + auto skipTo = FindMatchRecognizeParam(r.Root, "skipTo"); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(skipTo), {"AfterMatchSkip_To", "Y"}, GetQuoted)); + } + { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -326,12 +325,12 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(not r.IsOk()); - } + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(not r.IsOk()); } - Y_UNIT_TEST(row_pattern_initial) { - const auto stmt = R"( +} +Y_UNIT_TEST(row_pattern_initial) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -340,12 +339,12 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(not r.IsOk()); - } + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(not r.IsOk()); +} - Y_UNIT_TEST(row_pattern_seek) { - const auto stmt = R"( +Y_UNIT_TEST(row_pattern_seek) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -354,12 +353,12 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(not r.IsOk()); - } + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(not r.IsOk()); +} - Y_UNIT_TEST(PatternSimple) { - const auto stmt = R"( +Y_UNIT_TEST(PatternSimple) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -367,16 +366,16 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - const auto& r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); - UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 1)); - UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); - UNIT_ASSERT(IsListOfSize(GetQuoted(patternCallable->GetChild(1)), 3)); - } + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); + UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 1)); + UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); + UNIT_ASSERT(IsListOfSize(GetQuoted(patternCallable->GetChild(1)), 3)); +} - Y_UNIT_TEST(PatternMultiTerm) { - const auto stmt = R"( +Y_UNIT_TEST(PatternMultiTerm) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -384,16 +383,16 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - const auto& r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); - UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 4)); - UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); - UNIT_ASSERT(IsListOfSize(GetQuoted(patternCallable->GetChild(4)), 5)); - } + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); + UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 4)); + UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); + UNIT_ASSERT(IsListOfSize(GetQuoted(patternCallable->GetChild(4)), 5)); +} - Y_UNIT_TEST(PatternWithParanthesis) { - const auto stmt = R"( +Y_UNIT_TEST(PatternWithParanthesis) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -403,25 +402,25 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - const auto& r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); - UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 2)); - UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); - const auto& firstTerm = patternCallable->GetChild(1); - UNIT_ASSERT(IsListOfSize(GetQuoted(firstTerm), 1)); - const auto& lastTerm = patternCallable->GetChild(2); - UNIT_ASSERT(IsListOfSize(GetQuoted(lastTerm), 3)); - const auto& firstFactorOfLastTerm = lastTerm->GetChild(1)->GetChild(0); - UNIT_ASSERT(IsListOfSize(GetQuoted(firstFactorOfLastTerm), 6)); - const auto nestedPattern = firstFactorOfLastTerm->GetChild(1)->GetChild(0); - UNIT_ASSERT(IsListOfSize(nestedPattern, 1 + 1)); - UNIT_ASSERT(IsAtom(nestedPattern->GetChild(0), "MatchRecognizePattern")); - UNIT_ASSERT(IsListOfSize(GetQuoted(nestedPattern->GetChild(1)), 2)); - } + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); + UNIT_ASSERT(IsListOfSize(patternCallable, 1 + 2)); + UNIT_ASSERT(IsAtom(patternCallable->GetChild(0), "MatchRecognizePattern")); + const auto& firstTerm = patternCallable->GetChild(1); + UNIT_ASSERT(IsListOfSize(GetQuoted(firstTerm), 1)); + const auto& lastTerm = patternCallable->GetChild(2); + UNIT_ASSERT(IsListOfSize(GetQuoted(lastTerm), 3)); + const auto& firstFactorOfLastTerm = lastTerm->GetChild(1)->GetChild(0); + UNIT_ASSERT(IsListOfSize(GetQuoted(firstFactorOfLastTerm), 6)); + const auto nestedPattern = firstFactorOfLastTerm->GetChild(1)->GetChild(0); + UNIT_ASSERT(IsListOfSize(nestedPattern, 1 + 1)); + UNIT_ASSERT(IsAtom(nestedPattern->GetChild(0), "MatchRecognizePattern")); + UNIT_ASSERT(IsListOfSize(GetQuoted(nestedPattern->GetChild(1)), 2)); +} - Y_UNIT_TEST(PatternManyAlternatives) { - const auto stmt = R"( +Y_UNIT_TEST(PatternManyAlternatives) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -431,19 +430,21 @@ PATTERN ( DEFINE A as A ) )"; - UNIT_ASSERT(MatchRecognizeSqlToYql(stmt).IsOk()); - } + UNIT_ASSERT(MatchRecognizeSqlToYql(stmt).IsOk()); +} - Y_UNIT_TEST(PatternLimitedNesting) { - constexpr size_t MaxNesting = 20; - for (size_t extraNesting = 0; extraNesting <= 1; ++extraNesting) { - std::string pattern; - for (size_t i = 0; i != MaxNesting + extraNesting; ++i) - pattern.push_back('('); - pattern.push_back('A'); - for (size_t i = 0; i != MaxNesting + extraNesting; ++i) - pattern.push_back(')'); - const auto stmt = TString(R"( +Y_UNIT_TEST(PatternLimitedNesting) { + constexpr size_t MaxNesting = 20; + for (size_t extraNesting = 0; extraNesting <= 1; ++extraNesting) { + std::string pattern; + for (size_t i = 0; i != MaxNesting + extraNesting; ++i) { + pattern.push_back('('); + } + pattern.push_back('A'); + for (size_t i = 0; i != MaxNesting + extraNesting; ++i) { + pattern.push_back(')'); + } + const auto stmt = TString(R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -453,18 +454,18 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - const auto &r = MatchRecognizeSqlToYql(stmt); - if (not extraNesting) { - UNIT_ASSERT(r.IsOk()); - } else { - UNIT_ASSERT(not r.IsOk()); - } + const auto& r = MatchRecognizeSqlToYql(stmt); + if (not extraNesting) { + UNIT_ASSERT(r.IsOk()); + } else { + UNIT_ASSERT(not r.IsOk()); } } +} - Y_UNIT_TEST(PatternFactorQuantifiers) { - auto makeRequest = [](const TString& factor) { - return TString(R"( +Y_UNIT_TEST(PatternFactorQuantifiers) { + auto makeRequest = [](const TString& factor) { + return TString(R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -474,173 +475,173 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; + }; + auto getTheFactor = [](const NYql::TAstNode* root) { + const auto& patternCallable = FindMatchRecognizeParam(root, "pattern"); + const auto& factor = patternCallable->GetChild(1)->GetChild(1)->GetChild(0)->GetChild(1); + return NYql::NMatchRecognize::TRowPatternFactor{ + TString(), // Primary var or subexpression, not used in this test + FromString<uint64_t>(GetAtom(GetQuoted(factor->GetChild(1)))), // QuantityMin + FromString<uint64_t>(GetAtom(GetQuoted(factor->GetChild(2)))), // QuantityMax + FromString<bool>(GetAtom(GetQuoted(factor->GetChild(3)))), // Greedy + FromString<bool>(GetAtom(GetQuoted(factor->GetChild(4)))), // Output, not used in this test + FromString<bool>(GetAtom(GetQuoted(factor->GetChild(5)))), // Flag "Unused", not used in this test }; - auto getTheFactor = [](const NYql::TAstNode* root) { - const auto& patternCallable = FindMatchRecognizeParam(root, "pattern"); - const auto& factor = patternCallable->GetChild(1)->GetChild(1)->GetChild(0)->GetChild(1); - return NYql::NMatchRecognize::TRowPatternFactor{ - TString(), // Primary var or subexpression, not used in this test - FromString<uint64_t>(GetAtom(GetQuoted(factor->GetChild(1)))), // QuantityMin - FromString<uint64_t>(GetAtom(GetQuoted(factor->GetChild(2)))), // QuantityMax - FromString<bool>(GetAtom(GetQuoted(factor->GetChild(3)))), // Greedy - FromString<bool>(GetAtom(GetQuoted(factor->GetChild(4)))), // Output, not used in this test - FromString<bool>(GetAtom(GetQuoted(factor->GetChild(5)))), // Flag "Unused", not used in this test - }; - }; - { - //no quantifiers - const auto stmt = makeRequest("A"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(1, factor.QuantityMin); - UNIT_ASSERT_EQUAL(1, factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //optional greedy(default) - const auto stmt = makeRequest("A?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(1, factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //optional reluctant - const auto stmt = makeRequest("A??"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(1, factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } - { - //+ greedy(default) - const auto stmt = makeRequest("A+"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(1, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //+ reluctant - const auto stmt = makeRequest("A+?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(1, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } - { - //* greedy(default) - const auto stmt = makeRequest("A*"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //* reluctant - const auto stmt = makeRequest("A*?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } - { - //exact n - const auto stmt = makeRequest("A{4}"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(4, factor.QuantityMax); - } - { - //from n to m greedy(default - const auto stmt = makeRequest("A{4, 7}"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(7, factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //from n to m reluctant - const auto stmt = makeRequest("A{4,7}?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(7, factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } - { - //at least n greedy(default) - const auto stmt = makeRequest("A{4,}"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //at least n reluctant - const auto stmt = makeRequest("A{4,}?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } - { - //at most m greedy(default) - const auto stmt = makeRequest("A{,7}"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(7, factor.QuantityMax); - UNIT_ASSERT(factor.Greedy); - } - { - //at least n reluctant - const auto stmt = makeRequest("A{,7}?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(0, factor.QuantityMin); - UNIT_ASSERT_EQUAL(7, factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } + }; + { + // no quantifiers + const auto stmt = makeRequest("A"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(1, factor.QuantityMin); + UNIT_ASSERT_EQUAL(1, factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + // optional greedy(default) + const auto stmt = makeRequest("A?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(1, factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + // optional reluctant + const auto stmt = makeRequest("A??"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(1, factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } + { + //+ greedy(default) + const auto stmt = makeRequest("A+"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(1, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + //+ reluctant + const auto stmt = makeRequest("A+?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(1, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } + { + //* greedy(default) + const auto stmt = makeRequest("A*"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + //* reluctant + const auto stmt = makeRequest("A*?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } + { + // exact n + const auto stmt = makeRequest("A{4}"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(4, factor.QuantityMax); + } + { + // from n to m greedy(default + const auto stmt = makeRequest("A{4, 7}"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(7, factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + // from n to m reluctant + const auto stmt = makeRequest("A{4,7}?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(7, factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } + { + // at least n greedy(default) + const auto stmt = makeRequest("A{4,}"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + // at least n reluctant + const auto stmt = makeRequest("A{4,}?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(std::numeric_limits<uint64_t>::max(), factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } + { + // at most m greedy(default) + const auto stmt = makeRequest("A{,7}"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(7, factor.QuantityMax); + UNIT_ASSERT(factor.Greedy); + } + { + // at least n reluctant + const auto stmt = makeRequest("A{,7}?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(0, factor.QuantityMin); + UNIT_ASSERT_EQUAL(7, factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); + } - { - //quantifiers on subexpression - const auto stmt = makeRequest("(A B+ C | D | ^){4,7}?"); - const auto &r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto& factor = getTheFactor(r.Root); - UNIT_ASSERT_EQUAL(4, factor.QuantityMin); - UNIT_ASSERT_EQUAL(7, factor.QuantityMax); - UNIT_ASSERT(!factor.Greedy); - } + { + // quantifiers on subexpression + const auto stmt = makeRequest("(A B+ C | D | ^){4,7}?"); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto& factor = getTheFactor(r.Root); + UNIT_ASSERT_EQUAL(4, factor.QuantityMin); + UNIT_ASSERT_EQUAL(7, factor.QuantityMax); + UNIT_ASSERT(!factor.Greedy); } +} - Y_UNIT_TEST(Permute) { - const auto stmt = R"( +Y_UNIT_TEST(Permute) { + const auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -650,50 +651,48 @@ FROM Input MATCH_RECOGNIZE( DEFINE A as A ) )"; - const auto& r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); + const auto& r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); - const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); - const auto permutePattern = patternCallable->GetChild(1)->GetChild(1)->GetChild(0)->GetChild(1)->GetChild(0); - UNIT_ASSERT(IsListOfSize(permutePattern, 1 + 120)); //CallableName + 5! - } + const auto& patternCallable = FindMatchRecognizeParam(r.Root, "pattern"); + const auto permutePattern = patternCallable->GetChild(1)->GetChild(1)->GetChild(0)->GetChild(1)->GetChild(0); + UNIT_ASSERT(IsListOfSize(permutePattern, 1 + 120)); // CallableName + 5! +} - Y_UNIT_TEST(PermuteTooMuch) { - for (size_t n = 1; n <= 6 + 1; ++n) { - std::vector<std::string> vars(n); - std::generate(begin(vars), end(vars), [n = 0] () mutable { return "A" + std::to_string(n++);}); - const auto stmt = TString(R"( +Y_UNIT_TEST(PermuteTooMuch) { + for (size_t n = 1; n <= 6 + 1; ++n) { + std::vector<std::string> vars(n); + std::generate(begin(vars), end(vars), [n = 0]() mutable { return "A" + std::to_string(n++); }); + const auto stmt = TString(R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( PATTERN ( PERMUTE( )" + std::accumulate(cbegin(vars) + 1, cend(vars), vars.front(), - [](const std::string& acc, const std::string& v) { - return acc + ", " + v; - }) + - R"( + [](const std::string& acc, const std::string& v) { + return acc + ", " + v; + }) + + R"( ) ) DEFINE A0 as A0 ) -)" - ); - const auto &r = MatchRecognizeSqlToYql(stmt); - if (n <= 6) { - UNIT_ASSERT(r.IsOk()); - } else { - UNIT_ASSERT(!r.IsOk()); - } +)"); + const auto& r = MatchRecognizeSqlToYql(stmt); + if (n <= 6) { + UNIT_ASSERT(r.IsOk()); + } else { + UNIT_ASSERT(!r.IsOk()); } } +} +Y_UNIT_TEST(row_pattern_subset_clause) { + // TODO https://st.yandex-team.ru/YQL-16186 +} - Y_UNIT_TEST(row_pattern_subset_clause) { - //TODO https://st.yandex-team.ru/YQL-16186 - } - - Y_UNIT_TEST(Defines) { - auto stmt = R"( +Y_UNIT_TEST(Defines) { + auto stmt = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -704,34 +703,34 @@ FROM Input MATCH_RECOGNIZE( L as L.V = LAST(Q.T) ) )"; - auto r = MatchRecognizeSqlToYql(stmt); - UNIT_ASSERT(r.IsOk()); - const auto defines = FindMatchRecognizeParam(r.Root, "define"); - UNIT_ASSERT(IsListOfSize(defines, 7)); - const auto varNames = defines->GetChild(3); - UNIT_ASSERT(IsListOfAtoms(GetQuoted(varNames), {"Y", "Q", "L"}, GetQuoted)); - - UNIT_ASSERT(IsLambda(defines->GetChild(4), 3)); - UNIT_ASSERT(IsLambda(defines->GetChild(5), 3)); - UNIT_ASSERT(IsLambda(defines->GetChild(6), 3)); - } + auto r = MatchRecognizeSqlToYql(stmt); + UNIT_ASSERT(r.IsOk()); + const auto defines = FindMatchRecognizeParam(r.Root, "define"); + UNIT_ASSERT(IsListOfSize(defines, 7)); + const auto varNames = defines->GetChild(3); + UNIT_ASSERT(IsListOfAtoms(GetQuoted(varNames), {"Y", "Q", "L"}, GetQuoted)); + + UNIT_ASSERT(IsLambda(defines->GetChild(4), 3)); + UNIT_ASSERT(IsLambda(defines->GetChild(5), 3)); + UNIT_ASSERT(IsLambda(defines->GetChild(6), 3)); +} - Y_UNIT_TEST(AbsentRowPatternVariableInDefines) { - auto getStatement = [](const TString &var) { - return TStringBuilder() << R"( +Y_UNIT_TEST(AbsentRowPatternVariableInDefines) { + auto getStatement = [](const TString& var) { + return TStringBuilder() << R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( PATTERN ( Q ) DEFINE )" << var << " AS TRUE )"; - }; - UNIT_ASSERT(MatchRecognizeSqlToYql(getStatement("Q")).IsOk()); - UNIT_ASSERT(!MatchRecognizeSqlToYql(getStatement("Y")).IsOk()); - } + }; + UNIT_ASSERT(MatchRecognizeSqlToYql(getStatement("Q")).IsOk()); + UNIT_ASSERT(!MatchRecognizeSqlToYql(getStatement("Y")).IsOk()); +} - Y_UNIT_TEST(CheckRequiredNavigationFunction) { - TString stmtPrefix = R"( +Y_UNIT_TEST(CheckRequiredNavigationFunction) { + TString stmtPrefix = R"( USE plato; SELECT * FROM Input MATCH_RECOGNIZE( @@ -739,9 +738,9 @@ FROM Input MATCH_RECOGNIZE( DEFINE L as L.V = )"; - //Be aware that right parenthesis is added at the end of the query as required - UNIT_ASSERT(MatchRecognizeSqlToYql(stmtPrefix + "LAST(Q.dt) )").IsOk()); - UNIT_ASSERT(!MatchRecognizeSqlToYql(stmtPrefix + "Q.dt )").IsOk()); - } - + // Be aware that right parenthesis is added at the end of the query as required + UNIT_ASSERT(MatchRecognizeSqlToYql(stmtPrefix + "LAST(Q.dt) )").IsOk()); + UNIT_ASSERT(!MatchRecognizeSqlToYql(stmtPrefix + "Q.dt )").IsOk()); } + +} // Y_UNIT_TEST_SUITE(MatchRecognize) |