timothyw553 commented on code in PR #19148:
URL: https://github.com/apache/iceberg/pull/19148#discussion_r4704354723
##########
api/src/main/java/org/apache/iceberg/util/StructProjection.java:
##########
@@ -177,6 +177,16 @@ private StructProjection(StructType structType, StructType
projection, boolean a
}
}
+ /**
+ * Returns whether the field at the given projected position exists in the
source struct.
+ *
+ * @param pos position in the projected struct
+ * @return true if the field exists in the source struct
+ */
+ public boolean isFieldProjected(int pos) {
Review Comment:
do we need a new public method in `api/` just for `PartitionComparator`
(which also relies on `coercePartition` returning a `StructProjection`)? if we
keep it, could we clarify the javadoc so callers know a present field with a
`null` value still returns true?
```diff
* Returns whether the field at the given projected position exists in the
source struct.
+ *
+ * <p>A present field with a null value returns true. Missing fields are
allowed only by
+ * {@link #createAllowMissing}.
```
##########
core/src/main/java/org/apache/iceberg/PartitionsTable.java:
##########
@@ -292,6 +292,17 @@ public int compare(StructLike o1, StructLike o2) {
if (cmp != 0) {
return cmp;
}
+
+ // Distinguish missing partition fields from fields with actual null
values.
+ StructProjection projection1 = (StructProjection) o1;
+ StructProjection projection2 = (StructProjection) o2;
+ for (int pos = 0; pos < projection1.size(); pos += 1) {
Review Comment:
now that we check `isFieldProjected(pos)` for every position, isn't the
`projectedFields()` count comparison right above redundant? different counts
imply at least one position differs in presence anyway, so could we drop that
check and declare `int cmp` inside this loop?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]