You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/11/09 20:48:52 UTC
[GitHub] [iceberg] joao-parana opened a new issue, #6164: The Literals class does not handle literals of type LocalDateTime. This causes errors in expressions involving Timestamp.
joao-parana opened a new issue, #6164:
URL: https://github.com/apache/iceberg/issues/6164
### Apache Iceberg version
1.0.0 (latest release)
### Query engine
_No response_
### Please describe the bug 🐞
The `Literals` class of the `org.apache.iceberg.expressions` package does not handle literals of type `LocalDateTime`.
https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L59
So a predicate like the one below, in a filter in a Java program, generates an error.
```java
LocalDateTime beginInterval = getLocalDateTimeFromSecondsEpoch(1668023502L);
LocalDateTime endInterval = getLocalDateTimeFromSecondsEpoch(1669668837L);
Expression predicate = Expressions.and(
Expressions.greaterThanOrEqual("ts", beginInterval),
Expressions.lessThanOrEqual("ts", endInterval)
);
```
Error:
```text
java.lang.IllegalArgumentException: Cannot create expression literal from java.time.LocalDateTime: 2022-11-09T20:19:30.023502
at org.apache.iceberg.expressions.Literals.from(Literals.java:86)
```
`ts` is an attribute of type `Types.TimestampType.withoutZone()` in my **Schema**.
```java
Schema schema = new Schema(
required(1, "ts", Types.TimestampType.withoutZone()),
. . .
);
```
Is there another way to specify a predicate to select data in a given time interval? The question concerns Iceberg's Java API (modules: api, core, data).
**Note**: I am using type `Types.TimestampType.withoutZone()` to allow partitioning the table using the `month("ts")` transform function.
--
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
[GitHub] [iceberg] RussellSpitzer commented on issue #6164: The Literals class does not handle literals of type LocalDateTime. This causes errors in expressions involving Timestamp.
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on issue #6164:
URL: https://github.com/apache/iceberg/issues/6164#issuecomment-1310882642
Timestamp expressions can be created as in this test case
https://github.com/apache/iceberg/blob/master/core/src/test/java/org/apache/iceberg/expressions/TestExpressionParser.java#L71
```Expressions.equal("ts", "2022-08-14T10:00:00.123456")```
If you look into Literals.java, Translations are available to timestamp from
Long (microseconds from epoch)
https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L300-L301
or
String
https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L503-L516
--
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
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
[GitHub] [iceberg] joao-parana commented on issue #6164: The Literals class does not handle literals of type LocalDateTime. This causes errors in expressions involving Timestamp.
Posted by GitBox <gi...@apache.org>.
joao-parana commented on issue #6164:
URL: https://github.com/apache/iceberg/issues/6164#issuecomment-1317670657
Thanks @RussellSpitzer, I made the changes below and it worked. I'm closing the issue.
```java
Long beginInterval = 1368023502001001L);
Long endInterval = 1731171440001001L);
Expression predicate = Expressions.and(
Expressions.greaterThanOrEqual("ts", beginInterval),
Expressions.lessThanOrEqual("ts", endInterval)
);
```
--
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
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
[GitHub] [iceberg] joao-parana closed issue #6164: The Literals class does not handle literals of type LocalDateTime. This causes errors in expressions involving Timestamp.
Posted by GitBox <gi...@apache.org>.
joao-parana closed issue #6164: The Literals class does not handle literals of type LocalDateTime. This causes errors in expressions involving Timestamp.
URL: https://github.com/apache/iceberg/issues/6164
--
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
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