Skip to content

SQL: CASTing passes instead of throwing an exception #50191

@astefan

Description

@astefan

SELECT (CAST('bla' AS DATE) IS NOT NULL)

yields

CAST('bla' AS DATE) IS NOT NULL
-------------------------------
true    

But running SELECT CAST('bla' AS DATE) throws an (expected) exception:

                "type": "sql_illegal_argument_exception",
                "reason": "cannot cast [bla] to [date]: Text 'bla' could not be parsed at index 0"

In reality, both cases should have thrown the sql_illegal_argument_exception. In the first case, though, bla is evaluated as not being null and the optimizer is already returning TRUE for IS NOT NULL.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions