This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 7142efe68a Ensure conversion of field specs to avro schema is ordered 
(#9077)
7142efe68a is described below

commit 7142efe68a475b95a934ce08eac90311010e0c35
Author: Lars-Kristian Svenøy <[email protected]>
AuthorDate: Fri Jul 22 19:25:51 2022 +0100

    Ensure conversion of field specs to avro schema is ordered (#9077)
---
 .../org/apache/pinot/core/util/SegmentProcessorAvroUtils.java     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java
index 4ff6d9e433..0a47f5f202 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java
@@ -20,7 +20,10 @@ package org.apache.pinot.core.util;
 
 import java.nio.ByteBuffer;
 import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 import org.apache.avro.Schema;
 import org.apache.avro.SchemaBuilder;
 import org.apache.avro.generic.GenericData;
@@ -74,7 +77,10 @@ public final class SegmentProcessorAvroUtils {
   public static Schema 
convertPinotSchemaToAvroSchema(org.apache.pinot.spi.data.Schema pinotSchema) {
     SchemaBuilder.FieldAssembler<org.apache.avro.Schema> fieldAssembler = 
SchemaBuilder.record("record").fields();
 
-    for (FieldSpec fieldSpec : pinotSchema.getAllFieldSpecs()) {
+    List<FieldSpec> orderedFieldSpecs = pinotSchema.getAllFieldSpecs().stream()
+        .sorted(Comparator.comparing(FieldSpec::getName))
+        .collect(Collectors.toList());
+    for (FieldSpec fieldSpec : orderedFieldSpecs) {
       String name = fieldSpec.getName();
       DataType storedType = fieldSpec.getDataType().getStoredType();
       if (fieldSpec.isSingleValueField()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to