Skip to content
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: Fix issue with CAST and NULL checking. #50371

Merged
merged 2 commits into from
Dec 19, 2019
Merged

Commits on Dec 19, 2019

  1. SQL: Fix issue with CAST and NULL checking.

    Previously, during expression optimization, 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, so it returns Nullability.TRUE.
    
    Fixes: elastic#50191
    matriv committed Dec 19, 2019
    Configuration menu
    Copy the full SHA
    6962f14 View commit details
    Browse the repository at this point in the history
  2. add tests to verify exception

    matriv committed Dec 19, 2019
    Configuration menu
    Copy the full SHA
    acce148 View commit details
    Browse the repository at this point in the history