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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]