Skip to content

[Bug] [Table model] Multi-value IN with non-literal expressions uses wrong row index in isNull check and narrows/truncates numeric values #19435

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

When a multi-value IN predicate in the table model contains any non-literal expression (e.g. another column, arithmetic expression, or non-folded CAST), ColumnTransformerBuilder.visitInPredicate puts the non-literal items into valueColumnTransformerList and evaluates them in In*MultiColumnTransformer.satisfy(List<Column> childrenColumns, int index).

There are two bugs in these transformers:

  1. Wrong index passed to isNull(...) in all six In*MultiColumnTransformer subclasses:

    • InInt32MultiColumnTransformer.java:48
    • InInt64MultiColumnTransformer.java:48
    • InFloatMultiColumnTransformer.java:48
    • InDoubleMultiColumnTransformer.java:48
    • InBinaryMultiColumnTransformer.java:49
    • InBooleanMultiColumnTransformer.java:48

    Every subclass checks if (!valueColumn.isNull(i)) (using the operand loop variable i) instead of if (!valueColumn.isNull(index)) (the row index). When a TsBlock has positionCount <= i (for example, a 1-row block with a single non-literal item at i = 1), valueColumn.isNull(1) throws ArrayIndexOutOfBoundsException; otherwise it reads the NULL flag of the wrong row.

  2. Unchecked narrowing, truncation, and saturation for mixed-type numeric expressions in InInt32MultiColumnTransformer and InInt64MultiColumnTransformer:

    • InInt32MultiColumnTransformer.java:50 calls valueType.getInt(valueColumn, index):
      • An INT64 column value outside INT32 range wraps via (int) (e.g. 4294967326 wraps to 30).
      • A DOUBLE/FLOAT expression truncates toward zero via (int) (e.g. 29.5 truncates to 29).
    • InInt64MultiColumnTransformer.java:50 calls valueType.getLong(valueColumn, index):
      • A DOUBLE/FLOAT expression truncates toward zero (29.5 -> 29) and saturates >= 2^63 onto Long.MAX_VALUE.

Minimal repro:

CREATE DATABASE test_in_expr;
USE test_in_expr;
CREATE TABLE t(i INT32 FIELD, l INT64 FIELD, d DOUBLE FIELD);
INSERT INTO t(time, i, l, d) VALUES (1, 30, 4294967326, 30.5);
INSERT INTO t(time, i, l, d) VALUES (2, 29, 9223372036854775807, 9223372036854775808.0);

-- Wrongly matches row 1 because 4294967326 narrows to 30
SELECT time, i FROM t WHERE i IN (20, l);

-- Wrongly matches both rows because i + 0.5 truncates to i
SELECT time, i FROM t WHERE i IN (20, i + 0.5);

-- Wrongly matches row 2 because 9223372036854775808.0 saturates to Long.MAX_VALUE
SELECT time, l FROM t WHERE l IN (0, d);

What did you expect to see?

  • isNull(index) is checked for the current row rather than the operand index i.
  • Non-literal numeric items in IN lists follow the same exact comparison semantics as =: out-of-range integers, non-integral floating-point values, and >= 2^63 doubles do not match INT32/INT64 values.

What did you see instead?

  • ArrayIndexOutOfBoundsException on short blocks (e.g. 1-row TsBlock) or wrong NULL handling when evaluating non-literal IN items.
  • False matches due to (int)/(long) narrowing, truncation, and saturation in InInt32MultiColumnTransformer and InInt64MultiColumnTransformer.

Anything else?

Related to #19276 / #19277, which fixes literal-only multi-value IN lists on INT32/INT64 fields.
Note also that InMultiColumnTransformer currently returns false instead of NULL when a non-literal candidate evaluates to NULL and no other item matches (SQL three-valued logic for IN/NOT IN).

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