ebyhr commented on code in PR #11775:
URL: https://github.com/apache/iceberg/pull/11775#discussion_r1951940306
##########
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:
Here is the problematic place in Trino:
https://github.com/trinodb/trino/blob/be9ae2f2d61aeee03352c34326416ea7e7fe1354/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/ExpressionConverter.java#L112-L121
```java
for (Range range : orderedRanges) {
if (range.isSingleValue()) {
icebergValues.add(convertTrinoValueToIceberg(type,
range.getLowBoundedValue()));
}
else {
rangeExpressions.add(toIcebergExpression(columnName,
range));
}
}
Expression ranges = or(rangeExpressions);
Expression values = icebergValues.isEmpty() ? alwaysFalse() :
in(columnName, icebergValues);
```
The `convertTrinoValueToIceberg` method returns Long (not literal) for
timestamp(9) type. The bottom `values` expression is created with Iceberg's
`Expressions.in` method.
> let Trino construct TimestampNanoLiteral and push that into the evaluator,
instead of a plain LongLiteral.
TimestampNanoLiteral and other literals' code are package-private. Let me
know if there is a method we can use from other repositories.
--
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]