chamikaramj commented on code in PR #24344:
URL: https://github.com/apache/beam/pull/24344#discussion_r1030932543


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/TypedSchemaTransformProvider.java:
##########
@@ -61,7 +63,13 @@ Optional<List<String>> dependencies(ConfigT configuration, 
PipelineOptions optio
   @Override
   public final Schema configurationSchema() {
     try {
-      return SchemaRegistry.createDefault().getSchema(configurationClass());
+      Schema schema = 
SchemaRegistry.createDefault().getSchema(configurationClass());
+
+      // Sort the fields by name to ensure a consistent schema is produced
+      Schema sortedSchema = schema.getFields().stream()
+          .sorted(Comparator.comparing(Field::getName))
+          .collect(Schema.toSchema());

Review Comment:
   Can we also add unit tests  ?



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/TypedSchemaTransformProvider.java:
##########
@@ -61,7 +63,13 @@ Optional<List<String>> dependencies(ConfigT configuration, 
PipelineOptions optio
   @Override
   public final Schema configurationSchema() {
     try {
-      return SchemaRegistry.createDefault().getSchema(configurationClass());
+      Schema schema = 
SchemaRegistry.createDefault().getSchema(configurationClass());
+
+      // Sort the fields by name to ensure a consistent schema is produced
+      Schema sortedSchema = schema.getFields().stream()

Review Comment:
   We should also preserve other fields of the Schema, for example, id, 
options, encoding_positions_set (and any future fields).
   
   
https://github.com/apache/beam/blob/master/model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/schema.proto#L40



-- 
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]

Reply via email to