RussellSpitzer commented on code in PR #17196:
URL: https://github.com/apache/iceberg/pull/17196#discussion_r3591059190
##########
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:
I didn't review the other tests :) but let's take a deeper look
Well if we really look into this we have two tests.
1. Roundtrip on the schema
2. Test of oneway legacy schema conversion to Iceberg
The "roundtrip test" here is redundant with the "testPrimitiveTypes" round
trip testing above. So we can drop that entirely and make sure it's covered
above. Then this keeps the one-way test and trims it down to just the
legacyAvroSchema => icebergSchema
--
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]