Skip to content

Incorrect result for IS NOT NULL predicate over UNION ALL query #14352

@findepi

Description

@findepi

Describe the bug

Incorrect result for IS NOT NULL predicate over UNION ALL query

To Reproduce

SELECT
    a,
    a IS NOT NULL
FROM (
    -- second column, even though it's not selected, is necessary to reproduce this bug
    SELECT 'foo' AS a, 3 AS b
    UNION ALL
    SELECT NULL AS a, 4 AS b
)

DF

+------+---------------+
| a    | a IS NOT NULL |
+------+---------------+
| NULL | true  😱       |
| foo  | true          |
+------+---------------+

Expected behavior

NULL valued checked with IS NOT NULL should return false

trino> SELECT
    ->     a,
    ->     a IS NOT NULL
    -> FROM (
    ->     SELECT 'foo' AS a, 3 AS b
    ->     UNION ALL
    ->     SELECT NULL AS a, 4 AS b
    -> );
  a   | _col1
------+-------
 foo  | true
 NULL | false

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions