Backlog
Labels
bugSomething isn't working
Description
Search before asking
- I searched in the issues and found nothing similar.
Version
master (table model), discovered while reviewing #19277.
Describe the bug and provide the minimal reproduce step
ExpressionAnalyzer.visitInPredicate accepts NULL in multi-value IN / NOT IN lists (since UNKNOWN is comparable with numeric and string types), and IrExpressionInterpreter keeps NullLiteral inside InListExpression.
However:
PredicateCombineIntoTableScanChecker.isInListAllLiteralreturnstruewhen the list containsNullLiteral(becauseNullLiteral instanceof Literal), pushingcol IN (20, NULL)down intoConvertPredicateToFilterVisitor.- Both
ConvertPredicateToFilterVisitor.constructInSetandcalc-commonsTypeServices.IN_MULTI_COLUMN_TRANSFORMER_SERVICEfail when encounteringNullLiteral(ClassCastExceptionon master, orSemanticExceptionafter Fix multi-value IN on INT32/INT64 fields in the table model #19277 forINT32/INT64). InMultiColumnTransformerdoes not trackhasNullfor SQL three-valued logic (x IN (20, NULL)must evaluate totruewhenx = 20andNULLwhenx != 20;x NOT IN (20, NULL)must evaluate tofalsewhenx = 20andNULLotherwise, returning no rows inWHERE).
Minimal repro:
CREATE DATABASE test_in_null;
USE test_in_null;
CREATE TABLE t(i INT32 FIELD, s STRING FIELD);
INSERT INTO t(time, i, s) VALUES (1, 20, 'a'), (2, 30, 'b'), (3, NULL, NULL);
SELECT time, i FROM t WHERE i IN (20, NULL);
SELECT time, i FROM t WHERE i NOT IN (20, NULL);
SELECT time, i IN (20, NULL) FROM t;
SELECT time, s IN ('a', NULL) FROM t;What did you expect to see?
WHERE i IN (20, NULL)returns row 1 (i = 20).WHERE i NOT IN (20, NULL)returns 0 rows.SELECT time, i IN (20, NULL)returnstruefor row 1,NULLfor rows 2 and 3.- Same three-valued logic for other data types (
INT64,STRING,DOUBLE, etc.).
What did you see instead?
Query fails with ClassCastException (or SemanticException after #19277) on NullLiteral.
Anything else?
Related to #19277 and #17053 (which focuses on CAST(NULL AS ...) predicates without TAG columns).
Are you willing to submit a PR?
- I'm willing to submit a PR!
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity