Skip to content

Do not create a block kernel for binary op with same column #19087

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions ydb/core/kqp/opt/physical/predicate_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if (node.Maybe<TCoBool>() ||
node.Maybe<TCoFloat>() ||
Expand Down Expand Up @@ -217,6 +226,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>();
}
Expand Down Expand Up @@ -290,6 +304,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;
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,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"))",
Expand Down
Loading