Skip to content

Stop supporting SSA_RUNTIME_VERSION less than 4 #15101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ydb/core/formats/arrow/ssa_runtime_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace NKikimr::NSsa {
// v2 is the version supported by kikimr-23-1. Supports LIKE filter for Utf8 type, COUNT(col), COUNT(*), SUM(), MIN(), MAX(), AVG(), SOME() aggregations.
// v3 is the version supported by kikimr-23-3. Supports LIKE filter for String type, JSON_VALUE and JSON_EXISTS functions in filters
// v4 is the version supported by kikimr-24-1. Supports any comparsions and arithmetics on YQL kernels.
// v5 supports generic ast pushdouwn via KqpOlapApply
constexpr ui32 RuntimeVersion = SSA_RUNTIME_VERSION;

static_assert(RuntimeVersion >= 4);

}
15 changes: 0 additions & 15 deletions ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ TExprBase KqpPushDownOlapGroupByKeysImpl(TExprBase node, TExprContext& ctx, bool
}

TExprBase KqpPushDownOlapGroupByKeys(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx) {
if (NKikimr::NSsa::RuntimeVersion < 2U) {
// We introduced aggregate pushdown in v2 of SSA program
return node;
}

if (!kqpCtx.Config->HasOptEnableOlapPushdown() || !kqpCtx.Config->HasOptEnableOlapProvideComputeSharding()) {
return node;
}
Expand All @@ -271,11 +266,6 @@ TExprBase KqpPushDownOlapGroupByKeys(TExprBase node, TExprContext& ctx, const TK

TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx)
{
if (NKikimr::NSsa::RuntimeVersion < 2U) {
// We introduced aggregate pushdown in v2 of SSA program
return node;
}

if (!kqpCtx.Config->HasOptEnableOlapPushdown()) {
return node;
}
Expand Down Expand Up @@ -373,11 +363,6 @@ TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOpti

TExprBase KqpPushOlapLength(TExprBase node, TExprContext& ctx, const TKqpOptimizeContext& kqpCtx)
{
if (NKikimr::NSsa::RuntimeVersion < 2U) {
// We introduced aggregate pushdown in v2 of SSA program
return node;
}

if (!kqpCtx.Config->HasOptEnableOlapPushdown()) {
return node;
}
Expand Down
70 changes: 29 additions & 41 deletions ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,31 @@ std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExp
return YqlIfPushdown(maybeIf.Cast(), argument, ctx);
}

if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
if (const auto maybeArithmetic = node.Maybe<TCoBinaryArithmetic>()) {
const auto arithmetic = maybeArithmetic.Cast();
if (const auto params = ExtractBinaryFunctionParameters(arithmetic, argument, ctx, pos)) {
return Build<TKqpOlapFilterBinaryOp>(ctx, pos)
.Operator().Value(arithmetic.Ref().Content(), TNodeFlags::Default).Build()
.Left(params->first)
.Right(params->second)
.Done();
}
if (const auto maybeArithmetic = node.Maybe<TCoBinaryArithmetic>()) {
const auto arithmetic = maybeArithmetic.Cast();
if (const auto params = ExtractBinaryFunctionParameters(arithmetic, argument, ctx, pos)) {
return Build<TKqpOlapFilterBinaryOp>(ctx, pos)
.Operator().Value(arithmetic.Ref().Content(), TNodeFlags::Default).Build()
.Left(params->first)
.Right(params->second)
.Done();
}
}

if (const auto maybeArithmetic = node.Maybe<TCoUnaryArithmetic>()) {
const auto arithmetic = maybeArithmetic.Cast();
if (const auto params = ConvertComparisonNode(arithmetic.Arg(), argument, ctx, pos); 1U == params.size()) {
TString oper(arithmetic.Ref().Content());
YQL_ENSURE(oper.to_lower());
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
.Operator().Value(oper, TNodeFlags::Default).Build()
.Arg(params.front())
.Done();
}
if (const auto maybeArithmetic = node.Maybe<TCoUnaryArithmetic>()) {
const auto arithmetic = maybeArithmetic.Cast();
if (const auto params = ConvertComparisonNode(arithmetic.Arg(), argument, ctx, pos); 1U == params.size()) {
TString oper(arithmetic.Ref().Content());
YQL_ENSURE(oper.to_lower());
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
.Operator().Value(oper, TNodeFlags::Default).Build()
.Arg(params.front())
.Done();
}
}

if (const auto maybeCoalesce = node.Maybe<TCoCoalesce>()) {
return YqlCoalescePushdown(maybeCoalesce.Cast(), argument, ctx);
}
if (const auto maybeCoalesce = node.Maybe<TCoCoalesce>()) {
return YqlCoalescePushdown(maybeCoalesce.Cast(), argument, ctx);
}

if (const auto maybeCompare = node.Maybe<TCoCompare>()) {
Expand Down Expand Up @@ -375,7 +373,7 @@ TExprBase BuildOneElementComparison(const std::pair<TExprBase, TExprBase>& param
compareOperator = "gt";
} else if (predicate.Maybe<TCoCmpGreaterOrEqual>() && !forceStrictComparison) {
compareOperator = "gte";
} else if constexpr (NKikimr::NSsa::RuntimeVersion >= 2U) {
} else {
// We introduced LIKE pushdown in v2 of SSA program
if (predicate.Maybe<TCoCmpStringContains>()) {
compareOperator = "string_contains";
Expand Down Expand Up @@ -511,16 +509,10 @@ template<bool Empty>
TMaybeNode<TExprBase> ExistsPushdown(const TCoExists& exists, TExprContext& ctx, TPositionHandle pos)
{
const auto columnName = exists.Optional().Cast<TCoMember>().Name();
if constexpr (NSsa::RuntimeVersion >= 4U) {
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
.Operator().Value(Empty ? "empty" : "exists", TNodeFlags::Default).Build()
.Arg(columnName)
.Done();
} else {
return Build<TKqpOlapFilterExists>(ctx, pos)
.Column(columnName)
return Build<TKqpOlapFilterUnaryOp>(ctx, pos)
.Operator().Value(Empty ? "empty" : "exists", TNodeFlags::Default).Build()
.Arg(columnName)
.Done();
}
}

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

TMaybeNode<TExprBase> CoalescePushdown(const TCoCoalesce& coalesce, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos)
{
if constexpr (NSsa::RuntimeVersion >= 4U) {
if (const auto node = YqlCoalescePushdown(coalesce, argument, ctx)) {
return node;
}
if (const auto node = YqlCoalescePushdown(coalesce, argument, ctx)) {
return node;
}

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

if (const auto maybeNot = predicate.Maybe<TCoNot>()) {
const auto notNode = maybeNot.Cast();
if constexpr (NSsa::RuntimeVersion >= 4U) {
if (const auto maybeExists = notNode.Value().Maybe<TCoExists>()) {
return TFilterOpsLevels(ExistsPushdown<true>(maybeExists.Cast(), ctx, pos));
}
if (const auto maybeExists = notNode.Value().Maybe<TCoExists>()) {
return TFilterOpsLevels(ExistsPushdown<true>(maybeExists.Cast(), ctx, pos));
}
auto pushedFilters = PredicatePushdown(notNode.Value(), argument, ctx, pos);
pushedFilters.WrapToNotOp(ctx, pos);
Expand Down
18 changes: 7 additions & 11 deletions ydb/core/kqp/opt/physical/predicate_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ bool IsSupportedDataType(const TCoDataCtor& node) {
return true;
}

if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
if (node.Maybe<TCoTimestamp>()) {
return true;
}
if (node.Maybe<TCoTimestamp>()) {
return true;
}

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

if constexpr (NKikimr::NSsa::RuntimeVersion >= 4U) {
if (const auto op = node.Maybe<TCoUnaryArithmetic>()) {
return CheckExpressionNodeForPushdown(op.Cast().Arg(), lambdaArg) && IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn());
} else if (const auto op = node.Maybe<TCoBinaryArithmetic>()) {
return CheckExpressionNodeForPushdown(op.Cast().Left(), lambdaArg) && CheckExpressionNodeForPushdown(op.Cast().Right(), lambdaArg)
&& IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn()) && !op.Cast().Maybe<TCoAggrAdd>();
}
if (const auto op = node.Maybe<TCoUnaryArithmetic>()) {
return CheckExpressionNodeForPushdown(op.Cast().Arg(), lambdaArg) && IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn());
} else if (const auto op = node.Maybe<TCoBinaryArithmetic>()) {
return CheckExpressionNodeForPushdown(op.Cast().Left(), lambdaArg) && CheckExpressionNodeForPushdown(op.Cast().Right(), lambdaArg)
&& IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn()) && !op.Cast().Maybe<TCoAggrAdd>();
}

if constexpr (NKikimr::NSsa::RuntimeVersion >= 5U) {
Expand Down
Loading
Loading