aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_expression.cpp
diff options
context:
space:
mode:
authorvvvv <vvvv@yandex-team.com>2025-01-29 16:02:22 +0300
committervvvv <vvvv@yandex-team.com>2025-01-29 16:23:33 +0300
commit15cba7449cdb7409f8e0ac12c6f77cb22e6e7bed (patch)
tree2e89b429c7870c2bab4a2af3d3d4015dc3b39ead /yql/essentials/sql/v1/sql_expression.cpp
parentbe36d7b60684c12f59cbbb6ef49017e5d7f4440d (diff)
downloadydb-15cba7449cdb7409f8e0ac12c6f77cb22e6e7bed.tar.gz
EXISTS with tables YQL-19496
commit_hash:76639a66853d8a9d514e4b11f47e14e2d26e26c4
Diffstat (limited to 'yql/essentials/sql/v1/sql_expression.cpp')
-rw-r--r--yql/essentials/sql/v1/sql_expression.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/sql_expression.cpp b/yql/essentials/sql/v1/sql_expression.cpp
index 199f15f293..c2074cb50d 100644
--- a/yql/essentials/sql/v1/sql_expression.cpp
+++ b/yql/essentials/sql/v1/sql_expression.cpp
@@ -1308,7 +1308,22 @@ TNodePtr TSqlExpression::ExistsRule(const TRule_exists_expr& rule) {
return nullptr;
}
const bool checkExist = true;
- return BuildBuiltinFunc(Ctx, Ctx.Pos(), "ListHasItems", {BuildSourceNode(pos, std::move(source), checkExist)});
+ auto select = BuildSourceNode(Ctx.Pos(), source, checkExist);
+ if (Ctx.Settings.EmitReadsForExists) {
+ TTableList tableList;
+ source->GetInputTables(tableList);
+
+ TNodePtr inputTables(BuildInputTables(Ctx.Pos(), tableList, false, Ctx.Scoped));
+ if (!inputTables->Init(Ctx, source.Get())) {
+ return nullptr;
+ }
+
+ auto node = inputTables;
+ node = node->L(node, node->Y("return", select));
+ select = node->Y("block", node->Q(node));
+ }
+
+ return BuildBuiltinFunc(Ctx, Ctx.Pos(), "ListHasItems", {select});
}
TNodePtr TSqlExpression::CaseRule(const TRule_case_expr& rule) {