Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
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: "[ES|QL] Add support for `byte_length` scalar function"
area: ES|QL
type: feature
issues: []

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.

37 changes: 37 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.

37 changes: 37 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.

12 changes: 12 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.

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.

Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,31 @@ FROM employees

// tag::length-result[]
first_name:keyword | last_name:keyword | fn_length:integer
Alejandro |McAlpine |9
Amabile |Gomatam |7
Alejandro |McAlpine |9
Amabile |Gomatam |7
Anneke |Preusig |6
// end::length-result[]
;

docsByteLength
required_capability: fn_byte_length
// tag::byteLength[]
FROM employees
| KEEP first_name, last_name
| EVAL fn_byte_length = BYTE_LENGTH(first_name)
// end::byteLength[]
| SORT first_name
| LIMIT 3
;

// tag::byteLength-result[]
first_name:keyword | last_name:keyword | fn_byte_length:integer
Alejandro |McAlpine |9
Amabile |Gomatam |7
Anneke |Preusig |6
// end::byteLength-result[]
;

docsGettingStartedEvalNoColumnName
// tag::gs-eval-no-column-name[]
FROM sample_data
Expand Down

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 @@ -33,6 +33,11 @@ public enum Cap {
*/
FN_BIT_LENGTH,

/**
* Support for function {@code BYTE_LENGTH}.
*/
FN_BYTE_LENGTH,

/**
* Support for function {@code REVERSE}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.StX;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.StY;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.BitLength;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.ByteLength;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Concat;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.EndsWith;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.LTrim;
Expand Down Expand Up @@ -308,6 +309,7 @@ private FunctionDefinition[][] functions() {
// string
new FunctionDefinition[] {
def(BitLength.class, BitLength::new, "bit_length"),
def(ByteLength.class, ByteLength::new, "byte_length"),
def(Concat.class, Concat::new, "concat"),
def(EndsWith.class, EndsWith::new, "ends_with"),
def(LTrim.class, LTrim::new, "ltrim"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.AbstractMultivalueFunction;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.StX;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.StY;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.ByteLength;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.LTrim;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Length;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.RLike;
Expand All @@ -80,6 +81,7 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
entries.add(Acos.ENTRY);
entries.add(Asin.ENTRY);
entries.add(Atan.ENTRY);
entries.add(ByteLength.ENTRY);
entries.add(Cbrt.ENTRY);
entries.add(Ceil.ENTRY);
entries.add(Cos.ENTRY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class BitLength extends UnaryScalarFunction {
@FunctionInfo(
returnType = "integer",
description = "Returns the bit length of a string.",
note = "All strings are in UTF-8, so a single character can use multiple bytes.",
examples = @Example(file = "docs", tag = "bitLength")
)
public BitLength(
Expand Down
Loading