mbutrovich opened a new issue, #3822:
URL: https://github.com/apache/iceberg-rust/issues/3822

   **Apache Iceberg version**
   
   main (development)
   
   **Query engine**
   
   (leave unselected)
   
   **Please describe the bug 🐞**
   
   `UnboundPredicate.bindLiteralOperation` converts the literal to the column 
type with `Literal.to` 
([UnboundPredicate.java#L179](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/api/src/main/java/org/apache/iceberg/expressions/UnboundPredicate.java#L179)).
 Three conversions floor the value: `TimestampLiteral.to(DATE)`, 
`TimestampNanoLiteral.to(DATE)`, and `TimestampNanoLiteral.to(TIMESTAMP)` 
([Literals.java#L449-L450](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L449-L450),
 
[#L473-L476](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L473-L476)).
 Binding doesn't adjust the operator afterward 
([UnboundPredicate.java#L170-L211](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/api/src/main/java/org/apache/iceberg/expressions/UnboundPr
 edicate.java#L170-L211)), so the bound predicate matches different rows.
   
   For example, `d < TIMESTAMP '2023-01-05 12:00:00'` on a `date` column `d` 
binds to `d < DATE '2023-01-05'`. A row with `d = 2023-01-05` matches the 
original predicate, because midnight is before noon, but not the bound one. In 
the same way, `ts < 1500` nanoseconds on a `timestamp` column binds to `ts < 1` 
microsecond and drops `ts = 1`.
   
   The [expressions 
spec](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/format/expressions-spec.md?plain=1#L98)
 says "implementations must fail rather than insert unsafe casts", and 
[L127](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/format/expressions-spec.md?plain=1#L127)
 says:
   
   > If the types cannot be aligned according to type promotion rules (for 
instance, `"goats" > -Infinity`), the predicate cannot be evaluated and 
implementations must fail.
   
   Neither `timestamp` to `date` nor `timestamp_ns` to `timestamp` is in the 
[promotion 
table](https://github.com/apache/iceberg/blob/bba8c0d735bb1b4550aa6cb3e11f57ce8b7919b0/format/spec.md?plain=1#L408-L416).
 Could these three conversions return `null`, so binding throws 
`ValidationException` as it does for other unconvertible literals? iceberg-rust 
returns an error for them in apache/iceberg-rust#3574.
   
   **Willingness to contribute**
   
   - [ ] I can contribute a fix for this bug independently
   - [ ] I would be willing to contribute a fix for this bug with guidance from 
the Iceberg community
   - [x] I cannot contribute a fix for this bug at this time


-- 
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]

Reply via email to