-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: check for slashless metadata paths #968
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati | |
metadataFileLocation != null && !metadataFileLocation.isEmpty(), | ||
"Cannot register an empty metadata file location as a table"); | ||
|
||
int lastSlashIndex = metadataFileLocation.lastIndexOf("/"); | ||
Preconditions.checkArgument( | ||
lastSlashIndex != -1, | ||
"Invalid metadata file location: %s, must be a full path to a file", | ||
metadataFileLocation); | ||
|
||
// Throw an exception if this table already exists in the catalog. | ||
if (tableExists(identifier)) { | ||
throw new AlreadyExistsException("Table already exists: %s", identifier); | ||
} | ||
|
||
String locationDir = metadataFileLocation.substring(0, metadataFileLocation.lastIndexOf("/")); | ||
String locationDir = metadataFileLocation.substring(0, lastSlashIndex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is no |
||
|
||
TableOperations ops = newTableOps(identifier); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The presence of a slash does not mean the path is full, e.g.
../relative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but this indicates the absence of a slash, which means the path is not full.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but it is kind of misleading to check for condition X and then print an error message saying condition (X + Y) is not met.
How about...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I don't think making this check for an absolute path is strictly a blocker here; we can file an issue to track that if need be. But let's please try to swiftly get rid of the 500