HuangZhenQiu commented on code in PR #23511: URL: https://github.com/apache/flink/pull/23511#discussion_r1461426662
########## flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDataDeSerializationSchemaTest.java: ########## @@ -330,23 +338,87 @@ void testSerializationWithTypesMismatch(AvroEncoding encoding) throws Exception .hasStackTraceContaining("Fail to serialize at field: f1"); } + @Test + void testTimestampTypeLegacyMapping() throws Exception { + final Tuple4<Class<? extends SpecificRecord>, SpecificRecord, GenericRecord, Row> testData = + AvroTestUtils.getTimestampTestData(); + + SpecificDatumWriter<Timestamps> datumWriter = new SpecificDatumWriter<>(Timestamps.class); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + Encoder encoder = EncoderFactory.get().binaryEncoder(byteArrayOutputStream, null); + datumWriter.write((Timestamps) testData.f1, encoder); + encoder.flush(); + + DataType dataType = + AvroSchemaConverter.convertToDataType( + SpecificData.get().getSchema(Timestamps.class).toString()); + + // Timestamp with local timezone is converted to BigIntType + assertThat(dataType.getChildren().get(2)) + .isEqualTo(new AtomicDataType(new BigIntType(false))); + assertThat(dataType.getChildren().get(3)) + .isEqualTo(new AtomicDataType(new BigIntType(false))); + + assertThatThrownBy(() -> createSerializationSchema(dataType, AvroEncoding.BINARY, true)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage( + "Avro does not support TIMESTAMP type with precision: 6, it only supports precision less than 3."); + + assertThatThrownBy(() -> createDeserializationSchema(dataType, AvroEncoding.BINARY, true)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage( + "Avro does not support TIMESTAMP type with precision: 6, it only supports precision less than 3."); Review Comment: It is for testing createSerializationSchema and createDeserializationSchema. Two different scenarios. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org