diff options
author | kndrvt <[email protected]> | 2025-05-27 12:21:32 +0300 |
---|---|---|
committer | kndrvt <[email protected]> | 2025-05-27 12:35:09 +0300 |
commit | 66037646e2c2d277e0406a6b23eca63b62357916 (patch) | |
tree | 3845fbb8be3a9b91aeaa892af793aafa013a7ff2 /yql/essentials/sql/v1/sql_select.cpp | |
parent | 0c00e886d1f9ca57d86722925b12be1e125f878c (diff) |
YQL-17269: add DISTINCT to UNION
commit_hash:d002e9690bd7cbd1874fdbfe454c9f7a00256839
Diffstat (limited to 'yql/essentials/sql/v1/sql_select.cpp')
-rw-r--r-- | yql/essentials/sql/v1/sql_select.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/yql/essentials/sql/v1/sql_select.cpp b/yql/essentials/sql/v1/sql_select.cpp index 52dd399a990..8e11721c84f 100644 --- a/yql/essentials/sql/v1/sql_select.cpp +++ b/yql/essentials/sql/v1/sql_select.cpp @@ -1388,18 +1388,28 @@ TSourcePtr TSqlSelect::Build(const TRule& node, TPosition pos, TSelectKindResult outermostSettings.Label = next.Settings.Label; } - switch (b.GetRule_select_op1().Alt_case()) { - case TRule_select_op::kAltSelectOp1: - break; - case TRule_select_op::kAltSelectOp2: - case TRule_select_op::kAltSelectOp3: - Ctx.Error() << "INTERSECT and EXCEPT are not implemented yet"; - return nullptr; - case TRule_select_op::ALT_NOT_SET: - Y_ABORT("You should change implementation according to grammar changes"); + auto selectOp = b.GetRule_select_op1(); + const TString token = ToLowerUTF8(Token(selectOp.GetToken1())); + if (token == "union") { + // nothing + } else if (token == "intersect" || token == "except") { + Ctx.Error() << "INTERSECT and EXCEPT are not implemented yet"; + return nullptr; + } else { + Y_ABORT("You should change implementation according to grammar changes. Invalid token: %s", token.c_str()); } - const bool quantifier = b.GetRule_select_op1().GetAlt_select_op1().HasBlock2(); + bool quantifier = false; + if (selectOp.HasBlock2()) { + const TString token = ToLowerUTF8(Token(selectOp.GetBlock2().GetToken1())); + if (token == "all") { + quantifier = true; + } else if (token == "distinct") { + // nothing + } else { + Y_ABORT("You should change implementation according to grammar changes. Invalid token: %s", token.c_str()); + } + } if (!second && quantifier != currentQuantifier) { auto source = BuildUnion(pos, std::move(sources), currentQuantifier, {}); |