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

Incorrect result for IS NULL for row of nulls #19444

Open
martint opened this issue Oct 19, 2023 · 3 comments
Open

Incorrect result for IS NULL for row of nulls #19444

martint opened this issue Oct 19, 2023 · 3 comments

Comments

@martint
Copy link
Member

martint commented Oct 19, 2023

Per the SQL specification section 8.8 - null predicate:

<null predicate> ::=
  <row value predicand> <null predicate part 2>
1) Let R be the <row value predicand> and let V be the value of R.
2) ...
  b) ...
    i) The value of “R IS NULL” is
      1) If the value of every field of V is the null value, then True.

Currently, Trino incorrectly returns false:

trino> select (null, null) is null;

 _col0
-------
 false
(1 row)
@sahoss
Copy link
Contributor

sahoss commented Oct 29, 2023

i'd like to explore a fix for this @martint. would that be ok?

@martint
Copy link
Member Author

martint commented Oct 29, 2023

Yes, go for it!

@sahoss
Copy link
Contributor

sahoss commented Nov 14, 2023

sharing my analysis. the incorrectness is due to a bug in the iterative optimizer rule SimplifyExpressions rewriter. adding this test case inside TestSimplifyExpressions is the way to reproduce this situation "closest" to the source of the bug.

 @Test
    public void testArrayNullPredicate() {
        assertSimplifies("(null, null) is NULL", "true");
    }

now, i am exploring how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants