sririshindra commented on code in PR #12779:
URL: https://github.com/apache/iceberg/pull/12779#discussion_r2049123660
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestSnapshotTableAction.java:
##########
@@ -65,4 +69,40 @@ public void testSnapshotWithParallelTasks() throws
IOException {
.execute();
assertThat(snapshotThreadsIndex.get()).isEqualTo(2);
}
+
+ @TestTemplate
+ public void testTableLocationOverlapThrowsException() throws IOException {
+ // Ensure the test runs only for non-Hadoop-based catalogs,
+ // because path-based tables cannot have a custom location set.
+ assumeThat(catalogName)
+ .as("Cannot set a custom location for a path-based table.")
+ .isNotEqualTo("testhadoop");
+
+ String location = Files.createTempDirectory(temp,
"junit").toFile().toString();
+
+ sql(
+ "CREATE TABLE %s (id bigint NOT NULL, data string) USING parquet
LOCATION '%s'",
+ SOURCE_NAME, location);
+ sql("INSERT INTO TABLE %s VALUES (1, 'a')", SOURCE_NAME);
+ sql("INSERT INTO TABLE %s VALUES (2, 'b')", SOURCE_NAME);
+
+ // Define properties for the destination table, setting its location to
the same path as the
+ // source table
+ Map<String, String> tableProperties = Maps.newHashMap();
+ tableProperties.put("location", "file:" + location);
+
+ // Test that an exception is thrown
+ // when the destination table location overlaps with the source table
location
+ // Assert that the exception message matches the expected error message
Review Comment:
I concur with this comment as well. Given that in other places in the code
base where the caching of IllegalArgumentException is being tested doesn't have
any explanation in the comments earthier I don't think the comment is needed
here as well. It wouldn't be a divergence from rest of the codebase.
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestSnapshotTableAction.java:
##########
@@ -65,4 +69,40 @@ public void testSnapshotWithParallelTasks() throws
IOException {
.execute();
assertThat(snapshotThreadsIndex.get()).isEqualTo(2);
}
+
+ @TestTemplate
+ public void testTableLocationOverlapThrowsException() throws IOException {
+ // Ensure the test runs only for non-Hadoop-based catalogs,
+ // because path-based tables cannot have a custom location set.
+ assumeThat(catalogName)
+ .as("Cannot set a custom location for a path-based table.")
+ .isNotEqualTo("testhadoop");
+
+ String location = Files.createTempDirectory(temp,
"junit").toFile().toString();
+
+ sql(
+ "CREATE TABLE %s (id bigint NOT NULL, data string) USING parquet
LOCATION '%s'",
+ SOURCE_NAME, location);
+ sql("INSERT INTO TABLE %s VALUES (1, 'a')", SOURCE_NAME);
+ sql("INSERT INTO TABLE %s VALUES (2, 'b')", SOURCE_NAME);
+
+ // Define properties for the destination table, setting its location to
the same path as the
+ // source table
+ Map<String, String> tableProperties = Maps.newHashMap();
+ tableProperties.put("location", "file:" + location);
Review Comment:
I concur. This is much cleaner.
--
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]