LadyForest commented on code in PR #230:
URL: https://github.com/apache/flink-table-store/pull/230#discussion_r926392026


##########
flink-table-store-spark/src/main/java/org/apache/flink/table/store/spark/SparkCatalog.java:
##########
@@ -86,12 +109,68 @@ public String[][] listNamespaces(String[] namespace) 
throws NoSuchNamespaceExcep
         if (!isValidateNamespace(namespace)) {
             throw new NoSuchNamespaceException(namespace);
         }
-        return new String[0][];
+        if (catalog.databaseExists(namespace[0])) {
+            return new String[0][];
+        }
+        throw new NoSuchNamespaceException(namespace);
     }
 
     @Override
-    public Map<String, String> loadNamespaceMetadata(String[] namespace) {
-        return Collections.emptyMap();
+    public Map<String, String> loadNamespaceMetadata(String[] namespace)
+            throws NoSuchNamespaceException {
+        Preconditions.checkArgument(
+                isValidateNamespace(namespace),
+                "Namespace %s is not valid",
+                Arrays.toString(namespace));
+        if (catalog.databaseExists(namespace[0])) {
+            return Collections.emptyMap();
+        }
+        throw new NoSuchNamespaceException(namespace);
+    }
+
+    /**
+     * Drop a namespace from the catalog, recursively dropping all objects 
within the namespace.
+     * This interface implementation only supports the Spark 3.0, 3.1 and 3.2.
+     *
+     * <p>If the catalog implementation does not support this operation, it 
may throw {@link
+     * UnsupportedOperationException}.
+     *
+     * @param namespace a multi-part namespace
+     * @return true if the namespace was dropped
+     * @throws UnsupportedOperationException If drop is not a supported 
operation
+     */
+    @Override
+    public boolean dropNamespace(String[] namespace) throws 
NoSuchNamespaceException {
+        return dropNamespace(namespace, false);
+    }
+
+    /**
+     * Drop a namespace from the catalog with cascade mode, recursively 
dropping all objects within
+     * the namespace if cascade is true. This interface implementation 
supports the Spark 3.3+.
+     *
+     * <p>If the catalog implementation does not support this operation, it 
may throw {@link
+     * UnsupportedOperationException}.
+     *
+     * @param namespace a multi-part namespace
+     * @param cascade When true, deletes all objects under the namespace
+     * @return true if the namespace was dropped
+     * @throws UnsupportedOperationException If drop is not a supported 
operation
+     */
+    public boolean dropNamespace(String[] namespace, boolean cascade)
+            throws NoSuchNamespaceException {

Review Comment:
   Note: `org.apache.spark.sql.catalyst.analysis.NonEmptyNamespaceException` 
cannot be thrown here because it is introduced since Spark 3.3
   https://spark.apache.org/docs/3.3.0/api/java/index.html



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