Skip to content
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

Add support for numeric range keys #56452

Merged
merged 4 commits into from
May 11, 2020
Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented May 8, 2020

This adds support for parsing numbers as range keys. They get converted
into a string, but we allow numbers.

While I was there I replaced the parser for Range with a
ConstructingObjectParser which will automatically add support for "did
you mean" style corrections on errors.

Closes #56402

This adds support for parsing numbers as range keys. They get converted
into a string, but we allow numbers.

While I was there I replaced the parser for `Range` with a
`ConstructingObjectParser` which will automatically add support for "did
you mean" style corrections on errors.

Closes elastic#56402
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 8, 2020
Copy link
Contributor

@polyfractal polyfractal left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Shame the ctor has that double/string duality, but low on the priority list of grievances to fix (hooray over-used inheritance patterns) :)

@@ -128,50 +132,6 @@ public String toString() {
return "[" + from + " to " + to + ")";
}

public static Range fromXContent(XContentParser parser) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Begone, foul parser!

@@ -63,6 +67,14 @@
protected final double to;
protected final String toAsStr;

public Range(String key, Double from, String fromAsStr, Double to, String toAsStr) {
Copy link
Contributor

@polyfractal polyfractal May 11, 2020

Choose a reason for hiding this comment

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

I wonder if we should add a guard here to throw an exception if from/fromAsStr and to/toAsStr are both non-null/non-empty/not infinity? Looks like we previously were just assuming the user gave us the right combination... i'm assuming we use these preferentially later (e.g. toAsStr if non-null, to otherwise or something like that)

Or if it turns out to be a big mess, at least a javadoc explaining the priority? Or make it package-private if possible? Not sure where else it's used though

Copy link
Member Author

Choose a reason for hiding this comment

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

It is used in a few places, yeah. I believe the best I can do is describe the priority. I'll do that.

@nik9000 nik9000 merged commit 4ee58fa into elastic:master May 11, 2020
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request May 11, 2020
This adds support for parsing numbers as range keys. They get converted
into a string, but we allow numbers.

While I was there I replaced the parser for `Range` with a
`ConstructingObjectParser` which will automatically add support for "did
you mean" style corrections on errors.

Closes elastic#56402
nik9000 added a commit that referenced this pull request May 11, 2020
This adds support for parsing numbers as range keys. They get converted
into a string, but we allow numbers.

While I was there I replaced the parser for `Range` with a
`ConstructingObjectParser` which will automatically add support for "did
you mean" style corrections on errors.

Closes #56402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregation key can't be number
4 participants