yuqi1129 commented on code in PR #9450:
URL: https://github.com/apache/gravitino/pull/9450#discussion_r2606588932


##########
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:
   It is used in registering a table.



-- 
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]

Reply via email to