OpenSearch/x-pack/plugin/sql
Marios Trivyzas f1a6b675f7 SQL: Fix issue with CAST and NULL checking. (#50371)
Previously, during expression optimisation, CAST would be considered
nullable if the casted expression resulted to a NULL literal, and would
be always non-nullable otherwise. As a result if CASE was wrapped by a
null check function like IS NULL or IS NOT NULL it was simplified to
TRUE/FALSE, eliminating the actual casting operation. So in case of an
expression with an erroneous casting like CAST('foo' AS DATETIME) IS NULL
it would be simplified to FALSE instead of throwing an Exception signifying
the attempt to cast 'foo' to a DATETIME type.

CAST now always returns Nullability.UKNOWN except from the case that
its result evaluated to a constant NULL, where it returns Nullability.TRUE.
This way the IS NULL/IS NOT NULL don't get simplified to FALSE/TRUE
and the CAST actually gets evaluated resulting to a thrown Exception.

Fixes: #50191
(cherry picked from commit 671e07a931cd828661e226cba22a5d38804a17a5)
2019-12-20 10:24:35 +02:00
..
jdbc Handle NULL in ResultSet's getDate() method (#50184) 2019-12-17 10:03:23 +02:00
qa Geo: Switch generated WKT to upper case (#50285) 2019-12-18 17:29:08 -05:00
sql-action upgrade to lucene 8.4.0-snapshot-08b8d116f8f (#50129) (#50132) 2019-12-12 13:13:37 +01:00
sql-cli Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
sql-client Clean up static web server in sql-client tests (#49187) (#49197) 2019-11-15 13:02:21 -07:00
sql-proto Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
src SQL: Fix issue with CAST and NULL checking. (#50371) 2019-12-20 10:24:35 +02:00
build.gradle Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00