Skip to content

Commit a4d457e

Browse files
committed
Code review feedback
1 parent 271bd71 commit a4d457e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

parquet-avro/src/main/java/org/apache/parquet/avro/AvroWriteSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void writeRecord(GroupType schema, Schema avroSchema, Object record) {
196196
private void writeVariantFields(GroupType schema, Schema avroSchema, Object record) {
197197
List<Type> fields = schema.getFields();
198198
List<Schema.Field> avroFields = avroSchema.getFields();
199-
// Check if the avro schema is a value/metadata pair. If not, just read the Variant as if it was a normal record.
199+
// Check if the avro schema is a value/metadata pair. If not, treat the value as a non-variant record.
200200
boolean binarySchema = true;
201201
int valueIndex = -1;
202202
int metadataIndex = -1;

parquet-avro/src/test/java/org/apache/parquet/avro/TestWriteVariant.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static ByteBuffer variant(String s) {
7979
return variant(b -> b.appendString(s));
8080
}
8181

82-
private static GroupType variantGroup = Types.buildGroup(Type.Repetition.REQUIRED)
82+
private static final GroupType UNSHREDDED_GROUP = Types.buildGroup(Type.Repetition.REQUIRED)
8383
.as(LogicalTypeAnnotation.variantType((byte) 1))
8484
.required(PrimitiveTypeName.BINARY)
8585
.named("metadata")
@@ -95,10 +95,10 @@ private static MessageType parquetSchema(GroupType variantGroup) {
9595
.named("table");
9696
}
9797

98-
private static MessageType readSchema = parquetSchema(variantGroup);
98+
private static final MessageType READ_SCHEMA = parquetSchema(UNSHREDDED_GROUP);
9999

100-
private static final Schema VARIANT_SCHEMA = new AvroSchemaConverter().convert(variantGroup);
101-
private static final Schema SCHEMA = new AvroSchemaConverter().convert(readSchema);
100+
private static final Schema VARIANT_SCHEMA = new AvroSchemaConverter().convert(UNSHREDDED_GROUP);
101+
private static final Schema SCHEMA = new AvroSchemaConverter().convert(READ_SCHEMA);
102102

103103
private ByteBuffer TEST_METADATA;
104104
private ByteBuffer TEST_OBJECT;
@@ -249,7 +249,7 @@ GenericRecord createRecord(int i, Variant v) {
249249
public void testUnshreddedValues() throws IOException {
250250
for (Variant v : VARIANTS) {
251251
GenericRecord record = createRecord(1, v);
252-
TestSchema testSchema = new TestSchema(readSchema, readSchema);
252+
TestSchema testSchema = new TestSchema(READ_SCHEMA, READ_SCHEMA);
253253

254254
GenericRecord actual = writeAndRead(testSchema, record);
255255

@@ -264,7 +264,7 @@ public void testShreddedValues() throws IOException {
264264
for (Variant v : VARIANTS) {
265265
GenericRecord record = createRecord(1, v);
266266
MessageType writeSchema = shreddingSchema(v);
267-
TestSchema testSchema = new TestSchema(writeSchema, readSchema);
267+
TestSchema testSchema = new TestSchema(writeSchema, READ_SCHEMA);
268268

269269
GenericRecord actual = writeAndRead(testSchema, record);
270270
assertEquals(record.get(0), actual.get(0));
@@ -283,7 +283,7 @@ public void testMixedShredding() throws IOException {
283283
}
284284

285285
MessageType writeSchema = shreddingSchema(valueForSchema);
286-
TestSchema testSchema = new TestSchema(writeSchema, readSchema);
286+
TestSchema testSchema = new TestSchema(writeSchema, READ_SCHEMA);
287287

288288
List<GenericRecord> actual = writeAndRead(testSchema, expected);
289289
assertEquals(actual.size(), VARIANTS.length);

0 commit comments

Comments
 (0)