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
6 changes: 6 additions & 0 deletions docs/changelog/124676.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 124676
summary: TO_LOWER processes all values
area: ES|QL
type: bug
issues:
- 124002
10 changes: 9 additions & 1 deletion docs/reference/esql/functions/examples/to_lower.asciidoc

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

7 changes: 4 additions & 3 deletions docs/reference/esql/functions/kibana/definition/to_lower.json

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

4 changes: 2 additions & 2 deletions docs/reference/esql/functions/kibana/definition/to_upper.json

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

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/parameters/to_lower.asciidoc

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

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/parameters/to_upper.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 @@ -1399,6 +1399,20 @@ emp_no:integer | first_name:keyword | name_lower:keyword
;


toLowerMv
required_capability: to_lower_mv
// tag::to_lower_mv[]
ROW v = TO_LOWER(["Some", "Text"])
// end::to_lower_mv[]
;

// tag::to_lower_mv-result[]
v:keyword
["some", "text"]
// end::to_lower_mv-result[]
;


toUpperRow#[skip:-8.12.99]
// tag::to_upper[]
ROW message = "Some Text"
Expand All @@ -1421,6 +1435,20 @@ emp_no:integer | first_name:keyword | name_upper:keyword
;


toUpperMv
required_capability: to_lower_mv
// tag::to_upper_mv[]
ROW v = TO_UPPER(["Some", "Text"])
// end::to_upper_mv[]
;

// tag::to_upper_mv-result[]
v:keyword
["SOME", "TEXT"]
// end::to_upper_mv-result[]
;


toUpperLowerUnicode#[skip:-8.12.99]
row a = "π/2 + a + B + Λ ºC" | eval lower = to_lower(a), upper = to_upper(a) | keep a, upper, lower;

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

/**
* Do {@code TO_LOWER} and {@code TO_UPPER} process all field values?
*/
TO_LOWER_MV,

/**
* Resolve groupings before resolving references to groupings in the aggregations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.compute.data.Vector;
import org.elasticsearch.compute.operator.DriverContext;
import org.elasticsearch.compute.operator.EvalOperator;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.xpack.esql.core.tree.Source;

import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.aggregateMetricDoubleBlockToString;
Expand Down Expand Up @@ -63,7 +64,7 @@ public Block evalBlock(Block b) {

@Override
public void close() {
field.close();
Releasables.closeExpectNoException(field);
}

public static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.ConvertEvaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.EvalOperator;
import org.elasticsearch.xpack.esql.core.expression.Expression;
Expand Down Expand Up @@ -99,7 +99,7 @@ public Expression replaceChildren(List<Expression> newChildren) {
return replaceChild(newChildren.get(0));
}

@Evaluator
@ConvertEvaluator
static BytesRef process(BytesRef val, @Fixed Locale locale, @Fixed Case caseType) {
return BytesRefs.toBytesRef(caseType.process(val.utf8ToString(), locale));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ public class ToLower extends ChangeCase {
@FunctionInfo(
returnType = { "keyword" },
description = "Returns a new string representing the input string converted to lower case.",
examples = @Example(file = "string", tag = "to_lower")
examples = { @Example(file = "string", tag = "to_lower"), @Example(file = "string", tag = "to_lower_mv"), }
)
public ToLower(
Source source,
@Param(
name = "str",
type = { "keyword", "text" },
description = "String expression. If `null`, the function returns `null`."
) Expression field,
Configuration configuration
) {
public ToLower(Source source, @Param(name = "str", type = { "keyword", "text" }, description = """
String expression. If `null`, the function returns `null`.
The input can be a single- or multi-valued column or an expression.""") Expression field, Configuration configuration) {
super(source, field, configuration, Case.LOWER);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ public class ToUpper extends ChangeCase {
description = "Returns a new string representing the input string converted to upper case.",
examples = @Example(file = "string", tag = "to_upper")
)
public ToUpper(
Source source,
@Param(
name = "str",
type = { "keyword", "text" },
description = "String expression. If `null`, the function returns `null`."
) Expression field,
Configuration configuration
) {
public ToUpper(Source source, @Param(name = "str", type = { "keyword", "text" }, description = """
String expression. If `null`, the function returns `null`.
The input can be a single- or multi-valued column or an expression.""") Expression field, Configuration configuration) {
super(source, field, configuration, Case.UPPER);
}

Expand Down
Loading