Skip to content

where clause incorrectly reject NULL literal (by SQLancer-NoREC) #11248

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
2010YOUY01 opened this issue Jul 3, 2024 · 1 comment · Fixed by #11266
Closed

where clause incorrectly reject NULL literal (by SQLancer-NoREC) #11248

2010YOUY01 opened this issue Jul 3, 2024 · 1 comment · Fixed by #11266
Labels
bug Something isn't working

Comments

@2010YOUY01
Copy link
Contributor

Describe the bug

DataFusion CLI v39.0.0
> select 1 where null;
Error during planning: Cannot create filter with non-boolean predicate 'NULL' returning Null

This query should return an empty set instead of planning error:
NULL in SQL means the absence of a value, not a specific type.
In the above query, it should interpret NULL as a missing boolean value.

PostgreSQL reference:

postgres=# select 1 where null;
 ?column? 
----------
(0 rows)

DataFusion also exeucte it correctly if Null value is within a column

DataFusion CLI v39.0.0
> create table t1(v1 boolean);
0 row(s) fetched.
Elapsed 0.076 seconds.

> insert into t1 values (true),(false),(NULL);
+-------+
| count |
+-------+
| 3     |
+-------+
1 row(s) fetched.
Elapsed 0.055 seconds.

> select * from t1;
+-------+
| v1    |
+-------+
| true  |
| false |
|       |
+-------+
3 row(s) fetched.
Elapsed 0.005 seconds.

> select * from t1 where t1.v1;
+------+
| v1   |
+------+
| true |
+------+
1 row(s) fetched.
Elapsed 0.010 seconds.

Found by SQLancer's NoREC oracle #11030

To Reproduce

No response

Expected behavior

No response

Additional context

No response

@xinlifoobar
Copy link
Contributor

This seems not an easy fix... It would break about 34 sqllogictests.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants