nastra commented on code in PR #14262:
URL: https://github.com/apache/iceberg/pull/14262#discussion_r2478453145


##########
core/src/test/java/org/apache/iceberg/TestContentFileParser.java:
##########
@@ -161,6 +217,140 @@ private static String 
dataFileJsonWithAllOptional(PartitionSpec spec) {
     }
   }
 
+  private static String dataFileJsonWithContentStats(
+      boolean hasValueCount,
+      boolean hasNullValueCount,
+      boolean hasNanValueCount,
+      boolean hasLowBound,
+      boolean hasUpperBound) {
+    StringBuilder sb = new StringBuilder();
+    sb.append(
+            
"{\"spec-id\":0,\"content\":\"DATA\",\"file-path\":\"/path/to/data-with-stats.parquet\",")
+        .append("\"file-format\":\"PARQUET\",")
+        .append("\"partition\":{\"1000\":1},")
+        .append("\"file-size-in-bytes\":350,")
+        .append("\"record-count\":10,")
+        .append("\"key-metadata\":\"00000000000000000000000000000000\",")
+        .append("\"split-offsets\":[128,256],")
+        .append("\"sort-order-id\":1,")
+        .append("\"content-stats\":{");
+
+    // Use a loop to reduce repetition in serializing field stats
+    int[] fieldIds = {10200, 10400};
+    Object[][] fieldValues = {
+      // int field: field id, valueCount, nullValueCount, nanValueCount, 
lowerBound, upperBound
+      {90, 10, 0, 1000000, 5000000},
+      // string field: field id, valueCount, nullValueCount, nanValueCount, 
lowerBound, upperBound
+      {180, 20, 0, "02000000", "0A000000"}
+    };
+
+    for (int i = 0; i < fieldIds.length; i++) {

Review Comment:
   we shouldn't be building up the JSON structure like this, because this makes 
it quite difficult to read/maintain the code and reason about it. In tests like 
`TestLoadCredentialsResponseParser` / `TestLoadViewResponseParser` / 
`TestPlanTableScanResponseParser` we typically use the JSON as a full string 
(instead of programmatically building it) for the respective test case we're 
trying to verify. 



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

Reply via email to