RussellSpitzer commented on code in PR #4687:
URL: https://github.com/apache/iceberg/pull/4687#discussion_r867179750
##########
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkDataWrite.java:
##########
@@ -588,6 +600,56 @@ public void
partitionedCreateWithTargetFileSizeViaOption(IcebergOptionsType opti
Assert.assertTrue("All DataFiles contain 1000 rows",
files.stream().allMatch(d -> d.recordCount() == 1000));
}
+ @Test
+ public void testCommitUnknownException() throws IOException {
+ File parent = temp.newFolder(format.toString());
+ File location = new File(parent, "commitunknown");
+
+ HadoopTables tables = new HadoopTables(CONF);
+ PartitionSpec spec =
PartitionSpec.builderFor(SCHEMA).identity("data").build();
+ Table table = tables.create(SCHEMA, spec, location.toString());
+
+ List<SimpleRecord> records = Lists.newArrayList(
+ new SimpleRecord(1, "a"),
+ new SimpleRecord(2, "b"),
+ new SimpleRecord(3, "c")
+ );
+
+ Dataset<Row> df = spark.createDataFrame(records, SimpleRecord.class);
+
+ AppendFiles append = table.newFastAppend();
+ AppendFiles spyAppend = spy(append);
+ doAnswer(invocation -> {
+ append.commit();
+ throw new CommitStateUnknownException(new RuntimeException("Datacenter
on Fire"));
+ }).when(spyAppend).commit();
+
+ Table spyTable = spy(table);
+ when(spyTable.newAppend()).thenReturn(spyAppend);
+ SparkTable sparkTable = new SparkTable(spyTable, false);
+
+ String manualTableName = "unknown_exception";
+ ManualSource.setTable(manualTableName, sparkTable);
+
+ // Although an exception is thrown here, write and commit have succeeded
+ AssertHelpers.assertThrowsWithCause("Should throw a Commit State Unknown
Exception",
+ SparkException.class,
Review Comment:
This tests the everything in our normal path except for Spark Catalog
Operations. All of the other pathways behave the same except for the
"loadTable" method.
--
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]