Freedomfirebody opened a new issue, #9431:
URL: https://github.com/apache/iceberg/issues/9431
### Apache Iceberg version
1.3.0
### Query engine
None
### Please describe the bug 🐞
When tried to use the `java.time.OffsetDateTime` value at the next scan
filter like `Expressions.lessThan("storage_time",
LocalDateTime.now().atOffset(ZoneOffset.UTC))`, then got an exception that is
below:
```
java.lang.IllegalArgumentException: Cannot create expression literal from
java.time.OffsetDateTime
```
And tried to use `Expressions.greaterThan("storage_time",
LocalDateTime.now().atOffset(ZoneOffset.UTC).toString())`, then it works
without exception but gets empty. The table has records from 12/01/2023 to now.
1. It should be a bug, `java.time.OffsetDateTime` and other similar values
should work. That literal class exists in
`org.apache.iceberg.expressions.ExpressionUtil.sanitize(org.apache.iceberg.expressions.Literal<?>,
long, int)`
2. Why I using `java.time.OffsetDateTime` as a filter, that gets empty? When
I comment on the filter, then it works and gets all records. It may be another
bug?
The following is part of the source code
```java
public static void create(HadoopCatalog hadoopCatalog, TableIdentifier
identifier) {
Schema schema = new Schema(
Types.NestedField.required(1, "id", Types.IntegerType.get()),
Types.NestedField.required(2, "storage_time",
Types.TimestampType.withZone()),
Types.NestedField.required(3, "message", Types.StringType.get()),
Types.NestedField.optional(4, "call_stack",
Types.ListType.ofRequired(5, Types.StringType.get()))
);
PartitionSpec spec = PartitionSpec.builderFor(schema)
.day("event_time")
.identity("id")
.build();
Map<String, String> properties = new HashMap<>();
Table table = hadoopCatalog.createTable(identifier, schema, spec,
properties);
}
public static void read(HadoopCatalog hadoopCatalog, TableIdentifier
identifier) {
try (CloseableIterable<Record> result = IcebergGenerics.read(table)
//.where(Expressions.greaterThan("event_time",
LocalDateTime.now().atOffset(ZoneOffset.UTC)))
.where(Expressions.lessThan("storage_time",
"2024-01-04T07:43:44.934813Z"))
.build()) {
for (Record r : result) {
System.out.println("=========================");
System.out.println(r);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
```
--
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]