ESQL: Replace "representable" type error messages#131775
ESQL: Replace "representable" type error messages#131775ivancea merged 20 commits intoelastic:mainfrom
Conversation
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMax.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMin.java
…e their error messages
|
Hi @ivancea, I've created a changelog YAML for you. |
| /** | ||
| * @see DataType#isRepresentable(DataType) | ||
| */ | ||
| public static TypeResolution isRepresentableExceptCounters(Expression e, String operationName, ParamOrdinal paramOrd) { |
There was a problem hiding this comment.
Added some helpers to centralize the logic and messages here
| "cartesian_shape", | ||
| "date", | ||
| "date_nanos", | ||
| "double", | ||
| "geo_point", | ||
| "geo_shape", |
There was a problem hiding this comment.
Missing types for the docs
There was a problem hiding this comment.
Huh. I thought the tests would catch that.
There was a problem hiding this comment.
Mostly. We check that every type in tests appears there, but if it isn't tested, we do nothing. And Count didn't have "error types" tests to check that we tested all the types
| "ip", | ||
| "keyword", | ||
| "long", | ||
| "unsigned_long", |
There was a problem hiding this comment.
This trivially allowed unsigned longs, so just allowed it
There was a problem hiding this comment.
I mostly copied this from Values, assuming that was correct
| private static final Map<DataType, Supplier<AggregatorFunctionSupplier>> SUPPLIERS = Map.ofEntries( | ||
| Map.entry(DataType.INTEGER, ValuesIntAggregatorFunctionSupplier::new), | ||
| Map.entry(DataType.LONG, ValuesLongAggregatorFunctionSupplier::new), | ||
| Map.entry(DataType.UNSIGNED_LONG, ValuesLongAggregatorFunctionSupplier::new), |
There was a problem hiding this comment.
This trivially allowed unsigned longs, so just allowed it
| return new TypeResolution("Unresolved children"); | ||
| } | ||
| var typeResolution = isType(field(), dt -> dt != DataType.UNSIGNED_LONG, sourceText(), FIRST, "any type except unsigned_long").and( | ||
| var typeResolution = isRepresentableExceptCounters(field(), sourceText(), FIRST).and( |
There was a problem hiding this comment.
This was technically allowing counters before, but I'm not sure we actually wanted it (?)
Also, it allowed things like date period, which led to illegal data type [date_period] 500 errors
| "version", | ||
| "numeric except counter types" | ||
| ); | ||
| return isRepresentableExceptCountersAndSpatial(field(), sourceText(), DEFAULT); |
There was a problem hiding this comment.
I'm changing this list of most types to "any but counters and spatial", which should be enough here
|
|
||
| private MultiRowTestCaseSupplier() {} | ||
|
|
||
| public static List<TypedDataSupplier> nullCases(int minRows, int maxRows) { |
There was a problem hiding this comment.
Pretty weird, but I needed it to make type tests work for Count
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
jan-elastic
left a comment
There was a problem hiding this comment.
LGTM on the changes to SAMPLE
I'll leave reviewing the remainder to someone more knowledgeable about the internal data types.
| "cartesian_shape", | ||
| "date", | ||
| "date_nanos", | ||
| "double", | ||
| "geo_point", | ||
| "geo_shape", |
There was a problem hiding this comment.
Huh. I thought the tests would catch that.
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Sample.java
Continuation of #131694 (Issue: #112006)