Skip to content

Commit 695cbb7

Browse files
committed
ESQL: Add url_decode function (#133494)
1 parent de50585 commit 695cbb7

File tree

2 files changed

+34
-3
lines changed
  • x-pack/plugin/esql

2 files changed

+34
-3
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,3 +2623,37 @@ ROW u = "%21%23%24%26%27%28%29*%2B%2C%2F%3A%3B%3D%3F%40%5B%5D" | EVAL u = URL_DE
26232623
u:keyword
26242624
"!#$&'()*+,/:;=?@[]"
26252625
;
2626+
2627+
combined url encode decode tests with table reads
2628+
required_capability: url_encode
2629+
required_capability: url_decode
2630+
2631+
FROM employees
2632+
| SORT emp_no
2633+
| LIMIT 10
2634+
| EVAL name = URL_DECODE(URL_ENCODE(CONCAT(gender, " - ", first_name, "+", last_name, "; ", CONCAT("@", first_name, last_name))))
2635+
| KEEP emp_no, name;
2636+
2637+
emp_no:integer | name:keyword
2638+
10001 | M - Georgi+Facello; @GeorgiFacello
2639+
10002 | F - Bezalel+Simmel; @BezalelSimmel
2640+
10003 | M - Parto+Bamford; @PartoBamford
2641+
10004 | M - Chirstian+Koblick; @ChirstianKoblick
2642+
10005 | M - Kyoichi+Maliniak; @KyoichiMaliniak
2643+
10006 | F - Anneke+Preusig; @AnnekePreusig
2644+
10007 | F - Tzvetan+Zielinski; @TzvetanZielinski
2645+
10008 | M - Saniya+Kalloufi; @SaniyaKalloufi
2646+
10009 | F - Sumant+Peac; @SumantPeac
2647+
10010 | null
2648+
;
2649+
2650+
combined url encode decode tests with random strings
2651+
required_capability: url_encode
2652+
required_capability: url_decode
2653+
2654+
ROW u = ["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
2655+
| eval u = URL_DECODE(URL_ENCODE(u));
2656+
2657+
u:keyword
2658+
["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
2659+
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlDecode.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvalua
8787
static BytesRef process(final BytesRef val) {
8888
String input = val.utf8ToString();
8989
String decoded = URLDecoder.decode(input, StandardCharsets.UTF_8);
90-
91-
// System.out.println(String.format("in: %s - out: %s", input, decoded));
92-
9390
return new BytesRef(decoded);
9491
}
9592
}

0 commit comments

Comments
 (0)