diff options
author | Alexander Smirnov <alex@ydb.tech> | 2025-04-19 00:51:37 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2025-04-19 00:51:37 +0000 |
commit | c46f4db13aad94d84f1930f145dc0d4cf79cbf43 (patch) | |
tree | f59e23b072305d922f5836f129bcd0c7dac5fdc9 /yql/essentials/sql/v1/source.cpp | |
parent | f73bc5d691a9919f911d7236692c067ef127e9e2 (diff) | |
parent | 605a8a3075d2116bf0c742d7ae889ba14b801a8e (diff) | |
download | ydb-c46f4db13aad94d84f1930f145dc0d4cf79cbf43.tar.gz |
Merge branch 'rightlib' into merge-libs-250419-0050
Diffstat (limited to 'yql/essentials/sql/v1/source.cpp')
-rw-r--r-- | yql/essentials/sql/v1/source.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/yql/essentials/sql/v1/source.cpp b/yql/essentials/sql/v1/source.cpp index 28afe17d9c3..1b639dbc5d9 100644 --- a/yql/essentials/sql/v1/source.cpp +++ b/yql/essentials/sql/v1/source.cpp @@ -488,12 +488,15 @@ TNodePtr ISource::BuildFlattenColumns(const TString& label) { namespace { -TNodePtr BuildLambdaBodyForExprAliases(TPosition pos, const TVector<TNodePtr>& exprs) { +TNodePtr BuildLambdaBodyForExprAliases(TPosition pos, const TVector<TNodePtr>& exprs, bool override) { auto structObj = BuildAtom(pos, "row", TNodeFlags::Default); for (const auto& exprNode: exprs) { const auto name = exprNode->GetLabel(); YQL_ENSURE(name); - structObj = structObj->Y("ForceRemoveMember", structObj, structObj->Q(name)); + if (override) { + structObj = structObj->Y("ForceRemoveMember", structObj, structObj->Q(name)); + } + if (dynamic_cast<const TSessionWindow*>(exprNode.Get())) { continue; } @@ -515,12 +518,12 @@ TNodePtr ISource::BuildPreaggregatedMap(TContext& ctx) { TNodePtr res; if (groupByExprs) { - auto body = BuildLambdaBodyForExprAliases(Pos, groupByExprs); + auto body = BuildLambdaBodyForExprAliases(Pos, groupByExprs, ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride); res = Y("FlatMap", "core", BuildLambda(Pos, Y("row"), body)); } if (distinctAggrExprs) { - auto body = BuildLambdaBodyForExprAliases(Pos, distinctAggrExprs); + auto body = BuildLambdaBodyForExprAliases(Pos, distinctAggrExprs, ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride); auto lambda = BuildLambda(Pos, Y("row"), body); res = res ? Y("FlatMap", res, lambda) : Y("FlatMap", "core", lambda); } @@ -530,7 +533,7 @@ TNodePtr ISource::BuildPreaggregatedMap(TContext& ctx) { TNodePtr ISource::BuildPreFlattenMap(TContext& ctx) { Y_UNUSED(ctx); YQL_ENSURE(IsFlattenByExprs()); - return BuildLambdaBodyForExprAliases(Pos, Expressions(EExprSeat::FlattenByExpr)); + return BuildLambdaBodyForExprAliases(Pos, Expressions(EExprSeat::FlattenByExpr), true); } TNodePtr ISource::BuildPrewindowMap(TContext& ctx) { |