summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Khalikov <[email protected]>2025-07-28 15:11:20 +0300
committerGitHub <[email protected]>2025-07-28 12:11:20 +0000
commitf432f4c16390ced06b500289a24b66d68301605f (patch)
tree99ebb28f2490fc7beb66a4bf62a5e1ea0a5b37b2
parent5183c237ccdf995146da1705bebf034a64b1d21f (diff)
Do not create a block kernel for binary op with same column (#19087)
-rw-r--r--ydb/core/kqp/opt/physical/predicate_collector.cpp18
-rw-r--r--ydb/core/kqp/ut/olap/kqp_olap_ut.cpp2
2 files changed, 20 insertions, 0 deletions
diff --git a/ydb/core/kqp/opt/physical/predicate_collector.cpp b/ydb/core/kqp/opt/physical/predicate_collector.cpp
index 343fb59a8c8..2fa75a8eca7 100644
--- a/ydb/core/kqp/opt/physical/predicate_collector.cpp
+++ b/ydb/core/kqp/opt/physical/predicate_collector.cpp
@@ -22,6 +22,15 @@ bool IsSupportedPredicate(const TCoCompare& predicate) {
return !predicate.Ref().Content().starts_with("Aggr");
}
+bool CheckSameColumn(const TExprBase &left, const TExprBase &right) {
+ if (auto leftMember = left.Maybe<TCoMember>()) {
+ if (auto rightMember = right.Maybe<TCoMember>()) {
+ return (leftMember.Cast().Name() == rightMember.Cast().Name());
+ }
+ }
+ return false;
+}
+
bool IsSupportedDataType(const TCoDataCtor& node, bool allowOlapApply) {
Y_UNUSED(allowOlapApply);
if (node.Maybe<TCoBool>() || node.Maybe<TCoFloat>() || node.Maybe<TCoDouble>() || node.Maybe<TCoInt8>() || node.Maybe<TCoInt16>() ||
@@ -196,6 +205,11 @@ bool CheckExpressionNodeForPushdown(const TExprBase& node, const TExprNode* lamb
if (const auto op = node.Maybe<TCoUnaryArithmetic>()) {
return CheckExpressionNodeForPushdown(op.Cast().Arg(), lambdaArg, options) && IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn(), options.AllowOlapApply);
} else if (const auto op = node.Maybe<TCoBinaryArithmetic>()) {
+ // FIXME: CS should be able to handle bin arithmetic op with the same column.
+ if (!options.AllowOlapApply && CheckSameColumn(op.Cast().Left(), op.Cast().Right())) {
+ return false;
+ }
+
return CheckExpressionNodeForPushdown(op.Cast().Left(), lambdaArg, options) && CheckExpressionNodeForPushdown(op.Cast().Right(), lambdaArg, options)
&& IsGoodTypeForArithmeticPushdown(*op.Cast().Ref().GetTypeAnn(), options.AllowOlapApply) && !op.Cast().Maybe<TCoAggrAdd>();
}
@@ -273,6 +287,10 @@ bool CheckComparisonParametersForPushdown(const TCoCompare& compare, const TExpr
// We do not know how process input that is not a sequence of elements
return false;
}
+ // FIXME: CS should be able to handle bin cmp op with the same column.
+ if (!options.AllowOlapApply && CheckSameColumn(compare.Left(), compare.Right())) {
+ return false;
+ }
if (!IsGoodTypesForPushdownCompare(*compare.Left().Ref().GetTypeAnn(), *compare.Right().Ref().GetTypeAnn(), options)) {
return false;
diff --git a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
index 85ccd42c258..0ae7eacd27c 100644
--- a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
+++ b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
@@ -1165,6 +1165,8 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
R"(`level` >= Int32("4"))",
R"(`level` <= Int32("0"))",
R"(`level` != Int32("0"))",
+ R"(`level` + `level` <= Int32("0"))",
+ R"(`level` <= `level`)",
R"((`level`, `uid`, `resource_id`) = (Int32("1"), "uid_3000001", "10001"))",
R"((`level`, `uid`, `resource_id`) > (Int32("1"), "uid_3000001", "10001"))",
R"((`level`, `uid`, `resource_id`) > (Int32("1"), "uid_3000000", "10001"))",