nastra commented on code in PR #8948:
URL: https://github.com/apache/iceberg/pull/8948#discussion_r1377152579
##########
spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestUpdate.java:
##########
@@ -1425,59 +1420,57 @@ public void testUpdateWithInvalidAssignmentsStrict() {
withSQLConf(
ImmutableMap.of("spark.sql.storeAssignmentPolicy", "strict"),
() -> {
- AssertHelpers.assertThrows(
- "Should complain about writing nulls to a top-level column",
- AnalysisException.class,
- "Cannot safely cast `id` \"VOID\" to \"INT\"",
- () -> sql("UPDATE %s t SET t.id = NULL", commitTarget()));
-
- AssertHelpers.assertThrows(
- "Should complain about writing nulls to a nested column",
- AnalysisException.class,
- "Cannot safely cast `s`.`n1` \"VOID\" to \"INT\"",
- () -> sql("UPDATE %s t SET t.s.n1 = NULL", commitTarget()));
-
- AssertHelpers.assertThrows(
- "Should complain about writing missing fields in structs",
- AnalysisException.class,
- "Cannot find data for the output column",
- () -> sql("UPDATE %s t SET t.s = named_struct('n1', 1)",
commitTarget()));
-
- AssertHelpers.assertThrows(
- "Should complain about writing invalid data types",
- AnalysisException.class,
- "Cannot safely cast",
- () -> sql("UPDATE %s t SET t.s.n1 = 'str'", commitTarget()));
-
- AssertHelpers.assertThrows(
- "Should complain about writing incompatible structs",
- AnalysisException.class,
- "Cannot find data for the output column",
- () ->
- sql("UPDATE %s t SET t.s.n2 = named_struct('dn3', 1, 'dn1',
2)", commitTarget()));
+ Assertions.assertThatThrownBy(() -> sql("UPDATE %s t SET t.id =
NULL", commitTarget()))
+ .as("Should complain about writing nulls to a top-level column")
+ .isInstanceOf(AnalysisException.class)
+ .hasMessageContaining("Cannot safely cast `id` \"VOID\" to
\"INT\"");
+
+ Assertions.assertThatThrownBy(() -> sql("UPDATE %s t SET t.s.n1 =
NULL", commitTarget()))
+ .as("Should complain about writing nulls to a nested column")
+ .isInstanceOf(AnalysisException.class)
+ .hasMessageContaining("Cannot safely cast `s`.`n1` \"VOID\" to
\"INT\"");
+
+ Assertions.assertThatThrownBy(
+ () -> sql("UPDATE %s t SET t.s = named_struct('n1', 1)",
commitTarget()))
+ .as("Should complain about writing missing fields in structs")
+ .isInstanceOf(AnalysisException.class)
+ .hasMessageContaining("Cannot find data for the output column");
+
+ Assertions.assertThatThrownBy(() -> sql("UPDATE %s t SET t.s.n1 =
'str'", commitTarget()))
+ .as("Should complain about writing invalid data types")
+ .isInstanceOf(AnalysisException.class)
+ .hasMessageContaining("Cannot safely cast");
+
+ Assertions.assertThatThrownBy(
+ () ->
+ sql(
+ "UPDATE %s t SET t.s.n2 = named_struct('dn3', 1,
'dn1', 2)",
+ commitTarget()))
+ .as("Should complain about writing incompatible structs")
+ .isInstanceOf(AnalysisException.class)
+ .hasMessageContaining("Cannot find data for the output column");
});
}
@Test
public void testUpdateWithNonDeterministicCondition() {
createAndInitTable("id INT, dep STRING", "{ \"id\": 1, \"dep\": \"hr\" }");
- AssertHelpers.assertThrows(
- "Should complain about non-deterministic expressions",
- AnalysisException.class,
- "The operator expects a deterministic expression",
- () -> sql("UPDATE %s SET id = -1 WHERE id = 1 AND rand() > 0.5",
commitTarget()));
+ Assertions.assertThatThrownBy(
+ () -> sql("UPDATE %s SET id = -1 WHERE id = 1 AND rand() > 0.5",
commitTarget()))
+ .as("Should complain about non-deterministic expressions")
Review Comment:
this and the one below can all be removed
--
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]