Skip to content

Commit 9871976

Browse files
committed
And some more tests
1 parent 8f6e6a4 commit 9871976

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

docs/reference/query-languages/esql/_snippets/functions/types/to_string.md

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

docs/reference/query-languages/esql/kibana/definition/functions/to_string.json

Lines changed: 12 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/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToCartesianShape;
7979
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDateNanos;
8080
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatePeriod;
81+
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDateRange;
8182
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatetime;
8283
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDegrees;
8384
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDenseVector;
@@ -470,6 +471,7 @@ private static FunctionDefinition[][] functions() {
470471
def(ToDatePeriod.class, ToDatePeriod::new, "to_dateperiod"),
471472
def(ToDatetime.class, ToDatetime::new, "to_datetime", "to_dt"),
472473
def(ToDateNanos.class, ToDateNanos::new, "to_date_nanos", "to_datenanos"),
474+
def(ToDateRange.class, ToDateRange::new, "to_date_range", "to_daterange"),
473475
def(ToDegrees.class, ToDegrees::new, "to_degrees"),
474476
def(ToDenseVector.class, ToDenseVector::new, "to_dense_vector"),
475477
def(ToDouble.class, ToDouble::new, "to_double", "to_dbl"),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public ToString(
113113
"long",
114114
"text",
115115
"unsigned_long",
116-
"version" },
116+
"version",
117+
"date_range" },
117118
description = "Input value. The input can be a single- or multi-valued column or an expression."
118119
) Expression v
119120
) {

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,9 @@ public void testRegexOnInt() {
16411641

16421642
public void testUnsupportedTypesWithToString() {
16431643
// DATE_PERIOD and TIME_DURATION types have been added, but not really patched through the engine; i.e. supported.
1644-
final String supportedTypes = "aggregate_metric_double or boolean or cartesian_point or cartesian_shape or date_nanos or datetime "
1645-
+ "or dense_vector or geo_point or geo_shape or geohash or geohex or geotile or ip or numeric or string or version";
1644+
final String supportedTypes =
1645+
"aggregate_metric_double or boolean or cartesian_point or cartesian_shape or date_nanos or date_range or datetime "
1646+
+ "or dense_vector or geo_point or geo_shape or geohash or geohex or geotile or ip or numeric or string or version";
16461647
verifyUnsupported(
16471648
"row period = 1 year | eval to_string(period)",
16481649
"line 1:28: argument of [to_string(period)] must be [" + supportedTypes + "], found value [period] type [date_period]"

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleErrorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerP
3838
"first argument of ["
3939
+ sourceForSignature(signature)
4040
+ "] must be [any type except counter types, dense_vector,"
41-
+ " aggregate_metric_double, dense_vector or date_range], found value [] type ["
42-
+ signature.getFirst()
41+
+ " aggregate_metric_double or date_range], found value [] type ["
42+
+ signature.getFirst().esType()
4343
+ "]"
4444
);
4545
}

0 commit comments

Comments
 (0)