RussellSpitzer commented on code in PR #17196:
URL: https://github.com/apache/iceberg/pull/17196#discussion_r3590879098
##########
core/src/test/java/org/apache/iceberg/avro/TestSchemaConversions.java:
##########
@@ -112,6 +112,53 @@ public void
testAvroToIcebergTimestampTypeWithoutAdjustToUTC() {
assertThat(AvroSchemaUtil.convert(avroType)).isEqualTo(expectedIcebergType);
}
+ @Test
+ public void testTimestampTypesWithLegacyMappingDisabled() {
+ String name = "timestamps";
+
+ Schema ts =
LogicalTypes.localTimestampMicros().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema tsNs =
LogicalTypes.localTimestampNanos().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema tsTz =
LogicalTypes.timestampMicros().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema tsTzNs =
LogicalTypes.timestampNanos().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema avroSchema =
+ record(
+ name,
+ requiredField(0, "ts", ts),
+ requiredField(1, "ts_ns", tsNs),
+ requiredField(2, "ts_tz", tsTz),
+ requiredField(3, "ts_tz_ns", tsTzNs));
+
+ Schema legacyTs =
LogicalTypes.timestampMicros().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema legacyTsNs =
LogicalTypes.timestampNanos().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema legacyTsTz =
LogicalTypes.timestampMicros().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema legacyTsTzNs =
+
LogicalTypes.timestampNanos().addToSchema(Schema.create(Schema.Type.LONG));
+ Schema legacyAvroSchema =
+ record(
+ name,
+ requiredField(0, "ts", addAdjustToUtc(legacyTs, false)),
+ requiredField(1, "ts_ns", addAdjustToUtc(legacyTsNs, false)),
+ requiredField(2, "ts_tz", addAdjustToUtc(legacyTsTz, true)),
+ requiredField(3, "ts_tz_ns", addAdjustToUtc(legacyTsTzNs, true)));
+
+ Types.StructType icebergSchema =
+ Types.StructType.of(
+ required(0, "ts", Types.TimestampType.withoutZone()),
+ required(1, "ts_ns", Types.TimestampNanoType.withoutZone()),
+ required(2, "ts_tz", Types.TimestampType.withZone()),
+ required(3, "ts_tz_ns", Types.TimestampNanoType.withZone()));
+
+ assertThat(AvroSchemaUtil.convert(avroSchema, false))
Review Comment:
This looks like 3 independent tests here to me. I'd split these up
--
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]