Skip to content

[Bug] [Table model] Multi-value IN containing NULL literal fails instead of following SQL three-valued logic #19437

Backlog

Description

@JackieTien97

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:

  1. PredicateCombineIntoTableScanChecker.isInListAllLiteral returns true when the list contains NullLiteral (because NullLiteral instanceof Literal), pushing col IN (20, NULL) down into ConvertPredicateToFilterVisitor.
  2. Both ConvertPredicateToFilterVisitor.constructInSet and calc-commons TypeServices.IN_MULTI_COLUMN_TRANSFORMER_SERVICE fail when encountering NullLiteral (ClassCastException on master, or SemanticException after Fix multi-value IN on INT32/INT64 fields in the table model #19277 for INT32/INT64).
  3. InMultiColumnTransformer does not track hasNull for SQL three-valued logic (x IN (20, NULL) must evaluate to true when x = 20 and NULL when x != 20; x NOT IN (20, NULL) must evaluate to false when x = 20 and NULL otherwise, returning no rows in WHERE).

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) returns true for row 1, NULL for 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!

Activity

  1. added
    bug
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions