Commit f7e61de
committed
[ES|QL] implicit casting changes (#182989)
## Summary
This is a follow-on from
elastic/elasticsearch#107859.
Two main changes to our client-side validation code.
1. comparison operators like `==` and `>=` now support implicit casting
from strings for `version`, `ip`, and `boolean` types
2. `in` and `not in` operators support implicit casting from strings for
`version`, `ip`, `boolean`, and `date` constants. To address this
quickly, I have disabled type-checking for array values (e.g. `in (
version_field, "1.2.3", "2.3.1" )`) because our parameter typing system
does not currently support arrays of mixed types which it will need to
in order to re-enable checking while allowing string literals. I have
added this to #177699
### A note on testing
These implicit casting changes may not be on the latest Elasticsearch
snapshot. Instead, check out the `8.14` branch in a local Elasticsearch
repo and run `yarn es source --source-path='path/to/elasticsearch'`
See [these
tests](https://github.com/elastic/kibana/pull/182989/files#diff-89c4af0faedcf80d51cfb19ae397a5898c7293055b19284a94cb3f6a7cd4d071R1727-R1763)
for a set of good use cases to try. `to_<type>` functions can be used if
the sample data doesn't contain a field of the type you want to test.
### A note on string to date casting
In #182856 we started accepting
string literals for any function arguments that are dates.
By the same logic, `"2022" - 1 day` would work, so our validator doesn't
complain about it. However, it currently fails at the Elasticsearch
level.
In a discussion with Fang, we determined that this is a
valid use case, so I have created
elastic/elasticsearch#108432 and determined
not to tighten the client-side validation since this seems more like a
casting "hole" that will soon be filled in on the ES side (though not in
8.14).
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or
(cherry picked from commit c3e1027)1 parent a14ee25 commit f7e61de
4 files changed
Lines changed: 2638 additions & 1071 deletions
File tree
- packages/kbn-esql-validation-autocomplete/src
- definitions
- validation
Lines changed: 74 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
95 | 110 | | |
96 | 111 | | |
97 | 112 | | |
| |||
214 | 229 | | |
215 | 230 | | |
216 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
217 | 247 | | |
218 | 248 | | |
219 | 249 | | |
| |||
232 | 262 | | |
233 | 263 | | |
234 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
235 | 280 | | |
236 | 281 | | |
237 | 282 | | |
| |||
318 | 363 | | |
319 | 364 | | |
320 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
321 | 375 | | |
322 | 376 | | |
323 | 377 | | |
| |||
327 | 381 | | |
328 | 382 | | |
329 | 383 | | |
330 | | - | |
| 384 | + | |
| 385 | + | |
331 | 386 | | |
332 | 387 | | |
333 | 388 | | |
334 | 389 | | |
335 | 390 | | |
336 | 391 | | |
337 | | - | |
| 392 | + | |
338 | 393 | | |
339 | 394 | | |
340 | 395 | | |
341 | 396 | | |
342 | 397 | | |
343 | 398 | | |
344 | | - | |
| 399 | + | |
345 | 400 | | |
346 | 401 | | |
347 | 402 | | |
348 | 403 | | |
349 | 404 | | |
350 | 405 | | |
351 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
352 | 421 | | |
353 | 422 | | |
354 | 423 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
| 560 | + | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| |||
0 commit comments