-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Conversation
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
Pinging @elastic/es-analytics-geo (:Analytics/Aggregations) |
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, 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 { |
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.
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) { |
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 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
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.
It is used in a few places, yeah. I believe the best I can do is describe the priority. I'll do that.
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
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 aConstructingObjectParser
which will automatically add support for "didyou mean" style corrections on errors.
Closes #56402