clairemcginty commented on code in PR #1115:
URL: https://github.com/apache/parquet-java/pull/1115#discussion_r1721966099


##########
parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java:
##########
@@ -494,13 +498,25 @@ public Optional<LogicalType> 
visit(LogicalTypeAnnotation.TimeLogicalTypeAnnotati
       @Override
       public Optional<LogicalType> 
visit(LogicalTypeAnnotation.TimestampLogicalTypeAnnotation 
timestampLogicalType) {
         LogicalTypeAnnotation.TimeUnit unit = timestampLogicalType.getUnit();
-        switch (unit) {
-          case MILLIS:
-            return of(LogicalTypes.timestampMillis());
-          case MICROS:
-            return of(LogicalTypes.timestampMicros());
+        boolean isAdjustedToUTC = timestampLogicalType.isAdjustedToUTC();
+
+        if (isAdjustedToUTC) {
+          switch (unit) {
+            case MILLIS:
+              return of(LogicalTypes.timestampMillis());
+            case MICROS:
+              return of(LogicalTypes.timestampMicros());
+          }
+          return empty(); 
+        } else {
+          switch (unit) {
+            case MILLIS:
+              return of(LogicalTypes.localTimestampMillis());

Review Comment:
   FYI, this change does break compatibility with Avro 1.8 and 1.9 -- 
`LogicalTypes#localTimestamp{Millis, Micros}` weren't introduced until [Avro 
1.10](https://github.com/apache/avro/blob/release-1.10.0/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java#L184-L194)
 and are [not present in earlier 
versions](https://github.com/apache/avro/blob/release-1.9.2/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java#L158-L168).
   
   Maybe we could gate this change around a check of Avro runtime version, like 
we do 
[here](https://github.com/apache/parquet-java/blob/apache-parquet-1.14.2-rc1/parquet-avro/src/main/java/org/apache/parquet/avro/AvroRecordConverter.java#L258-L260)?
   cc @wgtmac 



-- 
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]

Reply via email to