liuxiaocs7 commented on code in PR #7134:
URL: https://github.com/apache/iceberg/pull/7134#discussion_r1142416374


##########
data/src/test/java/org/apache/iceberg/io/TestPartitioningWriters.java:
##########
@@ -137,11 +137,10 @@ public void testClusteredDataWriterOutOfOrderPartitions() 
throws IOException {
     writer.write(toRow(4, "bbb"), spec, partitionKey(spec, "bbb"));
     writer.write(toRow(5, "ccc"), spec, partitionKey(spec, "ccc"));
 
-    AssertHelpers.assertThrows(
-        "Should fail to write out of order partitions",
-        IllegalStateException.class,
-        "Encountered records that belong to already closed files",
-        () -> writer.write(toRow(6, "aaa"), spec, partitionKey(spec, "aaa")));
+    Assertions.assertThatThrownBy(
+            () -> writer.write(toRow(6, "aaa"), spec, partitionKey(spec, 
"aaa")))
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessageContaining("Encountered records that belong to already 
closed files");

Review Comment:
   Hi, @nastra, thanks for your advice, but here is the case with dynamic 
variables, i think we should continue to use `hasMessageContaining` because 
`write.write()` may raise throws the following exception.
   
   ```java
   if (completedSpecIds.contains(spec.specId())) {
     String errorCtx = String.format("spec %s", spec);
     throw new IllegalStateException(NOT_CLUSTERED_ROWS_ERROR_MSG_TEMPLATE + 
errorCtx);
   }
   ```
   
   and `NOT_CLUSTERED_ROWS_ERROR_MSG_TEMPLATE` is:
   
   ```java
   private static final String NOT_CLUSTERED_ROWS_ERROR_MSG_TEMPLATE =
       "Incoming records violate the writer assumption that records are 
clustered by spec and "
           + "by partition within each spec. Either cluster the incoming 
records or switch to fanout writers.\n"
           + "Encountered records that belong to already closed files:\n";
   ```
   
   Should we use the full constant string 
`NOT_CLUSTERED_ROWS_ERROR_MSG_TEMPLATE` to check? `
   Encountered records that belong to already closed files` seems to be enough 
for now.
   
   
![image](https://user-images.githubusercontent.com/42756849/226408545-0f69bad5-5b0f-4b81-93d2-a7e1b5837e5c.png)
   



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