Skip to content

Commit 61d2e1e

Browse files
GalLalouchejozala
authored andcommitted
[ES|QL] Add support BYTE_LENGTH scalar function (#116591)
Also added documentation and examples for BIT_LENGTH and LENGTH regarding unicode.
1 parent 0475d0c commit 61d2e1e

File tree

29 files changed

+667
-159
lines changed

29 files changed

+667
-159
lines changed

docs/changelog/116591.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 116591
2+
summary: "Add support for `BYTE_LENGTH` scalar function"
3+
area: ES|QL
4+
type: feature
5+
issues: []

docs/reference/esql/functions/description/bit_length.asciidoc

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/description/byte_length.asciidoc

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/description/length.asciidoc

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/examples/byte_length.asciidoc

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/bit_length.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/byte_length.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/length.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/bit_length.md

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/byte_length.md

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/length.md

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/layout/byte_length.asciidoc

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/parameters/byte_length.asciidoc

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/signature/byte_length.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/reference/esql/functions/string-functions.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// tag::string_list[]
1111
* <<esql-bit_length>>
12+
* <<esql-byte_length>>
1213
* <<esql-concat>>
1314
* <<esql-ends_with>>
1415
* <<esql-from_base64>>
@@ -32,6 +33,7 @@
3233
// end::string_list[]
3334

3435
include::layout/bit_length.asciidoc[]
36+
include::layout/byte_length.asciidoc[]
3537
include::layout/concat.asciidoc[]
3638
include::layout/ends_with.asciidoc[]
3739
include::layout/from_base64.asciidoc[]

docs/reference/esql/functions/types/byte_length.asciidoc

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// the comments in whatever file the test already lives in. If you have to
55
// write a new test to make an example in the docs then put it in whatever
66
// file matches its "theme" best. Put it next to similar tests. Not here.
7-
7+
88
// Also! When Nik originally extracted examples from the docs to make them
99
// testable he didn't spend a lot of time putting the docs into appropriate
1010
// files. He just made this one. He didn't put his toys away. We'd be better
@@ -352,26 +352,26 @@ FROM employees
352352

353353
// tag::case-result[]
354354
emp_no:integer | languages:integer| type:keyword
355-
10001 | 2 |bilingual
356-
10002 | 5 |polyglot
357-
10003 | 4 |polyglot
358-
10004 | 5 |polyglot
359-
10005 | 1 |monolingual
355+
10001 | 2 |bilingual
356+
10002 | 5 |polyglot
357+
10003 | 4 |polyglot
358+
10004 | 5 |polyglot
359+
10005 | 1 |monolingual
360360
// end::case-result[]
361361
;
362362

363363
docsCountAll
364364
// tag::countAll[]
365-
FROM employees
366-
| STATS count = COUNT(*) BY languages
365+
FROM employees
366+
| STATS count = COUNT(*) BY languages
367367
| SORT languages DESC
368368
// end::countAll[]
369369
;
370370

371371
// tag::countAll-result[]
372372
count:long | languages:integer
373373
10 |null
374-
21 |5
374+
21 |5
375375
18 |4
376376
17 |3
377377
19 |2
@@ -381,8 +381,8 @@ count:long | languages:integer
381381

382382
basicGrok
383383
// tag::basicGrok[]
384-
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
385-
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num}"""
384+
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
385+
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num}"""
386386
| KEEP date, ip, email, num
387387
// end::basicGrok[]
388388
;
@@ -395,8 +395,8 @@ date:keyword | ip:keyword | email:keyword | num:keyword
395395

396396
grokWithConversionSuffix
397397
// tag::grokWithConversionSuffix[]
398-
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
399-
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
398+
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
399+
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
400400
| KEEP date, ip, email, num
401401
// end::grokWithConversionSuffix[]
402402
;
@@ -409,8 +409,8 @@ date:keyword | ip:keyword | email:keyword | num:integer
409409

410410
grokWithToDatetime
411411
// tag::grokWithToDatetime[]
412-
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
413-
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
412+
ROW a = "2023-01-23T12:15:00.000Z 127.0.0.1 [email protected] 42"
413+
| GROK a """%{TIMESTAMP_ISO8601:date} %{IP:ip} %{EMAILADDRESS:email} %{NUMBER:num:int}"""
414414
| KEEP date, ip, email, num
415415
| EVAL date = TO_DATETIME(date)
416416
// end::grokWithToDatetime[]
@@ -471,7 +471,7 @@ Tokyo | 100-7014 | null
471471

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

486486
dissectWithToDatetime
487487
// tag::dissectWithToDatetime[]
488-
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
489-
| DISSECT a """%{date} - %{msg} - %{ip}"""
488+
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
489+
| DISSECT a """%{date} - %{msg} - %{ip}"""
490490
| KEEP date, msg, ip
491491
| EVAL date = TO_DATETIME(date)
492492
// end::dissectWithToDatetime[]
@@ -574,8 +574,8 @@ FROM employees
574574

575575
// tag::like-result[]
576576
first_name:keyword | last_name:keyword
577-
Ebbe |Callaway
578-
Eberhardt |Terkki
577+
Ebbe |Callaway
578+
Eberhardt |Terkki
579579
// end::like-result[]
580580
;
581581

@@ -589,7 +589,7 @@ FROM employees
589589

590590
// tag::rlike-result[]
591591
first_name:keyword | last_name:keyword
592-
Alejandro |McAlpine
592+
Alejandro |McAlpine
593593
// end::rlike-result[]
594594
;
595595

@@ -660,18 +660,19 @@ FROM sample_data
660660
docsBitLength
661661
required_capability: fn_bit_length
662662
// tag::bitLength[]
663-
FROM employees
664-
| KEEP first_name, last_name
665-
| EVAL fn_bit_length = BIT_LENGTH(first_name)
663+
FROM airports
664+
| WHERE country == "India"
665+
| KEEP city
666+
| EVAL fn_length=LENGTH(city), fn_bit_length = BIT_LENGTH(city)
666667
// end::bitLength[]
667-
| SORT first_name
668+
| SORT city
668669
| LIMIT 3
669670
;
670671

671672
// tag::bitLength-result[]
672-
first_name:keyword | last_name:keyword | fn_bit_length:integer
673-
Alejandro |McAlpine |72
674-
Amabile |Gomatam |56
675-
Anneke |Preusig |48
673+
city:keyword | fn_length:integer | fn_bit_length:integer
674+
Agwār | 5 | 48
675+
Ahmedabad | 9 | 72
676+
Bangalore | 9 | 72
676677
// end::bitLength-result[]
677678
;

0 commit comments

Comments
 (0)