Skip to content

Commit c4eb6d0

Browse files
authored
Merge a58af04 into 669e2b5
2 parents 669e2b5 + a58af04 commit c4eb6d0

File tree

16 files changed

+174
-176
lines changed

16 files changed

+174
-176
lines changed

ydb/library/yql/minikql/comp_nodes/mkql_match_recognize.cpp

Lines changed: 52 additions & 161 deletions
Large diffs are not rendered by default.

ydb/library/yql/minikql/comp_nodes/mkql_match_recognize_nfa.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ class TNfaTransitionGraphBuilder {
283283
return {input, output};
284284
}
285285
public:
286-
using TPatternConfigurationPtr = TNfaTransitionGraph::TPtr;
287-
static TPatternConfigurationPtr Create(const TRowPattern& pattern, const THashMap<TString, size_t>& varNameToIndex) {
286+
static TNfaTransitionGraph::TPtr Create(const TRowPattern& pattern, const THashMap<TString, size_t>& varNameToIndex) {
288287
auto result = std::make_shared<TNfaTransitionGraph>();
289288
TNfaTransitionGraphBuilder builder(result);
290289
auto item = builder.BuildTerms(pattern, varNameToIndex);
@@ -455,6 +454,10 @@ class TNfa {
455454
serializer.Read(EpsilonTransitionsLastRow);
456455
}
457456

457+
void Clear() {
458+
ActiveStates.clear();
459+
}
460+
458461
private:
459462
//TODO (zverevgeny): Consider to change to std::vector for the sake of perf
460463
using TStateSet = std::set<TState, std::less<TState>, TMKQLAllocator<TState>>;

ydb/library/yql/minikql/comp_nodes/ut/mkql_match_recognize_ut.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ namespace NKikimr {
115115
{NYql::NMatchRecognize::TRowPatternFactor{"A", 3, 3, false, false, false}}
116116
},
117117
getDefines,
118+
false,
118119
streamingMode);
119120

120121
auto graph = setup.BuildGraph(pgmReturn);

ydb/library/yql/minikql/mkql_program_builder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5973,6 +5973,7 @@ TRuntimeNode TProgramBuilder::MatchRecognizeCore(
59735973
const TArrayRef<std::pair<TStringBuf, TBinaryLambda>>& getMeasures,
59745974
const NYql::NMatchRecognize::TRowPattern& pattern,
59755975
const TArrayRef<std::pair<TStringBuf, TTernaryLambda>>& getDefines,
5976+
bool afterMatchSkipPastLastRow,
59765977
bool streamingMode
59775978
) {
59785979
MKQL_ENSURE(RuntimeVersion >= 42, "MatchRecognize is not supported in runtime version " << RuntimeVersion);
@@ -6126,6 +6127,7 @@ TRuntimeNode TProgramBuilder::MatchRecognizeCore(
61266127
for (const auto& d: defineNodes) {
61276128
callableBuilder.Add(d);
61286129
}
6130+
callableBuilder.Add(NewDataLiteral(afterMatchSkipPastLastRow));
61296131
callableBuilder.Add(NewDataLiteral(streamingMode));
61306132
return TRuntimeNode(callableBuilder.Build(), false);
61316133
}

ydb/library/yql/minikql/mkql_program_builder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ class TProgramBuilder : public TTypeBuilder {
713713
const TArrayRef<std::pair<TStringBuf, TBinaryLambda>>& getMeasures,
714714
const NYql::NMatchRecognize::TRowPattern& pattern,
715715
const TArrayRef<std::pair<TStringBuf, TTernaryLambda>>& getDefines,
716+
bool afterMatchSkipPastLastRow,
716717
bool streamingMode
717718
);
718719

ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ TMkqlCommonCallableCompiler::TShared::TShared() {
878878

879879
//explore params
880880
const auto& measures = params->ChildRef(0);
881+
const auto& skip = params->ChildRef(2);
881882
const auto& pattern = params->ChildRef(3);
882883
const auto& defines = params->ChildRef(4);
883884

@@ -920,6 +921,10 @@ TMkqlCommonCallableCompiler::TShared::TShared() {
920921
};
921922
}
922923

924+
auto to = skip->Child(0)->Content();
925+
MKQL_ENSURE(to.SkipPrefix("AfterMatchSkip_"), R"(MATCH_RECOGNIZE: <row pattern skip to> should start with "AfterMatchSkip_")");
926+
const auto afterMatchSkipPastLastRow = to == "PastLastRow";
927+
923928
const auto streamingMode = FromString<bool>(settings->Child(0)->Child(1)->Content());
924929

925930
return ctx.ProgramBuilder.MatchRecognizeCore(
@@ -929,6 +934,7 @@ TMkqlCommonCallableCompiler::TShared::TShared() {
929934
getMeasures,
930935
NYql::NMatchRecognize::ConvertPattern(pattern, ctx.ExprCtx),
931936
getDefines,
937+
afterMatchSkipPastLastRow,
932938
streamingMode
933939
);
934940
});

ydb/library/yql/sql/v1/sql_match_recognize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TMatchRecognizeBuilderPtr TSqlMatchRecognizeClause::CreateBuilder(const NSQLv1Ge
7878

7979
//this block is located before pattern block in grammar,
8080
// but depends on it, so it is processed after pattern block
81-
std::pair<TPosition, TAfterMatchSkipTo> skipTo { pos, TAfterMatchSkipTo{EAfterMatchSkipTo::NextRow, TString()} };
81+
std::pair<TPosition, TAfterMatchSkipTo> skipTo { pos, TAfterMatchSkipTo{EAfterMatchSkipTo::PastLastRow, TString()} };
8282
if (commonSyntax.HasBlock1()){
8383
skipTo = ParseAfterMatchSkipTo(commonSyntax.GetBlock1().GetRule_row_pattern_skip_to3());
8484
const auto varRequired =

ydb/library/yql/tests/sql/dq_file/part5/canondata/result.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,28 @@
20832083
}
20842084
],
20852085
"test.test[key_filter-utf8_with_legacy--Results]": [],
2086+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Analyze]": [
2087+
{
2088+
"checksum": "b4dd508a329723c74293d80f0278c705",
2089+
"size": 505,
2090+
"uri": "https://{canondata_backend}/1031349/a955c852651ea9f8124bef13bd770d8d15af6c2e/resource.tar.gz#test.test_match_recognize-after_match_skip_past_last_row-default.txt-Analyze_/plan.txt"
2091+
}
2092+
],
2093+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Debug]": [
2094+
{
2095+
"checksum": "7911a3e7570665753b1e25827635db15",
2096+
"size": 1317,
2097+
"uri": "https://{canondata_backend}/1031349/a955c852651ea9f8124bef13bd770d8d15af6c2e/resource.tar.gz#test.test_match_recognize-after_match_skip_past_last_row-default.txt-Debug_/opt.yql_patched"
2098+
}
2099+
],
2100+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Plan]": [
2101+
{
2102+
"checksum": "b4dd508a329723c74293d80f0278c705",
2103+
"size": 505,
2104+
"uri": "https://{canondata_backend}/1031349/a955c852651ea9f8124bef13bd770d8d15af6c2e/resource.tar.gz#test.test_match_recognize-after_match_skip_past_last_row-default.txt-Plan_/plan.txt"
2105+
}
2106+
],
2107+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Results]": [],
20862108
"test.test[optimizers-test_lmap_opts--Analyze]": [
20872109
{
20882110
"checksum": "a019f0e33bc55441f2581dc8345a6b9e",

ydb/library/yql/tests/sql/hybrid_file/part4/canondata/result.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,20 @@
16931693
"uri": "https://{canondata_backend}/1809005/7e4dc59583cad760822faf30fa4695e365329148/resource.tar.gz#test.test_limit-empty_sort_calc_after_limit-default.txt-Plan_/plan.txt"
16941694
}
16951695
],
1696+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Debug]": [
1697+
{
1698+
"checksum": "e6a51f8c3ed77a2c4dfdf2e55ec4517d",
1699+
"size": 1316,
1700+
"uri": "https://{canondata_backend}/1880306/5213fbc312a45950f1152a68258af55d6e4976a2/resource.tar.gz#test.test_match_recognize-after_match_skip_past_last_row-default.txt-Debug_/opt.yql_patched"
1701+
}
1702+
],
1703+
"test.test[match_recognize-after_match_skip_past_last_row-default.txt-Plan]": [
1704+
{
1705+
"checksum": "b4dd508a329723c74293d80f0278c705",
1706+
"size": 505,
1707+
"uri": "https://{canondata_backend}/1880306/5213fbc312a45950f1152a68258af55d6e4976a2/resource.tar.gz#test.test_match_recognize-after_match_skip_past_last_row-default.txt-Plan_/plan.txt"
1708+
}
1709+
],
16961710
"test.test[optimizers-nonselected_direct_row--Debug]": [
16971711
{
16981712
"checksum": "a508c130bc5c1ccfe64ed08be50ee04b",

ydb/library/yql/tests/sql/sql2yql/canondata/result.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10982,6 +10982,13 @@
1098210982
"uri": "https://{canondata_backend}/1599023/66d0b07d601bb15f0e0b65bb7b4d493f89c1c283/resource.tar.gz#test_sql2yql.test_lineage-with_inline_/sql.yql"
1098310983
}
1098410984
],
10985+
"test_sql2yql.test[match_recognize-after_match_skip_past_last_row]": [
10986+
{
10987+
"checksum": "bb84286a97914c6cfd2e47288a49335e",
10988+
"size": 3122,
10989+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql2yql.test_match_recognize-after_match_skip_past_last_row_/sql.yql"
10990+
}
10991+
],
1098510992
"test_sql2yql.test[match_recognize-alerts-streaming]": [
1098610993
{
1098710994
"checksum": "608ebe5a00413e80b8e74157944f0b65",
@@ -30729,32 +30736,39 @@
3072930736
"uri": "https://{canondata_backend}/1599023/66d0b07d601bb15f0e0b65bb7b4d493f89c1c283/resource.tar.gz#test_sql_format.test_lineage-with_inline_/formatted.sql"
3073030737
}
3073130738
],
30739+
"test_sql_format.test[match_recognize-after_match_skip_past_last_row]": [
30740+
{
30741+
"checksum": "100b9f9651315a432e18868c21b776d6",
30742+
"size": 412,
30743+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql_format.test_match_recognize-after_match_skip_past_last_row_/formatted.sql"
30744+
}
30745+
],
3073230746
"test_sql_format.test[match_recognize-alerts-streaming]": [
3073330747
{
30734-
"checksum": "b8aa97680d42faf26e093c2a3ccb05f1",
30735-
"size": 2939,
30736-
"uri": "https://{canondata_backend}/1937001/da4215d5087e56eec0224ec5e7754dafd0b2bdcf/resource.tar.gz#test_sql_format.test_match_recognize-alerts-streaming_/formatted.sql"
30748+
"checksum": "d3a3fd90c8a6a758f0067dd66566d37a",
30749+
"size": 2968,
30750+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql_format.test_match_recognize-alerts-streaming_/formatted.sql"
3073730751
}
3073830752
],
3073930753
"test_sql_format.test[match_recognize-alerts]": [
3074030754
{
30741-
"checksum": "585357811c1f0240f4c3207baf8d66f3",
30742-
"size": 2941,
30743-
"uri": "https://{canondata_backend}/1937001/da4215d5087e56eec0224ec5e7754dafd0b2bdcf/resource.tar.gz#test_sql_format.test_match_recognize-alerts_/formatted.sql"
30755+
"checksum": "26acb44218b8f1112df875867fe530ef",
30756+
"size": 2970,
30757+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql_format.test_match_recognize-alerts_/formatted.sql"
3074430758
}
3074530759
],
3074630760
"test_sql_format.test[match_recognize-alerts_without_order]": [
3074730761
{
30748-
"checksum": "779c2c3a4eab619646509ce5008863e8",
30749-
"size": 2906,
30750-
"uri": "https://{canondata_backend}/1937001/f1ec239726ab3e2cf00695f3d10461ff9ef6c3b0/resource.tar.gz#test_sql_format.test_match_recognize-alerts_without_order_/formatted.sql"
30762+
"checksum": "0e6e55207b31bb4597a16821c0b3ac34",
30763+
"size": 2935,
30764+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql_format.test_match_recognize-alerts_without_order_/formatted.sql"
3075130765
}
3075230766
],
3075330767
"test_sql_format.test[match_recognize-permute]": [
3075430768
{
30755-
"checksum": "998e6752ce413cc78e952b9958dfab74",
30756-
"size": 721,
30757-
"uri": "https://{canondata_backend}/1600758/90e7657ff4d9210d12f860921bc22e4e3c794cc5/resource.tar.gz#test_sql_format.test_match_recognize-permute_/formatted.sql"
30769+
"checksum": "97960de85a125f078b142f62ebfe938e",
30770+
"size": 750,
30771+
"uri": "https://{canondata_backend}/1130705/ab8dea65d8ef4022fe05bde8ae56bb987e245f04/resource.tar.gz#test_sql_format.test_match_recognize-permute_/formatted.sql"
3075830772
}
3075930773
],
3076030774
"test_sql_format.test[match_recognize-simple_paritioning-streaming]": [

0 commit comments

Comments
 (0)