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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]