Skip to content

Commit 9633d6c

Browse files
authored
ESQL: TO_LOWER process all values (#124676) (#127772)
Make `TO_LOWER` and `TO_UPPER` process all values it received. This is quite large because it borrows a lot of code from the regular evaluator generator to generate conversions so we can use the Locale. That change propagates to the order of some parameters and to the `toString` and a few more places. Closes #124002
1 parent f19ba6a commit 9633d6c

File tree

21 files changed

+255
-197
lines changed

21 files changed

+255
-197
lines changed

docs/changelog/124676.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 124676
2+
summary: TO_LOWER processes all values
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 124002

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

Lines changed: 9 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/definition/to_lower.json

Lines changed: 4 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/definition/to_upper.json

Lines changed: 2 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/parameters/to_lower.asciidoc

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

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

Lines changed: 1 addition & 1 deletion
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/string.csv-spec

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,20 @@ emp_no:integer | first_name:keyword | name_lower:keyword
13991399
;
14001400

14011401

1402+
toLowerMv
1403+
required_capability: to_lower_mv
1404+
// tag::to_lower_mv[]
1405+
ROW v = TO_LOWER(["Some", "Text"])
1406+
// end::to_lower_mv[]
1407+
;
1408+
1409+
// tag::to_lower_mv-result[]
1410+
v:keyword
1411+
["some", "text"]
1412+
// end::to_lower_mv-result[]
1413+
;
1414+
1415+
14021416
toUpperRow#[skip:-8.12.99]
14031417
// tag::to_upper[]
14041418
ROW message = "Some Text"
@@ -1421,6 +1435,20 @@ emp_no:integer | first_name:keyword | name_upper:keyword
14211435
;
14221436

14231437

1438+
toUpperMv
1439+
required_capability: to_lower_mv
1440+
// tag::to_upper_mv[]
1441+
ROW v = TO_UPPER(["Some", "Text"])
1442+
// end::to_upper_mv[]
1443+
;
1444+
1445+
// tag::to_upper_mv-result[]
1446+
v:keyword
1447+
["SOME", "TEXT"]
1448+
// end::to_upper_mv-result[]
1449+
;
1450+
1451+
14241452
toUpperLowerUnicode#[skip:-8.12.99]
14251453
row a = "π/2 + a + B + Λ ºC" | eval lower = to_lower(a), upper = to_upper(a) | keep a, upper, lower;
14261454

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ChangeCaseEvaluator.java

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

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ public enum Cap {
840840
*/
841841
FIX_JOIN_MASKING_EVAL,
842842

843+
/**
844+
* Do {@code TO_LOWER} and {@code TO_UPPER} process all field values?
845+
*/
846+
TO_LOWER_MV,
847+
843848
/**
844849
* Resolve groupings before resolving references to groupings in the aggregations.
845850
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromAggregateMetricDoubleEvaluator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.compute.data.Vector;
1515
import org.elasticsearch.compute.operator.DriverContext;
1616
import org.elasticsearch.compute.operator.EvalOperator;
17+
import org.elasticsearch.core.Releasables;
1718
import org.elasticsearch.xpack.esql.core.tree.Source;
1819

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

6465
@Override
6566
public void close() {
66-
field.close();
67+
Releasables.closeExpectNoException(field);
6768
}
6869

6970
public static class Factory implements EvalOperator.ExpressionEvaluator.Factory {

0 commit comments

Comments
 (0)