diff --git a/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_returning.cpp b/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_returning.cpp index d4e97c698697..4ae0aaf7e3b4 100644 --- a/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_returning.cpp +++ b/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_returning.cpp @@ -204,7 +204,7 @@ TExprBase KqpRewriteReturningUpsert(TExprBase node, TExprContext& ctx, const TKq return node; } - if (!upsert.Input().Maybe() && !upsert.Input().Maybe()) { + if (upsert.Input().Maybe() || upsert.Input().Maybe()) { return node; } @@ -226,7 +226,7 @@ TExprBase KqpRewriteReturningDelete(TExprBase node, TExprContext& ctx, const TKq return node; } - if (!del.Input().Maybe() && !del.Input().Maybe()) { + if (del.Input().Maybe() || del.Input().Maybe()) { return node; } diff --git a/ydb/library/yql/dq/opt/dq_opt_phy.cpp b/ydb/library/yql/dq/opt/dq_opt_phy.cpp index edbe09496514..188b468e4727 100644 --- a/ydb/library/yql/dq/opt/dq_opt_phy.cpp +++ b/ydb/library/yql/dq/opt/dq_opt_phy.cpp @@ -2744,6 +2744,16 @@ TExprBase DqPropagatePrecomuteTake(TExprBase node, TExprContext& ctx, IOptimizat return node; } + auto* typeAnn = precompute.Connection().Raw()->GetTypeAnn(); + + YQL_ENSURE(typeAnn); + typeAnn = GetSeqItemType(typeAnn); + + const TTypeAnnotationNode* itemType; + if (!EnsureNewSeqType(precompute.Connection().Pos(), *typeAnn, ctx, &itemType)) { + return node; + } + auto takeLambda = Build(ctx, node.Pos()) .Args({"list_stream"}) .Body()