elasticsearch/docs/reference/sql
Marios Trivyzas f41efd6753
SQL: Fix ORDER BY YEAR() function (#51562)
Previously, if YEAR() was used as and ORDER BY argument without being
wrapped with another scalar (e.g. YEAR(birth_date) + 10), no script
ordering was used but instead the underlying field (e.g. birth_date)
was used instead as a performance optimisation. This works correctly if
YEAR() is the only ORDER BY arg but if further args are used as tie
breakers for the ordering wrong results are produced. This is because
2 rows with the different birth_date but on the same year are not tied
as the underlying ordering is on birth_date and not on the
YEAR(birth_date), and the following ORDER BY args are ignored.

Remove this optimisation for YEAR() to avoid incorrect results in
such cases.

As a consequence another bug is revealed: scalar functions on top
of nested fields produce scripted sorting/filtering which is not yet
supported. In such cases no error was thrown but instead all values for
such nested fields were null and were passed to the script implementing
the sorting/filtering, producing incorrect results.

Detect such cases and throw a validation exception.

Fixes: #51224
2020-01-30 14:48:34 +01:00
..
appendix SQL: Implement CURRENT_TIME/CURTIME functions (#40662) 2019-04-03 19:35:37 +02:00
endpoints SQL: add support for passing query parameters in REST API calls (#51029) 2020-01-20 15:29:53 +02:00
functions SQL: handle NULL arithmetic operations with INTERVALs (#49633) 2019-12-02 16:05:05 +02:00
language Fix docs typos (#50365) 2019-12-23 10:35:14 -05:00
concepts.asciidoc [DOCS] Replaces CCS terms with attributes (#40076) 2019-03-15 07:54:45 -07:00
getting-started.asciidoc Remove types from BulkRequest (#46983) 2019-10-07 13:29:12 +01:00
index.asciidoc SQL: Spec tests now use classpath discovery (#40388) 2019-03-25 15:22:59 +02:00
limitations.asciidoc SQL: Fix ORDER BY YEAR() function (#51562) 2020-01-30 14:48:34 +01:00
overview.asciidoc SQL: remove beta marker from documentation (#38661) 2019-02-10 00:09:03 +02:00
security.asciidoc [DOCS] Remove unneeded options from [source,sql] code blocks (#42759) 2019-05-31 13:03:41 -04:00