summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-01-20 16:38:10 +0300
committervvvv <[email protected]>2025-01-20 17:00:30 +0300
commit6b3e7777077b0112e088056abc7093db18d7bec0 (patch)
treedd79c706aadcb821936dfcf375a58b6adb2d00fd /yql/essentials/sql
parentb6a2451a8ed4ad6c210751fcf6ae3d28998235f1 (diff)
Introduced TableSource wrapper and Blocks/Peephole mode for minirun tests
init commit_hash:22d9a4470f726b8efcd86aaf043bfa5552c2b35e
Diffstat (limited to 'yql/essentials/sql')
-rw-r--r--yql/essentials/sql/v1/context.cpp1
-rw-r--r--yql/essentials/sql/v1/context.h1
-rw-r--r--yql/essentials/sql/v1/select.cpp17
-rw-r--r--yql/essentials/sql/v1/source.h2
-rw-r--r--yql/essentials/sql/v1/sql_query.cpp6
-rw-r--r--yql/essentials/sql/v1/sql_translation.cpp2
6 files changed, 22 insertions, 7 deletions
diff --git a/yql/essentials/sql/v1/context.cpp b/yql/essentials/sql/v1/context.cpp
index 64eca540d77..43afc53c38b 100644
--- a/yql/essentials/sql/v1/context.cpp
+++ b/yql/essentials/sql/v1/context.cpp
@@ -58,6 +58,7 @@ THashMap<TStringBuf, TPragmaField> CTX_PRAGMA_FIELDS = {
{"EmitStartsWith", &TContext::EmitStartsWith},
{"AnsiLike", &TContext::AnsiLike},
{"UseBlocks", &TContext::UseBlocks},
+ {"EmitTableSource", &TContext::EmitTableSource},
{"BlockEngineEnable", &TContext::BlockEngineEnable},
{"BlockEngineForce", &TContext::BlockEngineForce},
{"UnorderedResult", &TContext::UnorderedResult},
diff --git a/yql/essentials/sql/v1/context.h b/yql/essentials/sql/v1/context.h
index de7760a5d1f..a5001fd157c 100644
--- a/yql/essentials/sql/v1/context.h
+++ b/yql/essentials/sql/v1/context.h
@@ -314,6 +314,7 @@ namespace NSQLTranslationV1 {
bool EmitStartsWith = true;
TMaybe<bool> EmitAggApply;
bool UseBlocks = false;
+ bool EmitTableSource = false;
bool AnsiLike = false;
bool FeatureR010 = false; //Row pattern recognition: FROM clause
TMaybe<bool> CompactGroupBy;
diff --git a/yql/essentials/sql/v1/select.cpp b/yql/essentials/sql/v1/select.cpp
index 4f5db440696..bf8287e89a3 100644
--- a/yql/essentials/sql/v1/select.cpp
+++ b/yql/essentials/sql/v1/select.cpp
@@ -265,10 +265,11 @@ TSourcePtr BuildFakeSource(TPosition pos, bool missingFrom, bool inSubquery) {
class TNodeSource: public ISource {
public:
- TNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList)
+ TNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList, bool wrapByTableSource)
: ISource(pos)
, Node(node)
, WrapToList(wrapToList)
+ , WrapByTableSource(wrapByTableSource)
{
YQL_ENSURE(Node);
FakeSource = BuildFakeSource(pos);
@@ -296,21 +297,27 @@ public:
if (WrapToList) {
nodeAst = Y("ToList", nodeAst);
}
+
+ if (WrapByTableSource) {
+ nodeAst = Y("TableSource", nodeAst);
+ }
+
return nodeAst;
}
TPtr DoClone() const final {
- return new TNodeSource(Pos, SafeClone(Node), WrapToList);
+ return new TNodeSource(Pos, SafeClone(Node), WrapToList, WrapByTableSource);
}
private:
TNodePtr Node;
- bool WrapToList;
+ const bool WrapToList;
+ const bool WrapByTableSource;
TSourcePtr FakeSource;
};
-TSourcePtr BuildNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList) {
- return new TNodeSource(pos, node, wrapToList);
+TSourcePtr BuildNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList, bool wrapByTableSource) {
+ return new TNodeSource(pos, node, wrapToList, wrapByTableSource);
}
class IProxySource: public ISource {
diff --git a/yql/essentials/sql/v1/source.h b/yql/essentials/sql/v1/source.h
index f69684b03e6..bd311567d38 100644
--- a/yql/essentials/sql/v1/source.h
+++ b/yql/essentials/sql/v1/source.h
@@ -242,7 +242,7 @@ namespace NSQLTranslationV1 {
TNodePtr BuildSourceNode(TPosition pos, TSourcePtr source, bool checkExist = false);
TSourcePtr BuildMuxSource(TPosition pos, TVector<TSourcePtr>&& sources);
TSourcePtr BuildFakeSource(TPosition pos, bool missingFrom = false, bool inSubquery = false);
- TSourcePtr BuildNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList = false);
+ TSourcePtr BuildNodeSource(TPosition pos, const TNodePtr& node, bool wrapToList = false, bool wrapByTableSource = false);
TSourcePtr BuildTableSource(TPosition pos, const TTableRef& table, const TString& label = TString());
TSourcePtr BuildInnerSource(TPosition pos, TNodePtr node, const TString& service, const TDeferredAtom& cluster, const TString& label = TString());
TSourcePtr BuildRefColumnSource(TPosition pos, const TString& partExpression);
diff --git a/yql/essentials/sql/v1/sql_query.cpp b/yql/essentials/sql/v1/sql_query.cpp
index 9b8c1182db6..eb1a174b30c 100644
--- a/yql/essentials/sql/v1/sql_query.cpp
+++ b/yql/essentials/sql/v1/sql_query.cpp
@@ -3046,6 +3046,12 @@ TNodePtr TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt, bool& success
} else if (normalizedPragma == "disableuseblocks") {
Ctx.UseBlocks = false;
Ctx.IncrementMonCounter("sql_pragma", "DisableUseBlocks");
+ } else if (normalizedPragma == "emittablesource") {
+ Ctx.EmitTableSource = true;
+ Ctx.IncrementMonCounter("sql_pragma", "EmitTableSource");
+ } else if (normalizedPragma == "disableemittablesource") {
+ Ctx.EmitTableSource = false;
+ Ctx.IncrementMonCounter("sql_pragma", "DisableEmitTableSource");
} else if (normalizedPragma == "ansilike") {
Ctx.AnsiLike = true;
Ctx.IncrementMonCounter("sql_pragma", "AnsiLike");
diff --git a/yql/essentials/sql/v1/sql_translation.cpp b/yql/essentials/sql/v1/sql_translation.cpp
index 5dc95b3fcde..9989295291a 100644
--- a/yql/essentials/sql/v1/sql_translation.cpp
+++ b/yql/essentials/sql/v1/sql_translation.cpp
@@ -1479,7 +1479,7 @@ TMaybe<TSourcePtr> TSqlTranslation::AsTableImpl(const TRule_table_ref& node) {
return TMaybe<TSourcePtr>(nullptr);
}
- return BuildNodeSource(Ctx.Pos(), arg->Expr, true);
+ return BuildNodeSource(Ctx.Pos(), arg->Expr, true, Ctx.EmitTableSource);
}
}