This is an automated email from the ASF dual-hosted git repository.
gangwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-java.git
The following commit(s) were added to refs/heads/master by this push:
new f50dd6cb4 GH-2972: Fix incomplete avro metadata on INT96 schema
converter (#3311)
f50dd6cb4 is described below
commit f50dd6cb4b526cf4b585993c1b69a838cd8151f3
Author: Arnav Balyan <[email protected]>
AuthorDate: Sun Sep 21 19:17:15 2025 +0530
GH-2972: Fix incomplete avro metadata on INT96 schema converter (#3311)
---
.../apache/parquet/avro/AvroSchemaConverter.java | 4 ++-
.../parquet/avro/TestAvroSchemaConverter.java | 29 +++++++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git
a/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java
b/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java
index 58e9c2e19..782c009db 100644
---
a/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java
+++
b/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java
@@ -404,7 +404,9 @@ public class AvroSchemaConverter {
@Override
public Schema convertINT96(PrimitiveTypeName primitiveTypeName) {
if (readInt96AsFixed) {
- return Schema.createFixed("INT96", "INT96 represented as
byte[12]", null, 12);
+ String name = parquetType.getName();
+ String ns = namespace(name, names);
+ return Schema.createFixed(name, "INT96 represented as
byte[12]", ns, 12);
}
throw new IllegalArgumentException(
"INT96 is deprecated. As interim enable READ_INT96_AS_FIXED
flag to read as byte array.");
diff --git
a/parquet-avro/src/test/java/org/apache/parquet/avro/TestAvroSchemaConverter.java
b/parquet-avro/src/test/java/org/apache/parquet/avro/TestAvroSchemaConverter.java
index d54cd4310..130192e15 100644
---
a/parquet-avro/src/test/java/org/apache/parquet/avro/TestAvroSchemaConverter.java
+++
b/parquet-avro/src/test/java/org/apache/parquet/avro/TestAvroSchemaConverter.java
@@ -579,7 +579,7 @@ public class TestAvroSchemaConverter {
enableInt96ReadingConfig.setBoolean(AvroReadSupport.READ_INT96_AS_FIXED,
true);
Schema schema = Schema.createRecord("myrecord", null, null, false);
- Schema int96schema = Schema.createFixed("INT96", "INT96 represented as
byte[12]", null, 12);
+ Schema int96schema = Schema.createFixed("int96_field", "INT96 represented
as byte[12]", null, 12);
schema.setFields(Collections.singletonList(new Schema.Field("int96_field",
int96schema, null, null)));
testParquetToAvroConversion(
@@ -599,6 +599,33 @@ public class TestAvroSchemaConverter {
() -> new AvroSchemaConverter().convert(parquetSchemaWithInt96));
}
+ @Test
+ public void testMultipleInt96FieldsToStringConversion() throws Exception {
+ Configuration enableInt96ReadingConfig = new Configuration();
+ enableInt96ReadingConfig.setBoolean(AvroReadSupport.READ_INT96_AS_FIXED,
true);
+
+ Types.MessageTypeBuilder builder = Types.buildMessage();
+
builder.optional(PrimitiveType.PrimitiveTypeName.INT96).named("timestamp_1");
+
builder.optional(PrimitiveType.PrimitiveTypeName.INT96).named("timestamp_2");
+ MessageType int96Schema = builder.named("int96Schema");
+
+ AvroSchemaConverter converter = new
AvroSchemaConverter(enableInt96ReadingConfig);
+ Schema avroSchema = converter.convert(int96Schema);
+
+ String schemaString = avroSchema.toString(true);
+
+ Assert.assertTrue(
+ "First field should have full timestamp_1 definition",
+ schemaString.contains("\"name\" : \"timestamp_1\""));
+ Assert.assertTrue(
+ "Second field should have full timestamp_2 definition",
+ schemaString.contains("\"name\" : \"timestamp_2\""));
+
+ Assert.assertFalse(
+ "Should not reference bare 'INT96' type anymore",
+ schemaString.contains("\"type\" : [ \"null\", \"INT96\" ]"));
+ }
+
@Test
public void testDateType() throws Exception {
Schema date = LogicalTypes.date().addToSchema(Schema.create(INT));