RussellSpitzer commented on a change in pull request #2164:
URL: https://github.com/apache/iceberg/pull/2164#discussion_r565658423



##########
File path: api/src/main/java/org/apache/iceberg/SortOrder.java
##########
@@ -258,14 +257,20 @@ Builder addSortField(String transformAsString, int 
sourceId, SortDirection direc
     }
 
     public SortOrder build() {
-      if (orderId == 0 && fields.size() != 0) {
+      if (orderId != null && orderId == 0 && fields.size() != 0) {
         throw new IllegalArgumentException("Sort order ID 0 is reserved for 
unsorted order");
       }
-      if (fields.size() == 0 && orderId != 0) {
+      if (fields.size() == 0 && orderId != null && orderId != 0) {
         throw new IllegalArgumentException("Unsorted order ID must be 0");
       }
 
-      SortOrder sortOrder = new SortOrder(schema, orderId, fields);
+      if (fields.isEmpty()) {

Review comment:
       I think either is good, really I just wanted to have the control flow 
sorted like you have it now where we can clearly see the branch for unsorted vs 
sorted code, so beyond that I think it's your preference




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

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to