OpenSearch/x-pack/plugin
Marios Trivyzas f373020349 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
(cherry picked from commit f41efd6753dc3650a7eabb3e07b02b3b32c5704c)
2020-01-30 15:29:36 +01:00
..
analytics Begin moving date_histogram to offset rounding (take two) (#51271) (#51495) 2020-01-27 13:40:54 -05:00
autoscaling Initial autoscaling commit (#51161) 2020-01-17 15:31:12 -05:00
ccr Allow Repository Plugins to Filter Metadata on Create (#51472) (#51542) 2020-01-28 18:33:26 +01:00
core Add new 'maintenance' index privilege #50643 2020-01-30 11:59:11 +02:00
deprecation Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
enrich Formatting: keep simple if / else on the same line (#51544) 2020-01-29 10:42:04 +00:00
eql EQL: Enable QA/rest integration tests for snapshot builds only (#51624) (#51645) 2020-01-29 16:38:52 -05:00
frozen-indices Do not wrap soft-deletes reader for segment stats (#51331) 2020-01-23 08:43:06 -05:00
graph Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
ilm [TEST] Mute TimeSeriesLifecycleActionsIT.testWaitForSnapshotSlmExecutedBefore 2020-01-29 13:08:55 +01:00
logstash Deprecate creation of dot-prefixed index names except for hidden and system indices (#49959) 2020-01-28 10:01:16 -07:00
mapper-flattened Add telemetry for flattened fields. (#48972) (#49125) 2019-11-18 12:29:42 -08:00
ml [ML] Fix possible race condition starting datafeed (#51646) 2020-01-30 08:23:45 +01:00
monitoring Add max_resource_units to enterprise license (#50910) 2020-01-14 12:37:05 +11:00
ql SQL: Fix ORDER BY YEAR() function (#51562) 2020-01-30 15:29:36 +01:00
rollup Use more specific loggers in subclasses of TMNA (#50076) 2019-12-11 15:07:47 +00:00
search-business-rules Fix NPE in PinnedQuery call to DisjunctionMaxScorer. (#51047) (#51064) 2020-01-16 10:41:43 +00:00
security Add new 'maintenance' index privilege #50643 2020-01-30 11:59:11 +02:00
spatial Geo: Switch generated GeoJson type names to camel case (#50400) 2019-12-20 15:37:22 -05:00
sql SQL: Fix ORDER BY YEAR() function (#51562) 2020-01-30 15:29:36 +01:00
src/test Add new 'maintenance' index privilege #50643 2020-01-30 11:59:11 +02:00
transform Deprecate creation of dot-prefixed index names except for hidden and system indices (#49959) 2020-01-28 10:01:16 -07:00
vectors Increase the number of vector dims to 2048 (#46895) 2019-11-20 07:47:33 -05:00
voting-only-node Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
watcher The watcher indexing listener didn't handle document level exceptions. (#51466) 2020-01-29 12:55:02 +01:00
build.gradle Formalize build snapshot (#51484) 2020-01-27 16:56:31 -05:00