Fokko commented on code in PR #11775:
URL: https://github.com/apache/iceberg/pull/11775#discussion_r1951168267
##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -300,8 +300,7 @@ public <T> Literal<T> to(Type type) {
case TIMESTAMP:
return (Literal<T>) new TimestampLiteral(value());
case TIMESTAMP_NANO:
- // assume micros and convert to nanos to match the behavior in the
timestamp case above
- return new TimestampLiteral(value()).to(type);
+ return (Literal<T>) new TimestampNanoLiteral(value());
Review Comment:
Sorry, the example I gave was not the best one. Previous to V3, Iceberg did
not have nanoseconds, so therefore we have the assumption that every long we
see, is in microseconds. Otherwise, the following query would change:
```sql
CREATE TABLE tbl(ts timestamp);
-- We want to have all the events from the future
SELECT * FROM tbl WHERE ts > 1739288553127 -- this is interpreted as
microseconds
-- We need more precision
ALTER TABLE tbl MODIFY COLUMN ts timestamp_ns
SELECT * FROM tbl WHERE ts > 1739288553127t -- this is interpreted as
nanoseconds, changing the result
```
The trick here is to let Trino construct `TimestampNanoLiteral` and push
that into the evaluator, instead of a plain `LongLiteral`.
--
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]