jerryshao commented on code in PR #9450:
URL: https://github.com/apache/gravitino/pull/9450#discussion_r2606579342
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -342,4 +346,34 @@ private IndexParams getIndexParamsByIndexType(IndexType
indexType) {
throw new IllegalArgumentException("Unsupported index type: " +
indexType);
}
}
+
+ /**
+ * Check if the location is valid for Lance table. For example,
'invalid://path/to/table' is
+ * invalid. We use `URI` to check it for simplicity, in fact, we'd better use
+ *
+ * <p>Dataset.open(location, new RootAllocator()).close(); to check,
however, the code will throw
+ * exception if the path does not exist though it's indeed a valid path.
+ *
+ * @param location The location string.
+ * @return True if the location is valid, false otherwise.
+ */
+ @VisibleForTesting
+ boolean isValidLanceLocation(String location) {
+ if (StringUtils.isBlank(location)) {
+ return false;
+ }
+
+ try {
+ URI uri = new URI(location);
+ String scheme = uri.getScheme();
+ if (StringUtils.isNotBlank(scheme)) {
+ return true;
+ }
+
+ File file = new File(location);
+ return file.isAbsolute();
Review Comment:
Besides, why do we need to ensure that the path is absolute? My
understanding is that relative path should also work (FS will figure out the
working directory and how to normalize the relative path), do we need such a
strict restriction?
--
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]