slfan1989 commented on code in PR #13962:
URL: https://github.com/apache/iceberg/pull/13962#discussion_r2314882667
##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/SnapshotTableSparkAction.java:
##########
@@ -124,10 +124,12 @@ private SnapshotTable.Result doExecute() {
StagedSparkTable stagedTable = stageDestTable();
Table icebergTable = stagedTable.table();
- // TODO: Check the dest table location does not overlap with the source
table location
-
boolean threw = true;
try {
+ Preconditions.checkArgument(
+ !sourceTableLocation().equals(icebergTable.location()),
Review Comment:
Thank you very much for your valuable suggestion. I completely agree with
your point that we should refine the validation logic to cover more edge cases.
I have updated the code accordingly and added targeted unit tests.
The main changes are as follows:
> Standardizing the source table's location and target table's location:
- This improves the handling of `..` symbols (parent directory references).
- It also helps to remove unnecessary `trailing slashes` (/), ensuring paths
are consistently formatted.
> Support for multiple path directions:
- We now ensure that the target path does not contain the source table's
prefix, which effectively handles trivial path differences and nested paths.
- We added a check to ensure that the target path will not be written to the
direct parent path of the source table, preventing overlaps with the source's
parent directory.
--
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]