diff options
author | nsofya <nsofya@yandex-team.com> | 2023-06-06 17:16:00 +0300 |
---|---|---|
committer | nsofya <nsofya@yandex-team.com> | 2023-06-06 17:16:00 +0300 |
commit | 7a5a8df74899e9512edd404d83d4ab73ce2de7d8 (patch) | |
tree | 2a467a758c48b5006cb2421ec8f42e257138f99c | |
parent | aaf2fa744b04b66d31e076c217c37acc036806a2 (diff) | |
download | ydb-7a5a8df74899e9512edd404d83d4ab73ce2de7d8.tar.gz |
Add string kernels
Add string kernels
3 files changed, 38 insertions, 2 deletions
diff --git a/ydb/library/yql/core/arrow_kernels/registry/ut/registry_ut.cpp b/ydb/library/yql/core/arrow_kernels/registry/ut/registry_ut.cpp index d3cf78a273f..6d31cb4e2ac 100644 --- a/ydb/library/yql/core/arrow_kernels/registry/ut/registry_ut.cpp +++ b/ydb/library/yql/core/arrow_kernels/registry/ut/registry_ut.cpp @@ -83,6 +83,30 @@ Y_UNIT_TEST_SUITE(TKernelRegistryTest) { }); } + Y_UNIT_TEST(TestStartsWith) { + TestOne([](auto& b,auto& ctx) { + auto blockStringType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::String)); + auto blockOptBoolType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TOptionalExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::Bool))); + return b.AddBinaryOp(TKernelRequestBuilder::EBinaryOp::StartsWith, blockStringType, blockStringType, blockOptBoolType); + }); + } + + Y_UNIT_TEST(TestEndsWith) { + TestOne([](auto& b,auto& ctx) { + auto blockStringType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::String)); + auto blockOptBoolType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TOptionalExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::Bool))); + return b.AddBinaryOp(TKernelRequestBuilder::EBinaryOp::EndsWith, blockStringType, blockStringType, blockOptBoolType); + }); + } + + Y_UNIT_TEST(TestStringContains) { + TestOne([](auto& b,auto& ctx) { + auto blockStringType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::String)); + auto blockOptBoolType = ctx.template MakeType<TBlockExprType>(ctx.template MakeType<TOptionalExprType>(ctx.template MakeType<TDataExprType>(EDataSlot::Bool))); + return b.AddBinaryOp(TKernelRequestBuilder::EBinaryOp::StringContains, blockStringType, blockStringType, blockOptBoolType); + }); + } + Y_UNIT_TEST(TestUdf) { TestOne([](auto& b,auto& ctx) { auto blockOptStringType = ctx.template MakeType<TBlockExprType>( diff --git a/ydb/library/yql/core/arrow_kernels/request/request.cpp b/ydb/library/yql/core/arrow_kernels/request/request.cpp index a8f5acc538f..444534a35ee 100644 --- a/ydb/library/yql/core/arrow_kernels/request/request.cpp +++ b/ydb/library/yql/core/arrow_kernels/request/request.cpp @@ -49,6 +49,15 @@ ui32 TKernelRequestBuilder::AddBinaryOp(EBinaryOp op, const TTypeAnnotationNode* case EBinaryOp::Div: Items_.emplace_back(Pb_.BlockFunc("Div", returnType, { arg1, arg2 })); break; + case EBinaryOp::StartsWith: + Items_.emplace_back(Pb_.BlockFunc("StartsWith", returnType, { arg1, arg2 })); + break; + case EBinaryOp::EndsWith: + Items_.emplace_back(Pb_.BlockFunc("EndsWith", returnType, { arg1, arg2 })); + break; + case EBinaryOp::StringContains: + Items_.emplace_back(Pb_.BlockFunc("StringContains", returnType, { arg1, arg2 })); + break; } return Items_.size() - 1; diff --git a/ydb/library/yql/core/arrow_kernels/request/request.h b/ydb/library/yql/core/arrow_kernels/request/request.h index 20c0e9babe3..379684f7c3e 100644 --- a/ydb/library/yql/core/arrow_kernels/request/request.h +++ b/ydb/library/yql/core/arrow_kernels/request/request.h @@ -16,7 +16,10 @@ public: Add, Sub, Mul, - Div + Div, + StartsWith, + EndsWith, + StringContains }; TKernelRequestBuilder(const NKikimr::NMiniKQL::IFunctionRegistry& functionRegistry); @@ -40,4 +43,4 @@ private: }; -}
\ No newline at end of file +} |