Skip to content

Commit c3b9ee5

Browse files
committed
ESQL: Add url_decode function (elastic#133494)
1 parent 1ce7951 commit c3b9ee5

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
@@ -2537,3 +2537,37 @@ ROW u = "%21%23%24%26%27%28%29*%2B%2C%2F%3A%3B%3D%3F%40%5B%5D" | EVAL u = URL_DE
25372537
u:keyword
25382538
"!#$&'()*+,/:;=?@[]"
25392539
;
2540+
2541+
combined url encode decode tests with table reads
2542+
required_capability: url_encode
2543+
required_capability: url_decode
2544+
2545+
FROM employees
2546+
| SORT emp_no
2547+
| LIMIT 10
2548+
| EVAL name = URL_DECODE(URL_ENCODE(CONCAT(gender, " - ", first_name, "+", last_name, "; ", CONCAT("@", first_name, last_name))))
2549+
| KEEP emp_no, name;
2550+
2551+
emp_no:integer | name:keyword
2552+
10001 | M - Georgi+Facello; @GeorgiFacello
2553+
10002 | F - Bezalel+Simmel; @BezalelSimmel
2554+
10003 | M - Parto+Bamford; @PartoBamford
2555+
10004 | M - Chirstian+Koblick; @ChirstianKoblick
2556+
10005 | M - Kyoichi+Maliniak; @KyoichiMaliniak
2557+
10006 | F - Anneke+Preusig; @AnnekePreusig
2558+
10007 | F - Tzvetan+Zielinski; @TzvetanZielinski
2559+
10008 | M - Saniya+Kalloufi; @SaniyaKalloufi
2560+
10009 | F - Sumant+Peac; @SumantPeac
2561+
10010 | null
2562+
;
2563+
2564+
combined url encode decode tests with random strings
2565+
required_capability: url_encode
2566+
required_capability: url_decode
2567+
2568+
ROW u = ["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
2569+
| eval u = URL_DECODE(URL_ENCODE(u));
2570+
2571+
u:keyword
2572+
["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
2573+
;

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)