Skip to content

API: ExpressionUtil throws ClassCastException when sanitizing bound IN/NOT_IN predicates聽#18411

Open

Description

@LuciferYang

Apache Iceberg version

1.12.0 (latest release)

Query engine

None

Please describe the bug 馃悶

Since #15224 (1.11.0), ExpressionUtil casts each element of BoundSetPredicate.literalSet() to Literal<?> when it sanitizes a bound IN or NOT_IN predicate. The set holds raw values (Long, String, ...), not literals, so any bound set predicate with two or more values throws ClassCastException.

ExpressionUtil.sanitize(Expression) and toSanitizedString(Expression) throw when they are given a bound expression. The overloads that take a StructType bind the expression first, catch the exception, and sanitize the unbound expression instead. SnapshotScan builds the scan report filter with sanitize(StructType, Expression, boolean), so a single IN in the filter turns off type-aware sanitizing for the whole filter:

Schema schema =
    new Schema(
        Types.NestedField.required(1, "id", Types.LongType.get()),
        Types.NestedField.required(2, "ts", Types.TimestampType.withoutZone()));
long ninetyMinutesAgo =
    DateTimeUtil.microsFromTimestamptz(OffsetDateTime.now().minusMinutes(90));

Expression filter =
    Expressions.and(
        Expressions.greaterThan("ts", ninetyMinutesAgo), Expressions.in("id", 1L, 2L));
ExpressionUtil.toSanitizedString(schema.asStruct(), filter, true);
// expected: (ts > (timestamp-1-hours-ago) AND id IN ((1-digit-int), (1-digit-int)))
// actual:   (ts > (16-digit-int) AND id IN ((1-digit-int), (1-digit-int)))

Without the IN, the same ts predicate is reported as (timestamp-1-hours-ago).

Willingness to contribute

  • I can contribute a fix for this bug independently

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions