[AMORO-4379][Iceberg] Fix OS-dependent File.separator in table URI path resolution - #4380
Open
aakashofficial-k01 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
Table locations and file paths in Iceberg are URIs (RFC 3986) where path components are delimited by
/. Inamoro-format-iceberg, three locations constructed paths using the host OSFile.separator:TableFileUtil.getNewFilePath()IcebergTableMaintainer.clearInternalTableContentsFiles()IcebergTableMaintainer.clearInternalTableMetadata()On Windows environments,
File.separatorresolves to\. This produces invalid URIs (such ashdfs://nn:8020/tbl\00000-0.parquetors3://bucket/tbl\metadata), which causes:TableFileUtil.getUriPath()/URI.create()to throwIllegalArgumentException: Illegal character in pathduring table optimize commit (UnKeyedTableCommit.moveTargetFiles()).pio.listPrefix()) to treat\as a literal ASCII character, returning 0 files and silently skipping orphan metadata cleanup.//) on Linux when a base table location contains a trailing slash.Fix #4379.
Brief change log
TableFileUtil.getNewFilePath(), use Iceberg's standardLocationUtil.stripTrailingSlash(newDirectory)and format child file paths with forward slash/.IcebergTableMaintainer, constructdataLocationandmetadataLocationusingLocationUtil.stripTrailingSlash(table.location())and format with/adhering to Iceberg'sDefaultLocationProviderconvention.import java.io.File;in both classes.TestFileUtilverifyinggetNewFilePathwith and without trailing slashes across S3 and HDFS URIs.How was this patch tested?
getNewFilePathinTestFileUtil.java../mvnw test -pl amoro-common,amoro-format-iceberg -Dtest=TestFileUtil: BUILD SUCCESS (14/14 passed)./mvnw spotless:check checkstyle:check -pl amoro-format-iceberg: BUILD SUCCESS (0 violations)Documentation