Skip to content

Commit 72d2d86

Browse files
authored
YQL-17057: Fix escaping (#1664)
* YQL-17057: Fix escaping * test
1 parent 8fd6a95 commit 72d2d86

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

ydb/library/yql/udfs/common/re2/re2_udf.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,14 @@ namespace {
382382
default:
383383
if (hasEscape && c == escape) {
384384
if (escapeOn) {
385-
result << c;
385+
result << RE2::QuoteMeta(StringPiece(&c, 1));
386386
}
387387
escapeOn = !escapeOn;
388388
} else {
389389
if (slash)
390390
result << '\\';
391391
result << c;
392+
escapeOn = false;
392393
}
393394
slash = false;
394395
break;

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

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"uri": "file://test.test_DefOptions_/results.txt"
2020
}
2121
],
22+
"test.test[LikeEscape]": [
23+
{
24+
"uri": "file://test.test_LikeEscape_/results.txt"
25+
}
26+
],
2227
"test.test[MultipleCaptureGroups]": [
2328
{
2429
"uri": "file://test.test_MultipleCaptureGroups_/extracted"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[
2+
{
3+
"Write" = [
4+
{
5+
"Type" = [
6+
"ListType";
7+
[
8+
"StructType";
9+
[
10+
[
11+
"column0";
12+
[
13+
"DataType";
14+
"Bool"
15+
]
16+
];
17+
[
18+
"column1";
19+
[
20+
"DataType";
21+
"Bool"
22+
]
23+
];
24+
[
25+
"column2";
26+
[
27+
"DataType";
28+
"Bool"
29+
]
30+
];
31+
[
32+
"column3";
33+
[
34+
"DataType";
35+
"Bool"
36+
]
37+
];
38+
[
39+
"column4";
40+
[
41+
"DataType";
42+
"Bool"
43+
]
44+
];
45+
[
46+
"column5";
47+
[
48+
"DataType";
49+
"Bool"
50+
]
51+
];
52+
[
53+
"column6";
54+
[
55+
"DataType";
56+
"Bool"
57+
]
58+
]
59+
]
60+
]
61+
];
62+
"Data" = [
63+
[
64+
%true;
65+
%true;
66+
%true;
67+
%true;
68+
%true;
69+
%true;
70+
%false
71+
]
72+
]
73+
}
74+
]
75+
}
76+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT '?' LIKE '%??%' ESCAPE '?',
2+
'x_' LIKE '%xxx_' ESCAPE 'x',
3+
'[' LIKE '[' ESCAPE '!',
4+
'.' LIKE '..' ESCAPE '.',
5+
'[' LIKE '[[' ESCAPE '[',
6+
'a%b' LIKE '.a.%.b' ESCAPE '.',
7+
'x' LIKE '..' ESCAPE '.';

0 commit comments

Comments
 (0)