Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Jul 23, 2025

Continuation of #131694 (Issue: #112006)

  • Moved more messages from "representable" to "any type but counter types".
  • Added missing docs on Count
  • Added unsigned long and missing docs on Sample and Values
  • Fixed Sample throwing error 500 on non-representable types

@ivancea ivancea added >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.2.0 labels Jul 23, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @ivancea, I've created a changelog YAML for you.

/**
* @see DataType#isRepresentable(DataType)
*/
public static TypeResolution isRepresentableExceptCounters(Expression e, String operationName, ParamOrdinal paramOrd) {
Copy link
Contributor Author

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

Comment on lines +80 to +85
"cartesian_shape",
"date",
"date_nanos",
"double",
"geo_point",
"geo_shape",
Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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",
Copy link
Contributor Author

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

Copy link
Contributor

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),
Copy link
Contributor Author

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(
Copy link
Contributor Author

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

Copy link
Contributor

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);
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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

@ivancea ivancea marked this pull request as ready for review July 23, 2025 16:29
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Contributor

@jan-elastic jan-elastic left a 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.

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +80 to +85
"cartesian_shape",
"date",
"date_nanos",
"double",
"geo_point",
"geo_shape",
Copy link
Member

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.

@ivancea ivancea enabled auto-merge (squash) July 24, 2025 13:36
ivancea and others added 3 commits July 24, 2025 16:29
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Sample.java
@ivancea ivancea merged commit 8ab6751 into elastic:main Jul 28, 2025
33 checks passed
@ivancea ivancea deleted the esql-types-representable-message branch July 28, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants