-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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: Mark counter fields as unsupported #99054
Conversation
This marks TSDB's `counter` fields as unsupported by ESQL. We'll support them eventually, but in the short term we were just treating them like their underlying numeric type and that's not great. They have a conceptually different meaning that we'd like to respect one day. So, for now, we'll mark them unsupported.
Pinging @elastic/es-ql (Team:QL) |
Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL) |
Hi @nik9000, I've created a changelog YAML for you. |
@astefan, I'm not sure of a good way to unit test this thing. Do you have any ideas? |
@@ -19,7 +21,7 @@ public interface DataTypeRegistry { | |||
// | |||
Collection<DataType> dataTypes(); | |||
|
|||
DataType fromEs(String typeName); |
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 would try to make this a bit more generic, ie instead of specifically looking at TimeSeriesParams.MetricType
I'd try to use the FieldCapabilities instance itself from where I could extract whatever information necessary to decide the supportability of a data type. Another suggestion is to look into defining a second fromEs
method that receives this FieldCapabilities
parameter and keep the original one unchanged.
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.
When the IndexResolver
has been created the field_caps API didn't return such additional information and I am not seeing any less intrusive way to support this other than what you suggested.
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'd be worried about keeping the original one unchanged because it's kind of dangerous, at least in ESQL it is. But I'm happy to move the whole field caps response there.
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 stumbling over the same issue - how about encoding the TIME_SERIES_METRIC_PARAM inside the name along with its value, as a suffix for example?
This convention avoids having to extend the static method and can handle in the future more parameter or special types outside the metric ones without having to extend the method yet again.
For example when dealing with a timeseries metric type, append that to the typeName itself and then check in EsqlDataType if the typeName ends up TIME_SERIES_METRIC_PARAM-COUNTER
.
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.
Adding it to the string feels easy to break. It'd be even more likely for folks to accidentally not use the metric param.
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 looked at taking the whole FieldCapabilities
object but there is a place we don't have it - in the mapping walking code. I'm not sure it's worth trying to get it there when adding the smaller parameter works.
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.
How about adding a generic object as field context instead of typing it to TimeSeriesParams.MetricType and doing an instanceof check?
It is not OOP-ish but in this case we're looking at a bag properties for fields vs just the name.
For example how about DataType fromEs(String typeName, Object typeContext)
and then in ESQL do:
if (typeContext ==TimeSeriesParams.MetricType.COUNTER)) {
...
}
I'd like to avoid us to add a new param for each special type on the method signature and instead use a "bucket" type approach.
If you're on the fence, we can merge the PR and revisit this in the future.
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 get where your coming from. My preference would be to merge as is and then, when we got to add the next "funny" parameter, we do something like:
record FromEs(String typeName, TimeSeriesParams.MetricType metricType, TheNewThing newThing) {}
DataType fromEs(FromEs fromEs) {
If it feels sensible then. I don't feel like we need something so fancy for two fields. But three or our we really may.
Regarding unit testing, there is |
I saw that! I thought "oh, I can copy this into the |
+1 for not allowing counter fields in esql for now. |
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 a comment with my preference, I'll leave it up to you on how to move forward.
@astefan could you have a look at this one again? I'm not sure about pushing the whole |
This marks TSDB's `counter` fields as unsupported by ESQL. We'll support them eventually, but in the short term we were just treating them like their underlying numeric type and that's not great. They have a conceptually different meaning that we'd like to respect one day. So, for now, we'll mark them unsupported.
This marks TSDB's
counter
fields as unsupported by ESQL. We'll support them eventually, but in the short term we were just treating them like their underlying numeric type and that's not great. They have a conceptually different meaning that we'd like to respect one day. So, for now, we'll mark them unsupported.