aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@yandex-team.ru>2022-04-01 16:59:38 +0300
committervvvv <vvvv@yandex-team.ru>2022-04-01 16:59:38 +0300
commit3d23aea57287cebf25f327f41cad3624ec33e0c6 (patch)
tree782fbeb7267e74e24c620f897698e0f949d402b9
parent3b1502256339d0e27d739bda65197ba16626d796 (diff)
downloadydb-3d23aea57287cebf25f327f41cad3624ec33e0c6.tar.gz
YQL-13710 swap arguments in WithContext
ref:eca2b35341997025fd8c8aa99ff7c53f6775c398
-rw-r--r--ydb/library/yql/core/common_opt/yql_co_simple1.cpp2
-rw-r--r--ydb/library/yql/core/expr_nodes/yql_expr_nodes.json4
-rw-r--r--ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp4
-rw-r--r--ydb/library/yql/core/type_ann/type_ann_core.cpp20
-rw-r--r--ydb/library/yql/core/yql_opt_aggregate.cpp4
-rw-r--r--ydb/library/yql/dq/opt/dq_opt_phy.cpp6
-rw-r--r--ydb/library/yql/minikql/mkql_program_builder.cpp2
-rw-r--r--ydb/library/yql/minikql/mkql_program_builder.h2
-rw-r--r--ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp4
9 files changed, 24 insertions, 24 deletions
diff --git a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
index 9ad79d9366..9330a6447d 100644
--- a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
+++ b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
@@ -2402,7 +2402,7 @@ TExprNode::TPtr OptimizeToFlow(const TExprNode::TPtr& node, TExprContext& ctx) {
if (node->Head().IsCallable("WithContext")) {
YQL_CLOG(DEBUG, Core) << "Swap " << node->Content() << " with " << node->Head().Content();
- return ctx.ChangeChild(node->Head(), 1, ctx.NewCallable(node->Pos(), "ToFlow", { node->Head().TailPtr() }));
+ return ctx.ChangeChild(node->Head(), 0, ctx.NewCallable(node->Pos(), "ToFlow", { node->Head().HeadPtr() }));
}
return node;
diff --git a/ydb/library/yql/core/expr_nodes/yql_expr_nodes.json b/ydb/library/yql/core/expr_nodes/yql_expr_nodes.json
index 6c1b345e18..65e5acba4f 100644
--- a/ydb/library/yql/core/expr_nodes/yql_expr_nodes.json
+++ b/ydb/library/yql/core/expr_nodes/yql_expr_nodes.json
@@ -2109,8 +2109,8 @@
"Base": "TCallable",
"Match": {"Type": "Callable", "Name": "WithContext"},
"Children": [
- {"Index": 0, "Name": "Name", "Type": "TCoAtom"},
- {"Index": 1, "Name": "Input", "Type": "TExprBase"}
+ {"Index": 0, "Name": "Input", "Type": "TExprBase"},
+ {"Index": 1, "Name": "Name", "Type": "TCoAtom"}
]
}
]
diff --git a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
index b385354b4d..128e1883b7 100644
--- a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
+++ b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
@@ -3426,7 +3426,7 @@ TExprNode::TPtr OptimizeExpandMap(const TExprNode::TPtr& node, TExprContext& ctx
/* TODO
if (const auto& input = node->Head(); input.IsCallable("WithContext")) {
YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << input.Content();
- return ctx.ChangeChild(input, 1, ctx.ChangeChild(*node, 0, input.TailPtr()));
+ return ctx.ChangeChild(input, 0, ctx.ChangeChild(*node, 0, input.HeadPtr()));
}
*/
return node;
@@ -4306,7 +4306,7 @@ TExprNode::TPtr OptimizeWideMaps(const TExprNode::TPtr& node, TExprContext& ctx)
return ctx.ChangeChildren(*node, {input.HeadPtr(), std::move(lambda)});
} else if (input.IsCallable("WithContext")) {
YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << input.Content();
- return ctx.ChangeChild(input, 1U, ctx.ChangeChild(*node, 0U, input.TailPtr()));
+ return ctx.ChangeChild(input, 0U, ctx.ChangeChild(*node, 0U, input.HeadPtr()));
}
return node;
diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp
index ee39787182..dda74daf31 100644
--- a/ydb/library/yql/core/type_ann/type_ann_core.cpp
+++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp
@@ -3200,35 +3200,35 @@ namespace NTypeAnnImpl {
return IGraphTransformer::TStatus::Error;
}
- if (!EnsureAtom(input->Head(), ctx.Expr)) {
+ if (!EnsureAtom(input->Tail(), ctx.Expr)) {
return IGraphTransformer::TStatus::Error;
}
- if (input->Head().Content() != "Agg" && input->Head().Content() != "WinAgg") {
- ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Head().Pos()), TStringBuilder() <<
- "Unexpected context type: " << input->Head().Content()));
+ if (input->Tail().Content() != "Agg" && input->Tail().Content() != "WinAgg") {
+ ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Tail().Pos()), TStringBuilder() <<
+ "Unexpected context type: " << input->Tail().Content()));
return IGraphTransformer::TStatus::Error;
}
- if (!EnsureComputable(input->Tail(), ctx.Expr)) {
+ if (!EnsureComputable(input->Head(), ctx.Expr)) {
return IGraphTransformer::TStatus::Error;
}
- if (input->Tail().GetTypeAnn()->GetKind() == ETypeAnnotationKind::Stream) {
+ if (input->Head().GetTypeAnn()->GetKind() == ETypeAnnotationKind::Stream) {
output = ctx.Expr.Builder(input->Pos())
.Callable("FromFlow")
.Callable("WithContext")
- .Add(0, input->HeadPtr())
- .Callable(1, "ToFlow")
- .Add(0, input->TailPtr())
+ .Callable(0, "ToFlow")
+ .Add(0, input->HeadPtr())
.Seal()
+ .Add(1, input->TailPtr())
.Seal()
.Seal()
.Build();
return IGraphTransformer::TStatus::Repeat;
}
- input->SetTypeAnn(input->Tail().GetTypeAnn());
+ input->SetTypeAnn(input->Head().GetTypeAnn());
return IGraphTransformer::TStatus::Ok;
}
diff --git a/ydb/library/yql/core/yql_opt_aggregate.cpp b/ydb/library/yql/core/yql_opt_aggregate.cpp
index 6b895bf7fa..7e5d24dc4b 100644
--- a/ydb/library/yql/core/yql_opt_aggregate.cpp
+++ b/ydb/library/yql/core/yql_opt_aggregate.cpp
@@ -40,8 +40,8 @@ TExprNode::TPtr ExpandAggregate(const TExprNode::TPtr& node, TExprContext& ctx,
.Lambda()
.Param("stream")
.Callable("WithContext")
- .Atom(0, "Agg")
- .Arg(1, "stream")
+ .Arg(0, "stream")
+ .Atom(1, "Agg")
.Seal()
.Seal()
.Build() :
diff --git a/ydb/library/yql/dq/opt/dq_opt_phy.cpp b/ydb/library/yql/dq/opt/dq_opt_phy.cpp
index e4c54c3150..a76997b238 100644
--- a/ydb/library/yql/dq/opt/dq_opt_phy.cpp
+++ b/ydb/library/yql/dq/opt/dq_opt_phy.cpp
@@ -582,13 +582,13 @@ TExprBase DqPushCombineToStage(TExprBase node, TExprContext& ctx, IOptimizationC
lambda = Build<TCoLambda>(ctx, combine.Pos())
.Args({ TStringBuf("stream") })
.Body<TCoWithContext>()
- .Name()
- .Value("Agg")
- .Build()
.Input<TExprApplier>()
.Apply(lambda)
.With(0, TStringBuf("stream"))
.Build()
+ .Name()
+ .Value("Agg")
+ .Build()
.Build()
.Done();
}
diff --git a/ydb/library/yql/minikql/mkql_program_builder.cpp b/ydb/library/yql/minikql/mkql_program_builder.cpp
index 3d8e454beb..c05f7617f2 100644
--- a/ydb/library/yql/minikql/mkql_program_builder.cpp
+++ b/ydb/library/yql/minikql/mkql_program_builder.cpp
@@ -5093,7 +5093,7 @@ TRuntimeNode TProgramBuilder::ToPg(TRuntimeNode input, TType* returnType) {
return TRuntimeNode(callableBuilder.Build(), false);
}
-TRuntimeNode TProgramBuilder::WithContext(const std::string_view& contextType, TRuntimeNode input) {
+TRuntimeNode TProgramBuilder::WithContext(TRuntimeNode input, const std::string_view& contextType) {
if constexpr (RuntimeVersion < 30U) {
THROW yexception() << "Runtime version (" << RuntimeVersion << ") too old for " << __func__;
}
diff --git a/ydb/library/yql/minikql/mkql_program_builder.h b/ydb/library/yql/minikql/mkql_program_builder.h
index cf86862078..04cfa701b1 100644
--- a/ydb/library/yql/minikql/mkql_program_builder.h
+++ b/ydb/library/yql/minikql/mkql_program_builder.h
@@ -629,7 +629,7 @@ public:
TRuntimeNode PgCast(TRuntimeNode input, TType* returnType);
TRuntimeNode FromPg(TRuntimeNode input, TType* returnType);
TRuntimeNode ToPg(TRuntimeNode input, TType* returnType);
- TRuntimeNode WithContext(const std::string_view& contextType, TRuntimeNode input);
+ TRuntimeNode WithContext(TRuntimeNode input, const std::string_view& contextType);
TRuntimeNode PgInternal0(TType* returnType);
protected:
diff --git a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
index 2fc40f294c..a1215a254e 100644
--- a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
+++ b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
@@ -2294,8 +2294,8 @@ TMkqlCommonCallableCompiler::TShared::TShared() {
});
AddCallable("WithContext", [](const TExprNode& node, TMkqlBuildContext& ctx) {
- auto input = MkqlBuildExpr(*node.Child(1), ctx);
- return ctx.ProgramBuilder.WithContext(node.Child(0)->Content(), input);
+ auto input = MkqlBuildExpr(*node.Child(0), ctx);
+ return ctx.ProgramBuilder.WithContext(input, node.Child(1)->Content());
});
AddCallable("QueueCreate", [](const TExprNode& node, TMkqlBuildContext& ctx) {