aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony-Romanov <150126326+Tony-Romanov@users.noreply.github.com>2024-01-29 09:53:07 +0100
committerGitHub <noreply@github.com>2024-01-29 09:53:07 +0100
commit93067e7045be055a88ea46e4ad51da508bca47bd (patch)
tree810a20fa35c83a8cece9c21cd65654b376c2f378
parent14521dd357a680149f8000fa69ae0d8ffd5d41d4 (diff)
downloadydb-93067e7045be055a88ea46e4ad51da508bca47bd.tar.gz
Fix optimizer and return back KQP peephole type check. (#842)
* Fix optimizer and return back KQP peephole type check. * A little fix. * Canonize test.
-rw-r--r--ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp10
-rw-r--r--ydb/library/yql/dq/opt/dq_opt_peephole.cpp10
-rw-r--r--ydb/tests/functional/suite_tests/canondata/test_postgres.TestPGSQL.test_sql_suite_plan-jointest_join0.test_/query_14.plan9
3 files changed, 10 insertions, 19 deletions
diff --git a/ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp b/ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp
index b8ac524ff9..bbb3dd54d2 100644
--- a/ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp
+++ b/ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp
@@ -87,8 +87,7 @@ TStatus ReplaceNonDetFunctionsWithParams(TExprNode::TPtr& input, TExprContext& c
class TKqpPeepholeTransformer : public TOptimizeTransformerBase {
public:
TKqpPeepholeTransformer(TTypeAnnotationContext& typesCtx)
- : TOptimizeTransformerBase(nullptr, NYql::NLog::EComponent::ProviderKqp, {})
- , TypesCtx(typesCtx)
+ : TOptimizeTransformerBase(&typesCtx, NYql::NLog::EComponent::ProviderKqp, {})
{
#define HNDL(name) "KqpPeephole-"#name, Hndl(&TKqpPeepholeTransformer::name)
AddHandler(0, &TDqReplicate::Match, HNDL(RewriteReplicate));
@@ -134,13 +133,13 @@ protected:
}
TMaybeNode<TExprBase> BuildWideReadTable(TExprBase node, TExprContext& ctx) {
- TExprBase output = KqpBuildWideReadTable(node, ctx, TypesCtx);
+ TExprBase output = KqpBuildWideReadTable(node, ctx, *Types);
DumpAppliedRule("BuildWideReadTable", node.Ptr(), output.Ptr(), ctx);
return output;
}
TMaybeNode<TExprBase> RewriteLength(TExprBase node, TExprContext& ctx) {
- TExprBase output = DqPeepholeRewriteLength(node, ctx, TypesCtx);
+ TExprBase output = DqPeepholeRewriteLength(node, ctx, *Types);
DumpAppliedRule("RewriteLength", node.Ptr(), output.Ptr(), ctx);
return output;
}
@@ -150,9 +149,6 @@ protected:
DumpAppliedRule("RewriteKqpWriteConstraint", node.Ptr(), output.Ptr(), ctx);
return output;
}
-
-private:
- TTypeAnnotationContext& TypesCtx;
};
struct TKqpPeepholePipelineConfigurator : IPipelineConfigurator {
diff --git a/ydb/library/yql/dq/opt/dq_opt_peephole.cpp b/ydb/library/yql/dq/opt/dq_opt_peephole.cpp
index 11877696b4..6ce322bfc5 100644
--- a/ydb/library/yql/dq/opt/dq_opt_peephole.cpp
+++ b/ydb/library/yql/dq/opt/dq_opt_peephole.cpp
@@ -511,18 +511,18 @@ NNodes::TExprBase DqPeepholeRewriteJoinDict(const NNodes::TExprBase& node, TExpr
rightKeySelector = BuildDictKeySelector(ctx, joinDict.Pos(), rightKeys, keyTypeItems, castKeyRight);
}
- auto streamToDict = [&ctx](const TExprBase& input, const TExprNode::TPtr& keySelector) {
+ const auto streamToDict = [&ctx](const TExprBase& input, const TExprNode::TPtr& keySelector) {
return Build<TCoSqueezeToDict>(ctx, input.Pos())
- .Stream(input)
+ .Stream(TCoIterator::Match(input.Raw()) ? TExprBase(ctx.RenameNode(input.Ref(), TCoToFlow::CallableName())) : input)
.KeySelector(keySelector)
.PayloadSelector()
.Args({"item"})
.Body("item")
.Build()
.Settings()
- .Add<TCoAtom>().Build("Hashed")
- .Add<TCoAtom>().Build("Many")
- .Add<TCoAtom>().Build("Compact")
+ .Add<TCoAtom>().Build("Hashed", TNodeFlags::Default)
+ .Add<TCoAtom>().Build("Many", TNodeFlags::Default)
+ .Add<TCoAtom>().Build("Compact", TNodeFlags::Default)
.Build()
.Done();
};
diff --git a/ydb/tests/functional/suite_tests/canondata/test_postgres.TestPGSQL.test_sql_suite_plan-jointest_join0.test_/query_14.plan b/ydb/tests/functional/suite_tests/canondata/test_postgres.TestPGSQL.test_sql_suite_plan-jointest_join0.test_/query_14.plan
index f309a146c2..a32ec829c0 100644
--- a/ydb/tests/functional/suite_tests/canondata/test_postgres.TestPGSQL.test_sql_suite_plan-jointest_join0.test_/query_14.plan
+++ b/ydb/tests/functional/suite_tests/canondata/test_postgres.TestPGSQL.test_sql_suite_plan-jointest_join0.test_/query_14.plan
@@ -70,7 +70,7 @@
"PlanNodeType": "Connection",
"Plans": [
{
- "Node Type": "FullJoin (JoinDict)-ConstantExpr",
+ "Node Type": "FullJoin (JoinDict)",
"Operators": [
{
"Inputs": [
@@ -78,15 +78,10 @@
"ExternalPlanNodeId": 4
},
{
- "InternalOperatorId": 1
+ "Other": "ConstantExpression"
}
],
"Name": "FullJoin (JoinDict)"
- },
- {
- "Inputs": [],
- "Iterator": "[{id: 1}]",
- "Name": "Iterator"
}
],
"PlanNodeId": 5,