-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[ES|QL] String literal implicit casting #106932
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
Changes from all commits
ae28791
c1ca596
31d6654
66e4202
d33a18b
e8ce087
b96be99
55a8f30
21819de
d61ef8d
f99d040
1314c32
b81d62a
37ee143
1bd84bb
3473df2
a5af576
14f6061
d3d1e8c
84e2412
aed668c
6b6ac05
b6eae98
905102e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,6 @@ | |
| |=== | ||
| field | buckets | from | to | result | ||
| datetime | integer | datetime | datetime | datetime | ||
| datetime | integer | datetime | keyword | datetime | ||
| datetime | integer | datetime | text | datetime | ||
| datetime | integer | keyword | datetime | datetime | ||
| datetime | integer | keyword | keyword | datetime | ||
| datetime | integer | keyword | text | datetime | ||
| datetime | integer | text | datetime | datetime | ||
| datetime | integer | text | keyword | datetime | ||
| datetime | integer | text | text | datetime | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting. We no longer tell folks they can use strings here, only dates. But maybe a human is ok because the examples will contain string literals.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct, though? The function does accept the string types (the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the implicit casting is done at resolution phase. We can do auto casting if the string literals are provided as input to the bucket function directly, e.g. However, if the string literals are provided as input to the bucket function through a variable, auto casting does not apply, e.g. This is the main reason that there are still code inside to function to do the conversion, as the foldable eval propagation happens at logical planner. We have some options to make auto casting work better, like:
There are some follow up work related to the auto casting. A lot(perhaps most) of the rules in analyzer and logical planner are related to query transformation, there are chances that we can rearrange the rules to make resolution and query transformation work more effectively.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As to whether this is right or not, I dunno. You certainly can only put date-like-strings in it. And now that we support implicit conversion for these literals everywhere where this list says "date" it means "date or date-like-string". I dunno.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure, that's fine. I was mostly commenting on adjusting the function info to remove the |
||
| double | integer | double | double | double | ||
| double | integer | double | integer | double | ||
| double | integer | double | long | double | ||
|
|
||
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.
@drewdaemon I've just realized you'll need this too. Here's the deal - we have automatic promotion of string literals. For this particular function these always had to be literals anyway so we no longer think of these as valid signatures.
This is an interesting wrinkle. We don't send anything telling you this has to be a literal. We probably should.
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.
@nik9000 thanks for thinking of us! Yes, we currently have this information hard-coded on our end. If there's a way to surface this in the definitions y'all provide us... all the better!
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.
We could generate something like:
Or something like that. But in general if something says
datetimenow it can take a literal string that is formatted like a date. Same for numbers. But that's quite a lot to add to your editor, especially right now.There are other cases where we send you
"only_literals": "any"for bits that take any literal. Thebucketsparameter here only takes literalintegers. No fields allowed.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.
Yeah, this kind of thing would be great. I have put elastic/kibana#179634 a bit on hold while I squish editor bugs for the 8.14 release. Once that settles down, I'm going to work on pulling these generated definitions into Kibana "for real."
At that point, I think I'll have a clearer understanding of exactly what structure would work best.
Noted, thanks!