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
SQL: Wrong Null folding of functions and operators. #35872
Labels
Comments
Pinging @elastic/es-search |
matriv
added a commit
to matriv/elasticsearch
that referenced
this issue
Jan 3, 2019
Logical operators `OR` and `AND` as well as conditional functions (`COALESCE`, `LEAST`, `GREATEST`, etc.) cannot be folded to NULL if one of their children is NULL as is the case for most of the functions. Therefore, their `nullable()` implementation cannot return `true`. On the other hand they cannot return `false` as if they're wrapped within an `IS NULL` or `IS NOT NULL` expression, the expression will be folded to `false` and `true` respectively leading to wrong results. Change the signature of `nullable()` method and add a third value `UKNOWN` to handle these cases. Fixes: elastic#35872
matriv
added a commit
that referenced
this issue
Jan 6, 2019
Logical operators OR and AND as well as conditional functions (COALESCE, LEAST, GREATEST, etc.) cannot be folded to NULL if one of their children is NULL as is the case for most of the functions. Therefore, their nullable() implementation cannot return true. On the other hand they cannot return false as if they're wrapped within an IS NULL or IS NOT NULL expression, the expression will be folded to false and true respectively leading to wrong results. Change the signature of nullable() method and add a third value UKNOWN to handle these cases. Fixes: #35872
matriv
added a commit
that referenced
this issue
Jan 6, 2019
Logical operators OR and AND as well as conditional functions (COALESCE, LEAST, GREATEST, etc.) cannot be folded to NULL if one of their children is NULL as is the case for most of the functions. Therefore, their nullable() implementation cannot return true. On the other hand they cannot return false as if they're wrapped within an IS NULL or IS NOT NULL expression, the expression will be folded to false and true respectively leading to wrong results. Change the signature of nullable() method and add a third value UKNOWN to handle these cases. Fixes: #35872
matriv
added a commit
that referenced
this issue
Jan 6, 2019
Logical operators OR and AND as well as conditional functions (COALESCE, LEAST, GREATEST, etc.) cannot be folded to NULL if one of their children is NULL as is the case for most of the functions. Therefore, their nullable() implementation cannot return true. On the other hand they cannot return false as if they're wrapped within an IS NULL or IS NOT NULL expression, the expression will be folded to false and true respectively leading to wrong results. Change the signature of nullable() method and add a third value UKNOWN to handle these cases. Fixes: #35872
matriv
added a commit
that referenced
this issue
Jan 6, 2019
Logical operators OR and AND as well as conditional functions (COALESCE, LEAST, GREATEST, etc.) cannot be folded to NULL if one of their children is NULL as is the case for most of the functions. Therefore, their nullable() implementation cannot return true. On the other hand they cannot return false as if they're wrapped within an IS NULL or IS NOT NULL expression, the expression will be folded to false and true respectively leading to wrong results. Change the signature of nullable() method and add a third value UKNOWN to handle these cases. Fixes: #35872
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
COALESCE
but also other functions and operators (e.g.:AND
,OR
) returnfalse
in theirnullable()
implementation. Therefore if they are nested insideIS NULL
orIS NOT NULL
, theFoldNull()
rule will wrongly fold them tofalse
andtrue
respectively.Here is an example of a query that because of the folding returns wrong results:
returns empty list:
but it should return:
The text was updated successfully, but these errors were encountered: