Skip to content

Commit 267d409

Browse files
authored
Stop supporting SSA_RUNTIME_VERSION less than 4 (#15101)
1 parent c5b2980 commit 267d409

File tree

7 files changed

+94
-351
lines changed

7 files changed

+94
-351
lines changed

ydb/core/formats/arrow/ssa_runtime_version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ namespace NKikimr::NSsa {
2727
// v2 is the version supported by kikimr-23-1. Supports LIKE filter for Utf8 type, COUNT(col), COUNT(*), SUM(), MIN(), MAX(), AVG(), SOME() aggregations.
2828
// v3 is the version supported by kikimr-23-3. Supports LIKE filter for String type, JSON_VALUE and JSON_EXISTS functions in filters
2929
// v4 is the version supported by kikimr-24-1. Supports any comparsions and arithmetics on YQL kernels.
30+
// v5 supports generic ast pushdouwn via KqpOlapApply
3031
constexpr ui32 RuntimeVersion = SSA_RUNTIME_VERSION;
3132

33+
static_assert(RuntimeVersion >= 4);
34+
3235
}

ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ TExprBase KqpPushDownOlapGroupByKeysImpl(TExprBase node, TExprContext& ctx, bool
245245
}
246246

247247
TExprBase KqpPushDownOlapGroupByKeys(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx) {
248-
if (NKikimr::NSsa::RuntimeVersion < 2U) {
249-
// We introduced aggregate pushdown in v2 of SSA program
250-
return node;
251-
}
252-
253248
if (!kqpCtx.Config->HasOptEnableOlapPushdown() || !kqpCtx.Config->HasOptEnableOlapProvideComputeSharding()) {
254249
return node;
255250
}
@@ -271,11 +266,6 @@ TExprBase KqpPushDownOlapGroupByKeys(TExprBase node, TExprContext& ctx, const TK
271266

272267
TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx)
273268
{
274-
if (NKikimr::NSsa::RuntimeVersion < 2U) {
275-
// We introduced aggregate pushdown in v2 of SSA program
276-
return node;
277-
}
278-
279269
if (!kqpCtx.Config->HasOptEnableOlapPushdown()) {
280270
return node;
281271
}
@@ -373,11 +363,6 @@ TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOpti
373363

374364
TExprBase KqpPushOlapLength(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx)
375365
{
376-
if (NKikimr::NSsa::RuntimeVersion < 2U) {
377-
// We introduced aggregate pushdown in v2 of SSA program
378-
return node;
379-
}
380-
381366
if (!kqpCtx.Config->HasOptEnableOlapPushdown()) {
382367
return node;
383368
}

ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -262,33 +262,31 @@ std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExp
262262
return YqlIfPushdown(maybeIf.Cast(), argument, ctx);
263263
}
264264

265-
if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
266-
if (const auto maybeArithmetic = node.Maybe<TCoBinaryArithmetic>()) {
267-
const auto arithmetic = maybeArithmetic.Cast();
268-
if (const auto params = ExtractBinaryFunctionParameters(arithmetic, argument, ctx, pos)) {
269-
return Build<TKqpOlapFilterBinaryOp>(ctx, pos)
270-
.Operator().Value(arithmetic.Ref().Content(), TNodeFlags::Default).Build()
271-
.Left(params->first)
272-
.Right(params->second)
273-
.Done();
274-
}
265+
if (const auto maybeArithmetic = node.Maybe<TCoBinaryArithmetic>()) {
266+
const auto arithmetic = maybeArithmetic.Cast();
267+
if (const auto params = ExtractBinaryFunctionParameters(arithmetic, argument, ctx, pos)) {
268+
return Build<TKqpOlapFilterBinaryOp>(ctx, pos)
269+
.Operator().Value(arithmetic.Ref().Content(), TNodeFlags::Default).Build()
270+
.Left(params->first)
271+
.Right(params->second)
272+
.Done();
275273
}
274+
}
276275

277-
if (const auto maybeArithmetic = node.Maybe<TCoUnaryArithmetic>()) {
278-
const auto arithmetic = maybeArithmetic.Cast();
279-
if (const auto params = ConvertComparisonNode(arithmetic.Arg(), argument, ctx, pos); 1U == params.size()) {
280-
TString oper(arithmetic.Ref().Content());
281-
YQL_ENSURE(oper.to_lower());
282-
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
283-
.Operator().Value(oper, TNodeFlags::Default).Build()
284-
.Arg(params.front())
285-
.Done();
286-
}
276+
if (const auto maybeArithmetic = node.Maybe<TCoUnaryArithmetic>()) {
277+
const auto arithmetic = maybeArithmetic.Cast();
278+
if (const auto params = ConvertComparisonNode(arithmetic.Arg(), argument, ctx, pos); 1U == params.size()) {
279+
TString oper(arithmetic.Ref().Content());
280+
YQL_ENSURE(oper.to_lower());
281+
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
282+
.Operator().Value(oper, TNodeFlags::Default).Build()
283+
.Arg(params.front())
284+
.Done();
287285
}
286+
}
288287

289-
if (const auto maybeCoalesce = node.Maybe<TCoCoalesce>()) {
290-
return YqlCoalescePushdown(maybeCoalesce.Cast(), argument, ctx);
291-
}
288+
if (const auto maybeCoalesce = node.Maybe<TCoCoalesce>()) {
289+
return YqlCoalescePushdown(maybeCoalesce.Cast(), argument, ctx);
292290
}
293291

294292
if (const auto maybeCompare = node.Maybe<TCoCompare>()) {
@@ -375,7 +373,7 @@ TExprBase BuildOneElementComparison(const std::pair<TExprBase, TExprBase>& param
375373
compareOperator = "gt";
376374
} else if (predicate.Maybe<TCoCmpGreaterOrEqual>() && !forceStrictComparison) {
377375
compareOperator = "gte";
378-
} else if constexpr (NKikimr::NSsa::RuntimeVersion >= 2U) {
376+
} else {
379377
// We introduced LIKE pushdown in v2 of SSA program
380378
if (predicate.Maybe<TCoCmpStringContains>()) {
381379
compareOperator = "string_contains";
@@ -511,16 +509,10 @@ template<bool Empty>
511509
TMaybeNode<TExprBase> ExistsPushdown(const TCoExists& exists, TExprContext& ctx, TPositionHandle pos)
512510
{
513511
const auto columnName = exists.Optional().Cast<TCoMember>().Name();
514-
if constexpr (NSsa::RuntimeVersion >= 4U) {
515-
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
516-
.Operator().Value(Empty ? "empty" : "exists", TNodeFlags::Default).Build()
517-
.Arg(columnName)
518-
.Done();
519-
} else {
520-
return Build<TKqpOlapFilterExists>(ctx, pos)
521-
.Column(columnName)
512+
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
513+
.Operator().Value(Empty ? "empty" : "exists", TNodeFlags::Default).Build()
514+
.Arg(columnName)
522515
.Done();
523-
}
524516
}
525517

526518
TMaybeNode<TExprBase> JsonExistsPushdown(const TCoJsonExists& jsonExists, TExprContext& ctx, TPositionHandle pos)
@@ -571,10 +563,8 @@ TMaybeNode<TExprBase> SafeCastPredicatePushdown(const TCoFlatMap& inputFlatmap,
571563

572564
TMaybeNode<TExprBase> CoalescePushdown(const TCoCoalesce& coalesce, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos)
573565
{
574-
if constexpr (NSsa::RuntimeVersion >= 4U) {
575-
if (const auto node = YqlCoalescePushdown(coalesce, argument, ctx)) {
576-
return node;
577-
}
566+
if (const auto node = YqlCoalescePushdown(coalesce, argument, ctx)) {
567+
return node;
578568
}
579569

580570
auto predicate = coalesce.Predicate();
@@ -617,10 +607,8 @@ TFilterOpsLevels PredicatePushdown(const TExprBase& predicate, const TExprNode&
617607

618608
if (const auto maybeNot = predicate.Maybe<TCoNot>()) {
619609
const auto notNode = maybeNot.Cast();
620-
if constexpr (NSsa::RuntimeVersion >= 4U) {
621-
if (const auto maybeExists = notNode.Value().Maybe<TCoExists>()) {
622-
return TFilterOpsLevels(ExistsPushdown<true>(maybeExists.Cast(), ctx, pos));
623-
}
610+
if (const auto maybeExists = notNode.Value().Maybe<TCoExists>()) {
611+
return TFilterOpsLevels(ExistsPushdown<true>(maybeExists.Cast(), ctx, pos));
624612
}
625613
auto pushedFilters = PredicatePushdown(notNode.Value(), argument, ctx, pos);
626614
pushedFilters.WrapToNotOp(ctx, pos);

ydb/core/kqp/opt/physical/predicate_collector.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ bool IsSupportedDataType(const TCoDataCtor& node) {
3232
return true;
3333
}
3434

35-
if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
36-
if (node.Maybe<TCoTimestamp>()) {
37-
return true;
38-
}
35+
if (node.Maybe<TCoTimestamp>()) {
36+
return true;
3937
}
4038

4139
if constexpr (NKikimr::NSsa::RuntimeVersion >= 5U) {
@@ -168,13 +166,11 @@ bool CheckExpressionNodeForPushdown(const TExprBase& node, const TExprNode* lamb
168166
return true;
169167
}
170168

171-
if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
172-
if (const auto op = node.Maybe<TCoUnaryArithmetic>()) {
173-
return CheckExpressionNodeForPushdown(op.Cast().Arg(), lambdaArg) && IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn());
174-
} else if (const auto op = node.Maybe<TCoBinaryArithmetic>()) {
175-
return CheckExpressionNodeForPushdown(op.Cast().Left(), lambdaArg) && CheckExpressionNodeForPushdown(op.Cast().Right(), lambdaArg)
176-
&& IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn()) && !op.Cast().Maybe<TCoAggrAdd>();
177-
}
169+
if (const auto op = node.Maybe<TCoUnaryArithmetic>()) {
170+
return CheckExpressionNodeForPushdown(op.Cast().Arg(), lambdaArg) && IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn());
171+
} else if (const auto op = node.Maybe<TCoBinaryArithmetic>()) {
172+
return CheckExpressionNodeForPushdown(op.Cast().Left(), lambdaArg) && CheckExpressionNodeForPushdown(op.Cast().Right(), lambdaArg)
173+
&& IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn()) && !op.Cast().Maybe<TCoAggrAdd>();
178174
}
179175

180176
if constexpr (NKikimr::NSsa::RuntimeVersion >= 5U) {

0 commit comments

Comments
 (0)