diff options
| author | imunkin <[email protected]> | 2025-05-06 17:16:22 +0300 |
|---|---|---|
| committer | imunkin <[email protected]> | 2025-05-06 17:33:10 +0300 |
| commit | 6ce738d44097d75b303066dd5ad549fe432794b1 (patch) | |
| tree | f62a0f32dee2fed417aed3d89a91e6fe7b728ccb /yql/essentials/udfs/common/string/string_udf.cpp | |
| parent | 56ff6f65502d7744348c5bc22d6a0cee3082d98a (diff) | |
YQL-19884: Add Ascii{Starts,Ends}WithIgnoreCase functions to String UDF
commit_hash:4b86982498876ec14632c0a018a940c3393bb5d6
Diffstat (limited to 'yql/essentials/udfs/common/string/string_udf.cpp')
| -rw-r--r-- | yql/essentials/udfs/common/string/string_udf.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/yql/essentials/udfs/common/string/string_udf.cpp b/yql/essentials/udfs/common/string/string_udf.cpp index 161c51c060b..feb95dced93 100644 --- a/yql/essentials/udfs/common/string/string_udf.cpp +++ b/yql/essentials/udfs/common/string/string_udf.cpp @@ -153,8 +153,25 @@ SIMPLE_STRICT_UDF_OPTIONS(TReverse, TOptional<char*>(TOptional<char*>), } \ } -#define STRING_TWO_ARGS_UDF(udfName, function) \ - BEGIN_SIMPLE_STRICT_ARROW_UDF(T##udfName, bool(TOptional<char*>, char*)) { \ +#define STRING_TWO_ARGS_UDF_DEPRECATED_2025_02(udfName, function) \ + SIMPLE_STRICT_UDF_OPTIONS(T##udfName, bool(TOptional<char*>, char*), \ + builder.SetMaxLangVer(NYql::MakeLangVersion(2025, 1))) \ + { \ + Y_UNUSED(valueBuilder); \ + if (args[0]) { \ + const TString haystack(args[0].AsStringRef()); \ + const TString needle(args[1].AsStringRef()); \ + return TUnboxedValuePod(function(haystack, needle)); \ + } else { \ + return TUnboxedValuePod(false); \ + } \ + } + +#define STRING_ASCII_CMP_IGNORE_CASE_UDF(udfName, function) \ + BEGIN_SIMPLE_STRICT_ARROW_UDF_OPTIONS(T##udfName, \ + bool(TOptional<char*>, char*), \ + builder.SetMinLangVer(NYql::MakeLangVersion(2025, 2))) \ + { \ Y_UNUSED(valueBuilder); \ if (args[0]) { \ const TString haystack(args[0].AsStringRef()); \ @@ -380,12 +397,19 @@ SIMPLE_STRICT_UDF_OPTIONS(TReverse, TOptional<char*>(TOptional<char*>), XX(HasPrefix, StartsWith) \ XX(HasSuffix, EndsWith) -#define STRING_TWO_ARGS_UDF_MAP(XX) \ +// NOTE: The functions below are marked as deprecated, so block implementation +// is not required for them. Hence, STRING_TWO_ARGS_UDF_DEPRECATED_2025_02 +// provides only the scalar one at the moment. +#define STRING_TWO_ARGS_UDF_MAP_DEPRECATED_2025_02(XX) \ XX(StartsWithIgnoreCase, AsciiHasPrefixIgnoreCase) \ XX(EndsWithIgnoreCase, AsciiHasSuffixIgnoreCase) \ XX(HasPrefixIgnoreCase, AsciiHasPrefixIgnoreCase) \ XX(HasSuffixIgnoreCase, AsciiHasSuffixIgnoreCase) +#define STRING_ASCII_CMP_IGNORE_CASE_UDF_MAP(XX) \ + XX(AsciiStartsWithIgnoreCase, AsciiHasPrefixIgnoreCase) \ + XX(AsciiEndsWithIgnoreCase, AsciiHasSuffixIgnoreCase) + // NOTE: The functions below are marked as deprecated, so block implementation // is not required for them. Hence, STROKA_UDF provides only the scalar one at // the moment. @@ -898,7 +922,8 @@ SIMPLE_STRICT_UDF_OPTIONS(TReverse, TOptional<char*>(TOptional<char*>), STROKA_CASE_UDF_MAP(STROKA_CASE_UDF) STROKA_ASCII_CASE_UDF_MAP(STROKA_ASCII_CASE_UDF) STROKA_FIND_UDF_MAP(STROKA_FIND_UDF) - STRING_TWO_ARGS_UDF_MAP(STRING_TWO_ARGS_UDF) + STRING_TWO_ARGS_UDF_MAP_DEPRECATED_2025_02(STRING_TWO_ARGS_UDF_DEPRECATED_2025_02) + STRING_ASCII_CMP_IGNORE_CASE_UDF_MAP(STRING_ASCII_CMP_IGNORE_CASE_UDF) IS_ASCII_UDF_MAP(IS_ASCII_UDF) static constexpr ui64 padLim = 1000000; @@ -914,7 +939,8 @@ SIMPLE_STRICT_UDF_OPTIONS(TReverse, TOptional<char*>(TOptional<char*>), STROKA_CASE_UDF_MAP(STRING_REGISTER_UDF) STROKA_ASCII_CASE_UDF_MAP(STRING_REGISTER_UDF) STROKA_FIND_UDF_MAP(STRING_REGISTER_UDF) - STRING_TWO_ARGS_UDF_MAP(STRING_REGISTER_UDF) + STRING_TWO_ARGS_UDF_MAP_DEPRECATED_2025_02(STRING_REGISTER_UDF) + STRING_ASCII_CMP_IGNORE_CASE_UDF_MAP(STRING_REGISTER_UDF) IS_ASCII_UDF_MAP(STRING_REGISTER_UDF) STRING_STREAM_PAD_FORMATTER_UDF_MAP(STRING_REGISTER_UDF) STRING_STREAM_NUM_FORMATTER_UDF_MAP(STRING_REGISTER_UDF) |
