-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Replace "representable" type error messages #131775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL: Replace "representable" type error messages #131775
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing types for the docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. I thought the tests would catch that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trivially allowed unsigned longs, so just allowed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| "version", | ||
| "numeric except counter types" | ||
| ); | ||
| return isRepresentableExceptCountersAndSpatial(field(), sourceText(), DEFAULT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty weird, but I needed it to make type tests work for Count
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on the changes to SAMPLE
I'll leave reviewing the remainder to someone more knowledgeable about the internal data types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| "cartesian_shape", | ||
| "date", | ||
| "date_nanos", | ||
| "double", | ||
| "geo_point", | ||
| "geo_shape", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)