Skip to content

Commit 996a205

Browse files
authored
Merge 501a210 into f2a67c6
2 parents f2a67c6 + 501a210 commit 996a205

File tree

5 files changed

+203
-6
lines changed

5 files changed

+203
-6
lines changed

ydb/library/yql/udfs/common/string/string_udf.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,26 @@ using namespace NUdf;
3131

3232
namespace {
3333

34-
#define STRING_UDF(udfName, function) \
35-
SIMPLE_STRICT_UDF(T##udfName, char*(TAutoMap<char*>)) { \
36-
const TString input(args[0].AsStringRef()); \
37-
const auto& result = function(input); \
38-
return valueBuilder->NewString(result); \
39-
}
34+
#define STRING_UDF(udfName, function) \
35+
BEGIN_SIMPLE_STRICT_ARROW_UDF(T##udfName, char*(TAutoMap<char*>)) { \
36+
const TString input(args[0].AsStringRef()); \
37+
const auto& result = function(input); \
38+
return valueBuilder->NewString(result); \
39+
} \
40+
\
41+
struct T##udfName##KernelExec \
42+
: public TUnaryKernelExec<T##udfName##KernelExec> \
43+
{ \
44+
template <typename TSink> \
45+
static void Process(TBlockItem arg1, const TSink& sink) { \
46+
const TString input(arg1.AsStringRef()); \
47+
const auto& result = function(input); \
48+
sink(TBlockItem(result)); \
49+
} \
50+
}; \
51+
\
52+
END_SIMPLE_ARROW_UDF(T##udfName, T##udfName##KernelExec::Do)
53+
4054

4155
// 'unsafe' udf is actually strict - it returns null on any exception
4256
#define STRING_UNSAFE_UDF(udfName, function) \

ydb/library/yql/udfs/common/string/test/canondata/result.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,10 @@
5858
{
5959
"uri": "file://test.test_To_/results.txt"
6060
}
61+
],
62+
"test.test[YQL-18027-BlockStringUDF]": [
63+
{
64+
"uri": "file://test.test_YQL-18027-BlockStringUDF_/results.txt"
65+
}
6166
]
6267
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
[
2+
{
3+
"Write" = [
4+
{
5+
"Type" = [
6+
"ListType";
7+
[
8+
"StructType";
9+
[
10+
[
11+
"b32enc";
12+
[
13+
"DataType";
14+
"String"
15+
]
16+
];
17+
[
18+
"b64enc";
19+
[
20+
"DataType";
21+
"String"
22+
]
23+
];
24+
[
25+
"b64encu";
26+
[
27+
"DataType";
28+
"String"
29+
]
30+
];
31+
[
32+
"cesc";
33+
[
34+
"DataType";
35+
"String"
36+
]
37+
];
38+
[
39+
"cunesc";
40+
[
41+
"DataType";
42+
"String"
43+
]
44+
];
45+
[
46+
"xenc";
47+
[
48+
"DataType";
49+
"String"
50+
]
51+
];
52+
[
53+
"henc";
54+
[
55+
"DataType";
56+
"String"
57+
]
58+
];
59+
[
60+
"hdec";
61+
[
62+
"DataType";
63+
"String"
64+
]
65+
];
66+
[
67+
"cgesc";
68+
[
69+
"DataType";
70+
"String"
71+
]
72+
];
73+
[
74+
"cgunesc";
75+
[
76+
"DataType";
77+
"String"
78+
]
79+
];
80+
[
81+
"clps";
82+
[
83+
"DataType";
84+
"String"
85+
]
86+
];
87+
[
88+
"strp";
89+
[
90+
"DataType";
91+
"String"
92+
]
93+
]
94+
]
95+
]
96+
];
97+
"Data" = [
98+
[
99+
"EAQCAILRO5SSA4TUPEQCAIDVNFXXAIC3EBOSI===";
100+
"ICAgIXF3ZSBydHkgICB1aW9wIFsgXSQ=";
101+
"ICAgIXF3ZSBydHkgICB1aW9wIFsgXSQ,";
102+
" !qwe rty uiop [ ]$";
103+
" !qwe rty uiop [ ]$";
104+
"202020217177652072747920202075696F70205B205D24";
105+
" !qwe rty uiop [ ]$";
106+
" !qwe rty uiop [ ]$";
107+
"+++!qwe+rty+++uiop+%5B+%5D$";
108+
" !qwe rty uiop [ ]$";
109+
" !qwe rty uiop [ ]$";
110+
"!qwe rty uiop [ ]$"
111+
];
112+
[
113+
"IBQXGIBAEAQCAIBAMRTGO2BANJVWYCR3E4SSAIA=";
114+
"QGFzICAgICAgIGRmZ2ggamtsCjsnJSAg";
115+
"QGFzICAgICAgIGRmZ2ggamtsCjsnJSAg";
116+
"@as dfgh jkl\\n;'% ";
117+
"@as dfgh jkl\n;'% ";
118+
"4061732020202020202064666768206A6B6C0A3B27252020";
119+
"@as dfgh jkl\n;&#39;% ";
120+
"@as dfgh jkl\n;'% ";
121+
"@as+++++++dfgh+jkl%0A;%27%25++";
122+
"@as dfgh jkl\n;'% ";
123+
"@as dfgh jkl ;'% ";
124+
"@as dfgh jkl\n;'%"
125+
];
126+
[
127+
"EAQCAI32PBRQS5TCNYQASCQIEBWSYLRPH5PCAIBA";
128+
"ICAgI3p4Ywl2Ym4gCQoIIG0sLi8/XiAgIA==";
129+
"ICAgI3p4Ywl2Ym4gCQoIIG0sLi8_XiAgIA,,";
130+
" #zxc\\tvbn \\t\\n\\x08 m,./?^ ";
131+
" #zxc\tvbn \t\n\x08 m,./?^ ";
132+
"202020237A78630976626E20090A08206D2C2E2F3F5E202020";
133+
" #zxc\tvbn \t\n\x08 m,./?^ ";
134+
" #zxc\tvbn \t\n\x08 m,./?^ ";
135+
"+++%23zxc%09vbn+%09%0A%08+m%2C./%3F%5E+++";
136+
" #zxc\tvbn \t\n\x08 m,./?^ ";
137+
" #zxc vbn \x08 m,./?^ ";
138+
"#zxc\tvbn \t\n\x08 m,./?^"
139+
];
140+
[
141+
"GEQTEQBTEM2CINJFGZPDOJRYFI4SQMBJFVPT2KZMHQXD4===";
142+
"MSEyQDMjNCQ1JTZeNyY4KjkoMCktXz0rLDwuPg==";
143+
"MSEyQDMjNCQ1JTZeNyY4KjkoMCktXz0rLDwuPg,,";
144+
"1!2@3#4$5%6^7&8*9(0)-_=+,<.>";
145+
"1!2@3#4$5%6^7&8*9(0)-_=+,<.>";
146+
"31213240332334243525365E3726382A392830292D5F3D2B2C3C2E3E";
147+
"1!2@3#4$5%6^7&amp;8*9(0)-_=+,&lt;.&gt;";
148+
"1!2@3#4$5%6^7&8*9(0)-_=+,<.>";
149+
"1!2@3%234$5%256%5E7%268*9%280%29-_%3D%2B%2C%3C.%3E";
150+
"1!2@3#4$5%6^7&8*9(0)-_= ,<.>";
151+
"1!2@3#4$5%6^7&8*9(0)-_=+,<.>";
152+
"1!2@3#4$5%6^7&8*9(0)-_=+,<.>"
153+
]
154+
]
155+
}
156+
]
157+
}
158+
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"value"=" !qwe rty uiop [ ]$"};
2+
{"value"="@as dfgh jkl\n;'\% "};
3+
{"value"=" #zxc\tvbn \t\n\b m,./?^ "};
4+
{"value"="1!2@3#4$5%6^7&8*9(0)-_=+,<.>"};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PRAGMA UseBlocks;
2+
3+
SELECT
4+
String::Base32Encode(value) as b32enc,
5+
String::Base64Encode(value) as b64enc,
6+
String::Base64EncodeUrl(value) as b64encu,
7+
String::EscapeC(value) as cesc,
8+
String::UnescapeC(value) as cunesc,
9+
String::HexEncode(value) as xenc,
10+
String::EncodeHtml(value) as henc,
11+
String::DecodeHtml(value) as hdec,
12+
String::CgiEscape(value) as cgesc,
13+
String::CgiUnescape(value) as cgunesc,
14+
String::Collapse(value) as clps,
15+
String::Strip(value) as strp,
16+
FROM Input

0 commit comments

Comments
 (0)