dramaticlly commented on code in PR #8194:
URL: https://github.com/apache/iceberg/pull/8194#discussion_r1282471881
##########
core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java:
##########
@@ -192,6 +192,14 @@ public Table create() {
String baseLocation = location != null ? location :
defaultWarehouseLocation(identifier);
tableProperties.putAll(tableOverrideProperties());
+
+ if
(Boolean.parseBoolean(tableProperties.get(TableProperties.UNIQUE_LOCATION))) {
+ boolean alreadyExists = ops.io().newInputFile(baseLocation).exists();
+ if (alreadyExists) {
+ throw new AlreadyExistsException("Table location already in use:
%s", baseLocation);
Review Comment:
thank you @RussellSpitzer for your feedback. I totally agree that checking
for directory or location is empty would be awesome, but based on the methods
available in
[FileIO](https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/io/FileIO.java).
I dont find anything useful for that purpose. The closest one I get is
[SupportsPrefixOperations::listPrefix](https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/io/SupportsPrefixOperations.java#L36)
which is subclass of fileIO.
Do you think it make sense for us to do conditional check based on io?
```java
boolean alreadyExists =
(ops.io() instanceof SupportsPrefixOperations) ?
Iterables.isEmpty(
((SupportsPrefixOperations) ops.io()).listPrefix(baseLocation)
)
: ops.io().newInputFile(baseLocation).exists();
```
--
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]