You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/10/07 17:33:10 UTC

[I] API: ExpressionUtil throws ClassCastException when sanitizing bound IN/NOT_IN predicates [iceberg]

LuciferYang opened a new issue, #18411:
URL: https://github.com/apache/iceberg/issues/18411

   ### 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:
   
   ```java
   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
   
   - [x] I can contribute a fix for this bug independently
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org