Skip to content

Commit

Permalink
[ES|QL] Add support BYTE_LENGTH scalar function (elastic#116591)
Browse files Browse the repository at this point in the history
Also added documentation and examples for BIT_LENGTH and LENGTH regarding unicode.
  • Loading branch information
GalLalouche authored Nov 12, 2024
1 parent 1bc5e33 commit b4898c9
Show file tree
Hide file tree
Showing 29 changed files with 667 additions and 159 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/116591.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 116591
summary: "Add support for `BYTE_LENGTH` scalar function"
area: ES|QL
type: feature
issues: []
2 changes: 2 additions & 0 deletions docs/reference/esql/functions/description/bit_length.asciidoc

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.

2 changes: 2 additions & 0 deletions docs/reference/esql/functions/description/length.asciidoc

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

13 changes: 13 additions & 0 deletions docs/reference/esql/functions/examples/byte_length.asciidoc

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

38 changes: 38 additions & 0 deletions docs/reference/esql/functions/kibana/definition/bit_length.json

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

38 changes: 38 additions & 0 deletions docs/reference/esql/functions/kibana/definition/byte_length.json

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

3 changes: 2 additions & 1 deletion docs/reference/esql/functions/kibana/definition/length.json

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

8 changes: 5 additions & 3 deletions docs/reference/esql/functions/kibana/docs/bit_length.md

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

14 changes: 14 additions & 0 deletions docs/reference/esql/functions/kibana/docs/byte_length.md

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

5 changes: 3 additions & 2 deletions docs/reference/esql/functions/kibana/docs/length.md

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

15 changes: 15 additions & 0 deletions docs/reference/esql/functions/layout/byte_length.asciidoc

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

6 changes: 6 additions & 0 deletions docs/reference/esql/functions/parameters/byte_length.asciidoc

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

1 change: 1 addition & 0 deletions docs/reference/esql/functions/signature/byte_length.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/reference/esql/functions/string-functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// tag::string_list[]
* <<esql-bit_length>>
* <<esql-byte_length>>
* <<esql-concat>>
* <<esql-ends_with>>
* <<esql-from_base64>>
Expand All @@ -32,6 +33,7 @@
// end::string_list[]

include::layout/bit_length.asciidoc[]
include::layout/byte_length.asciidoc[]
include::layout/concat.asciidoc[]
include::layout/ends_with.asciidoc[]
include::layout/from_base64.asciidoc[]
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/esql/functions/types/byte_length.asciidoc

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

59 changes: 30 additions & 29 deletions x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// the comments in whatever file the test already lives in. If you have to
// write a new test to make an example in the docs then put it in whatever
// file matches its "theme" best. Put it next to similar tests. Not here.

// Also! When Nik originally extracted examples from the docs to make them
// testable he didn't spend a lot of time putting the docs into appropriate
// files. He just made this one. He didn't put his toys away. We'd be better
Expand Down Expand Up @@ -352,26 +352,26 @@ FROM employees

// tag::case-result[]
emp_no:integer | languages:integer| type:keyword
10001 | 2 |bilingual
10002 | 5 |polyglot
10003 | 4 |polyglot
10004 | 5 |polyglot
10005 | 1 |monolingual
10001 | 2 |bilingual
10002 | 5 |polyglot
10003 | 4 |polyglot
10004 | 5 |polyglot
10005 | 1 |monolingual
// end::case-result[]
;

docsCountAll
// tag::countAll[]
FROM employees
| STATS count = COUNT(*) BY languages
FROM employees
| STATS count = COUNT(*) BY languages
| SORT languages DESC
// end::countAll[]
;

// tag::countAll-result[]
count:long | languages:integer
10 |null
21 |5
21 |5
18 |4
17 |3
19 |2
Expand All @@ -381,8 +381,8 @@ count:long | languages:integer

basicGrok
// tag::basicGrok[]
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num}"""
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num}"""
| KEEP date, ip, email, num
// end::basicGrok[]
;
Expand All @@ -395,8 +395,8 @@ date:keyword | ip:keyword | email:keyword | num:keyword

grokWithConversionSuffix
// tag::grokWithConversionSuffix[]
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
| KEEP date, ip, email, num
// end::grokWithConversionSuffix[]
;
Expand All @@ -409,8 +409,8 @@ date:keyword | ip:keyword | email:keyword | num:integer

grokWithToDatetime
// tag::grokWithToDatetime[]
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 some.email@foo.com 42"
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
| KEEP date, ip, email, num
| EVAL date = TO_DATETIME(date)
// end::grokWithToDatetime[]
Expand Down Expand Up @@ -471,7 +471,7 @@ Tokyo | 100-7014 | null

basicDissect
// tag::basicDissect[]
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
| DISSECT a """%{date} - %{msg} - %{ip}"""
| KEEP date, msg, ip
// end::basicDissect[]
Expand All @@ -485,8 +485,8 @@ date:keyword | msg:keyword | ip:keyword

dissectWithToDatetime
// tag::dissectWithToDatetime[]
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
| DISSECT a """%{date} - %{msg} - %{ip}"""
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
| DISSECT a """%{date} - %{msg} - %{ip}"""
| KEEP date, msg, ip
| EVAL date = TO_DATETIME(date)
// end::dissectWithToDatetime[]
Expand Down Expand Up @@ -574,8 +574,8 @@ FROM employees

// tag::like-result[]
first_name:keyword | last_name:keyword
Ebbe |Callaway
Eberhardt |Terkki
Ebbe |Callaway
Eberhardt |Terkki
// end::like-result[]
;

Expand All @@ -589,7 +589,7 @@ FROM employees

// tag::rlike-result[]
first_name:keyword | last_name:keyword
Alejandro |McAlpine
Alejandro |McAlpine
// end::rlike-result[]
;

Expand Down Expand Up @@ -660,18 +660,19 @@ FROM sample_data
docsBitLength
required_capability: fn_bit_length
// tag::bitLength[]
FROM employees
| KEEP first_name, last_name
| EVAL fn_bit_length = BIT_LENGTH(first_name)
FROM airports
| WHERE country == "India"
| KEEP city
| EVAL fn_length=LENGTH(city), fn_bit_length = BIT_LENGTH(city)
// end::bitLength[]
| SORT first_name
| SORT city
| LIMIT 3
;

// tag::bitLength-result[]
first_name:keyword | last_name:keyword | fn_bit_length:integer
Alejandro |McAlpine |72
Amabile |Gomatam |56
Anneke |Preusig |48
city:keyword | fn_length:integer | fn_bit_length:integer
Agwār | 5 | 48
Ahmedabad | 9 | 72
Bangalore | 9 | 72
// end::bitLength-result[]
;
Loading

0 comments on commit b4898c9

Please sign in to comment.