nastra commented on code in PR #16881:
URL: https://github.com/apache/iceberg/pull/16881#discussion_r3457699903
##########
core/src/main/java/org/apache/iceberg/avro/GenericAvroReader.java:
##########
@@ -173,67 +173,50 @@ public ValueReader<?> variant(
public ValueReader<?> primitive(Type partner, Schema primitive) {
LogicalType logicalType = primitive.getLogicalType();
if (logicalType != null) {
- switch (logicalType.getName()) {
- case "date":
+ return switch (logicalType.getName()) {
// Spark uses the same representation
- return ValueReaders.ints();
-
- case "time-micros":
- return ValueReaders.longs();
-
- case "timestamp-millis":
+ case "date" -> ValueReaders.ints();
+ case "time-micros" -> ValueReaders.longs();
+ case "timestamp-millis" -> {
// adjust to microseconds
ValueReader<Long> longs = ValueReaders.longs();
- return (ValueReader<Long>) (decoder, ignored) ->
longs.read(decoder, null) * 1000L;
-
- case "timestamp-micros":
- case "timestamp-nanos":
- // both are handled in memory as long values, using the type to
track units
- return ValueReaders.longs();
-
- case "decimal":
- return ValueReaders.decimal(
- ValueReaders.decimalBytesReader(primitive),
- ((LogicalTypes.Decimal) logicalType).getScale());
-
- case "uuid":
- return ValueReaders.uuids();
-
- default:
- throw new IllegalArgumentException("Unknown logical type: " +
logicalType);
- }
+ yield (ValueReader<Long>) (decoder, ignored) ->
longs.read(decoder, null) * 1000L;
Review Comment:
can be simplified to
```
case "timestamp-millis" -> // adjust to microseconds
(decoder, ignored) -> ValueReaders.longs().read(decoder, null)
* 1000L;
```
--
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]