Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2587,3 +2587,73 @@ ROW u = ["hello elastic!", "a+b-c%d", "", "!#$&'()*+,/:;=?@[]"] | EVAL u = URL_E
u:keyword
["hello+elastic%21", "a%2Bb-c%25d", "", "%21%23%24%26%27%28%29*%2B%2C%2F%3A%3B%3D%3F%40%5B%5D"]
;

url_decode sample for docs
required_capability: url_decode

// tag::url_decode[]
ROW u = "https%3A%2F%2Fwww.example.com%2Fpapers%3Fq%3Dinformation%2Bretrieval%26year%3D2024%26citations%3Dhigh" | EVAL u = URL_DECODE(u)
// end::url_decode[]
;

// tag::url_decode-result[]
u:keyword
https://www.example.com/papers?q=information+retrieval&year=2024&citations=high
// end::url_decode-result[]
;

url_decode mixed functions tests
required_capability: url_decode

FROM employees
| WHERE emp_no == 10001
| EVAL a = TRIM(URL_DECODE(first_name))
| EVAL b = URL_DECODE(TO_LOWER(first_name))
| KEEP a,b;

a:keyword | b:keyword
Georgi | georgi
;

url_decode mixed input tests
required_capability: url_decode

ROW u = "%21%23%24%26%27%28%29*%2B%2C%2F%3A%3B%3D%3F%40%5B%5D" | EVAL u = URL_DECODE(u);

u:keyword
"!#$&'()*+,/:;=?@[]"
;

combined url encode decode tests with table reads
required_capability: url_encode
required_capability: url_decode

FROM employees
| SORT emp_no
| LIMIT 10
| EVAL name = URL_DECODE(URL_ENCODE(CONCAT(gender, " - ", first_name, "+", last_name, "; ", CONCAT("@", first_name, last_name))))
| KEEP emp_no, name;

emp_no:integer | name:keyword
10001 | M - Georgi+Facello; @GeorgiFacello
10002 | F - Bezalel+Simmel; @BezalelSimmel
10003 | M - Parto+Bamford; @PartoBamford
10004 | M - Chirstian+Koblick; @ChirstianKoblick
10005 | M - Kyoichi+Maliniak; @KyoichiMaliniak
10006 | F - Anneke+Preusig; @AnnekePreusig
10007 | F - Tzvetan+Zielinski; @TzvetanZielinski
10008 | M - Saniya+Kalloufi; @SaniyaKalloufi
10009 | F - Sumant+Peac; @SumantPeac
10010 | null
;

combined url encode decode tests with random strings
required_capability: url_encode
required_capability: url_decode

ROW u = ["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
| eval u = URL_DECODE(URL_ENCODE(u));

u:keyword
["https://www.example.com/papers?q=information+retrieval&year=2024&citations=high", "", "!#$&'()+/:;=?@[]", "💨🔥🪨💧"]
;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,12 @@ public enum Cap {
/**
* URL encoding function.
*/
URL_ENCODE(Build.current().isSnapshot());
URL_ENCODE(Build.current().isSnapshot()),

/**
* URL decoding function.
*/
URL_DECODE(Build.current().isSnapshot());

private final boolean enabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToString;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToUnsignedLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToVersion;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.UrlDecode;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.UrlEncode;
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Abs;
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Acos;
Expand Down Expand Up @@ -225,6 +226,7 @@ public static List<NamedWriteableRegistry.Entry> unaryScalars() {
entries.add(WildcardLikeList.ENTRY);
entries.add(Delay.ENTRY);
entries.add(UrlEncode.ENTRY);
entries.add(UrlDecode.ENTRY);
// mv functions
entries.addAll(MvFunctionWritables.getNamedWriteables());
return entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToTimeDuration;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToUnsignedLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToVersion;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.UrlDecode;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.UrlEncode;
import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateDiff;
import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateExtract;
Expand Down Expand Up @@ -517,7 +518,8 @@ private static FunctionDefinition[][] snapshotFunctions() {
def(L2Norm.class, L2Norm::new, "v_l2_norm"),
def(Magnitude.class, Magnitude::new, "v_magnitude"),
def(Hamming.class, Hamming::new, "v_hamming"),
def(UrlEncode.class, UrlEncode::new, "url_encode") } };
def(UrlEncode.class, UrlEncode::new, "url_encode"),
def(UrlDecode.class, UrlDecode::new, "url_decode") } };
}

public EsqlFunctionRegistry snapshotRegistry() {
Expand Down
Loading
Loading