You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/01/27 22:30:29 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #2164: Core: Allow building unsorted orders

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



##########
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) {
-        throw new IllegalArgumentException("Sort order ID 0 is reserved for unsorted order");
+      if (fields.isEmpty()) {
+        if (orderId != null && orderId != 0) {
+          throw new IllegalArgumentException("Unsorted order ID must be 0");
+        }
+        return SortOrder.unsorted();
       }
-      if (fields.size() == 0 && orderId != 0) {
-        throw new IllegalArgumentException("Unsorted order ID must be 0");
+
+      if (orderId != null && orderId == 0) {

Review comment:
       If `orderId == 0`, then it can't be null, so the null check is redundant.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org