Skip to content

Commit 06bbbc3

Browse files
authored
Merge 7b5da83 into ae6ef0c
2 parents ae6ef0c + 7b5da83 commit 06bbbc3

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

ydb/core/formats/arrow/ssa_runtime_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace NKikimr::NSsa {
1919

2020
// Bump this version every time incompatible runtime functions are introduced.
2121
#ifndef SSA_RUNTIME_VERSION
22-
#define SSA_RUNTIME_VERSION 4U
22+
#define SSA_RUNTIME_VERSION 3U
2323
#endif
2424

2525
// History:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ std::vector<std::pair<TExprBase, TExprBase>> ExtractComparisonParameters(const T
140140

141141
TMaybeNode<TExprBase> ComparisonPushdown(const std::vector<std::pair<TExprBase, TExprBase>>& parameters, const TCoCompare& predicate, TExprContext& ctx, TPositionHandle pos);
142142

143+
[[maybe_unused]]
143144
TMaybeNode<TExprBase> YqlCoalescePushdown(const TCoCoalesce& coalesce, TExprContext& ctx) {
144145
if (const auto params = ExtractBinaryFunctionParameters(coalesce, ctx, coalesce.Pos())) {
145146
return Build<TKqpOlapFilterBinaryOp>(ctx, coalesce.Pos())

ydb/core/kqp/query_compiler/kqp_olap_compiler.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ ui64 CompileSimpleArrowComparison(const TKqpOlapFilterBinaryOp& comparison, TKqp
489489
function = TProgram::TAssignment::FUNC_CMP_GREATER;
490490
} else if (comparison.Operator() == "gte") {
491491
function = TProgram::TAssignment::FUNC_CMP_GREATER_EQUAL;
492+
} else if (comparison.Operator() == "string_contains") {
493+
function = TProgram::TAssignment::FUNC_STR_MATCH;
494+
} else if (comparison.Operator() == "starts_with") {
495+
function = TProgram::TAssignment::FUNC_STR_STARTS_WITH;
496+
} else if (comparison.Operator() == "ends_with") {
497+
function = TProgram::TAssignment::FUNC_STR_ENDS_WITH;
492498
}
493499

494500
cmpFunc->SetId(function);
@@ -620,6 +626,7 @@ TTypedColumn CompileYqlKernelUnaryOperation(const TKqpOlapFilterUnaryOp& operati
620626
return {command->GetColumn().GetId(), resultType};
621627
}
622628

629+
[[maybe_unused]]
623630
TTypedColumn CompileYqlKernelBinaryOperation(const TKqpOlapFilterBinaryOp& operation, TKqpOlapCompileContext& ctx)
624631
{
625632
// Columns should be created before operation, otherwise operation fail to find columns
@@ -708,7 +715,6 @@ const TTypedColumn BuildLogicalProgram(const TExprNode::TChildrenType& args, con
708715
logicalFunc->SetFunctionType(TProgram::YQL_KERNEL);
709716
logicalFunc->SetYqlOperationId((ui32)function);
710717
} else {
711-
logicalFunc->SetFunctionType(function);
712718
logicalFunc->SetId((ui32)function);
713719
}
714720

@@ -740,22 +746,38 @@ const TTypedColumn BuildLogicalNot(const TExprBase& arg, TKqpOlapCompileContext&
740746

741747
TTypedColumn GetOrCreateColumnIdAndType(const TExprBase& node, TKqpOlapCompileContext& ctx) {
742748
if (const auto& maybeBinaryOp = node.Maybe<TKqpOlapFilterBinaryOp>()) {
743-
if (const auto& binaryOp = maybeBinaryOp.Cast(); ctx.CheckYqlCompatibleArgsTypes(binaryOp)) {
744-
return CompileYqlKernelBinaryOperation(binaryOp, ctx);
749+
if constexpr (NSsa::RuntimeVersion >= 4U) {
750+
if (const auto& binaryOp = maybeBinaryOp.Cast(); ctx.CheckYqlCompatibleArgsTypes(binaryOp)) {
751+
return CompileYqlKernelBinaryOperation(binaryOp, ctx);
752+
} else {
753+
return {
754+
ConvertSafeCastToColumn(CompileSimpleArrowComparison(binaryOp, ctx), "Uint8", ctx),
755+
ctx.ExprCtx().MakeType<TBlockExprType>(ctx.ExprCtx().MakeType<TDataExprType>(EDataSlot::Bool))
756+
};
757+
}
745758
} else {
746759
return {
747-
ConvertSafeCastToColumn(CompileSimpleArrowComparison(binaryOp, ctx), "Uint8", ctx),
748-
ctx.ExprCtx().MakeType<TBlockExprType>(ctx.ExprCtx().MakeType<TDataExprType>(EDataSlot::Uint8))
760+
CompileSimpleArrowComparison(maybeBinaryOp.Cast(), ctx),
761+
ctx.ExprCtx().MakeType<TBlockExprType>(ctx.ExprCtx().MakeType<TDataExprType>(EDataSlot::Bool))
749762
};
750763
}
751764
} else if (const auto& maybeUnaryOp = node.Maybe<TKqpOlapFilterUnaryOp>()) {
752765
return CompileYqlKernelUnaryOperation(maybeUnaryOp.Cast(), ctx);
753766
} else if (const auto& maybeAnd = node.Maybe<TKqpOlapAnd>()) {
754-
return BuildLogicalProgram(maybeAnd.Ref().Children(), TKernelRequestBuilder::EBinaryOp::And, ctx);
767+
if constexpr (NSsa::RuntimeVersion >= 4U)
768+
return BuildLogicalProgram(maybeAnd.Ref().Children(), TKernelRequestBuilder::EBinaryOp::And, ctx);
769+
else
770+
return BuildLogicalProgram(maybeAnd.Ref().Children(), TProgram::TAssignment::FUNC_BINARY_AND, ctx);
755771
} else if (const auto& maybeOr = node.Maybe<TKqpOlapOr>()) {
756-
return BuildLogicalProgram(maybeOr.Ref().Children(), TKernelRequestBuilder::EBinaryOp::Or, ctx);
772+
if constexpr (NSsa::RuntimeVersion >= 4U)
773+
return BuildLogicalProgram(maybeOr.Ref().Children(), TKernelRequestBuilder::EBinaryOp::Or, ctx);
774+
else
775+
return BuildLogicalProgram(maybeOr.Ref().Children(), TProgram::TAssignment::FUNC_BINARY_OR, ctx);
757776
} else if (const auto& maybeXor = node.Maybe<TKqpOlapXor>()) {
758-
return BuildLogicalProgram(maybeXor.Ref().Children(), TKernelRequestBuilder::EBinaryOp::Xor, ctx);
777+
if constexpr (NSsa::RuntimeVersion >= 4U)
778+
return BuildLogicalProgram(maybeXor.Ref().Children(), TKernelRequestBuilder::EBinaryOp::Xor, ctx);
779+
else
780+
return BuildLogicalProgram(maybeXor.Ref().Children(), TProgram::TAssignment::FUNC_BINARY_XOR, ctx);
759781
} else if (const auto& maybeNot = node.Maybe<TKqpOlapNot>()) {
760782
return BuildLogicalNot(maybeNot.Cast().Value(), ctx);
761783
} else if (const auto& maybeJsonValue = node.Maybe<TKqpOlapJsonValue>()) {

ydb/core/kqp/ut/olap/kqp_olap_ut.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,11 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
17091709
scanSettings.Explain(true);
17101710

17111711
TLocalHelper(kikimr).CreateTestOlapTable();
1712+
#if SSA_RUNTIME_VERSION >= 4U
17121713
WriteTestData(kikimr, "/Root/olapStore/olapTable", 10000, 3000000, 5, true);
1714+
#else
1715+
WriteTestData(kikimr, "/Root/olapStore/olapTable", 10000, 3000000, 5, false);
1716+
#endif
17131717
Tests::NCommon::TLoggerInit(kikimr).Initialize();
17141718

17151719
auto tableClient = kikimr.GetTableClient();

ydb/core/kqp/ut/query/kqp_explain_ut.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,11 @@ Y_UNIT_TEST_SUITE(KqpExplain) {
855855
NJson::ReadJsonTree(*streamRes.PlanJson, &plan, true);
856856
UNIT_ASSERT(ValidatePlanNodeIds(plan));
857857

858+
#if SSA_RUNTIME_VERSION >= 4U
858859
auto readNode = FindPlanNodeByKv(plan, "Node Type", "TableFullScan");
860+
#else
861+
auto readNode = FindPlanNodeByKv(plan, "Node Type", "Filter-TableFullScan");
862+
#endif
859863
UNIT_ASSERT(readNode.IsDefined());
860864

861865
auto& operators = readNode.GetMapSafe().at("Operators").GetArraySafe();

0 commit comments

Comments
 (0)