diff options
author | ssmike <ssmike@ydb.tech> | 2023-01-24 14:52:11 +0300 |
---|---|---|
committer | ssmike <ssmike@ydb.tech> | 2023-01-24 14:52:11 +0300 |
commit | 13a0145566fbf90b2520d77925dfec024089c0ef (patch) | |
tree | 455788f7d90313e091cdbdfe8cbbde3533df2077 | |
parent | 05589f01efdc402ba5c36ec05da309b9d786e723 (diff) | |
download | ydb-13a0145566fbf90b2520d77925dfec024089c0ef.tar.gz |
Fix ut with enabled dqsource
-rw-r--r-- | ydb/core/kqp/opt/kqp_opt.cpp | 6 | ||||
-rw-r--r-- | ydb/core/kqp/opt/physical/kqp_opt_phy_build_stage.cpp | 8 | ||||
-rw-r--r-- | ydb/core/kqp/opt/physical/kqp_opt_phy_limit.cpp | 15 | ||||
-rw-r--r-- | ydb/core/kqp/runtime/kqp_read_actor.cpp | 24 |
4 files changed, 36 insertions, 17 deletions
diff --git a/ydb/core/kqp/opt/kqp_opt.cpp b/ydb/core/kqp/opt/kqp_opt.cpp index 519fc65e93a..8bea802beb0 100644 --- a/ydb/core/kqp/opt/kqp_opt.cpp +++ b/ydb/core/kqp/opt/kqp_opt.cpp @@ -68,6 +68,12 @@ bool IsKqpPureInputs(const TExprList& inputs) { return true; } + if (auto source = TExprBase(node).Maybe<TDqSource>()) { + if (source.Cast().Settings().Maybe<TKqpReadRangesSourceSettings>()) { + return true; + } + } + return false; }); } diff --git a/ydb/core/kqp/opt/physical/kqp_opt_phy_build_stage.cpp b/ydb/core/kqp/opt/physical/kqp_opt_phy_build_stage.cpp index 918a2600bf6..c463db658ac 100644 --- a/ydb/core/kqp/opt/physical/kqp_opt_phy_build_stage.cpp +++ b/ydb/core/kqp/opt/physical/kqp_opt_phy_build_stage.cpp @@ -63,7 +63,9 @@ TExprBase KqpBuildReadTableStage(TExprBase node, TExprContext& ctx, const TKqpOp bool useSource = kqpCtx.Config->EnableKqpScanQuerySourceRead && kqpCtx.IsScanQuery(); useSource = useSource || (kqpCtx.Config->EnableKqpDataQuerySourceRead && kqpCtx.IsDataQuery()); - useSource = useSource && tableDesc.Metadata->Kind != EKikimrTableKind::SysView; + useSource = useSource && + tableDesc.Metadata->Kind != EKikimrTableKind::SysView && + tableDesc.Metadata->Kind != EKikimrTableKind::Olap; TVector<TExprBase> values; TNodeOnNodeOwnedMap replaceMap; @@ -228,7 +230,9 @@ TExprBase KqpBuildReadTableRangesStage(TExprBase node, TExprContext& ctx, bool useSource = kqpCtx.Config->EnableKqpScanQuerySourceRead && kqpCtx.IsScanQuery(); useSource = useSource || (kqpCtx.Config->EnableKqpDataQuerySourceRead && kqpCtx.IsDataQuery()); - useSource = useSource && tableDesc.Metadata->Kind != EKikimrTableKind::SysView; + useSource = useSource && + tableDesc.Metadata->Kind != EKikimrTableKind::SysView && + tableDesc.Metadata->Kind != EKikimrTableKind::Olap; bool fullScan = TCoVoid::Match(ranges.Raw()); diff --git a/ydb/core/kqp/opt/physical/kqp_opt_phy_limit.cpp b/ydb/core/kqp/opt/physical/kqp_opt_phy_limit.cpp index 27c523117d2..f7b22dbb311 100644 --- a/ydb/core/kqp/opt/physical/kqp_opt_phy_limit.cpp +++ b/ydb/core/kqp/opt/physical/kqp_opt_phy_limit.cpp @@ -104,11 +104,18 @@ TExprBase KqpApplyLimitToReadTableSource(TExprBase node, TExprContext& ctx, cons .Input(limitValue.Cast()) .Done().Ptr()); } - replaces[readRangesSource.Settings().Raw()] = settings.BuildNode(ctx, source.Pos()).Ptr(); - + auto newSettings = Build<TKqpReadRangesSourceSettings>(ctx, source.Pos()) + .Table(readRangesSource.Table()) + .Columns(readRangesSource.Columns()) + .Settings(settings.BuildNode(ctx, source.Pos())) + .RangesExpr(readRangesSource.RangesExpr()) + .ExplainPrompt(readRangesSource.ExplainPrompt()) + .Done(); + replaces[readRangesSource.Raw()] = newSettings.Ptr(); + return TExprBase(ctx.ReplaceNodes(node.Ptr(), replaces)); -} - +} + TExprBase KqpApplyLimitToReadTable(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx) { if (!node.Maybe<TCoTake>()) { diff --git a/ydb/core/kqp/runtime/kqp_read_actor.cpp b/ydb/core/kqp/runtime/kqp_read_actor.cpp index 50aa6536b30..b52521af4db 100644 --- a/ydb/core/kqp/runtime/kqp_read_actor.cpp +++ b/ydb/core/kqp/runtime/kqp_read_actor.cpp @@ -97,35 +97,37 @@ public: // Absent cells mean infinity. So in prefix notation `From` should be exclusive. // For example x >= (Key1, Key2, +infinity) is equivalent to x > (Key1, Key2) where x is arbitrary tuple - if (range.From.GetCells().size() < keyColumns) { - fromInclusive = false; + if (from.size() < keyColumns) { noop = range.FromInclusive; - } else if (range.FromInclusive) { + fromInclusive = false; + } else if (fromInclusive) { // Nulls are minimum values so we should remove null padding. // x >= (Key1, Key2, null) is equivalent to x >= (Key1, Key2) - ssize_t i = range.From.GetCells().size(); - while (i > 0 && range.From.GetCells()[i - 1].IsNull()) { + ssize_t i = from.size(); + while (i > 0 && from[i - 1].IsNull()) { --i; noop = false; } - from = range.From.GetCells().subspan(0, i); + from = from.subspan(0, i); } // Absent cells mean infinity. So in prefix notation `To` should be inclusive. // For example x < (Key1, Key2, +infinity) is equivalent to x <= (Key1, Key2) where x is arbitrary tuple - if (range.To.GetCells().size() < keyColumns) { + if (to.size() < keyColumns) { toInclusive = true; + noop = noop && range.ToInclusive; + } else if (!range.ToInclusive) { // Nulls are minimum values so we should remove null padding. // For example x < (Key1, Key2, null) is equivalent to x < (Key1, Key2) - ssize_t i = range.To.GetCells().size(); - while (i > 0 && range.To.GetCells()[i - 1].IsNull()) { + ssize_t i = to.size(); + while (i > 0 && to[i - 1].IsNull()) { --i; noop = false; } - to = range.To.GetCells().subspan(0, i); + to = to.subspan(0, i); } - if (!noop) { + if (noop) { return; } |