JingsongLi commented on code in PR #1897:
URL: https://github.com/apache/incubator-paimon/pull/1897#discussion_r1306889678


##########
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/BaseProcedure.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.spark.procedure;
+
+import org.apache.paimon.spark.SparkCatalog;
+import org.apache.paimon.spark.SparkTable;
+import org.apache.paimon.spark.catalog.Catalogs;
+import org.apache.paimon.utils.Preconditions;
+
+import org.apache.spark.sql.SparkSession;
+import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
+import org.apache.spark.sql.connector.catalog.CatalogManager;
+import org.apache.spark.sql.connector.catalog.Identifier;
+
+/** A base class for procedure. */
+abstract class BaseProcedure implements Procedure {
+
+    public SparkSession spark = SparkSession.active();
+
+    /**
+     * get table by database and table name.
+     *
+     * @param database if null, use current database
+     * @param table -

Review Comment:
   remove useless comments



##########
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/BaseProcedure.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.spark.procedure;
+
+import org.apache.paimon.spark.SparkCatalog;
+import org.apache.paimon.spark.SparkTable;
+import org.apache.paimon.spark.catalog.Catalogs;
+import org.apache.paimon.utils.Preconditions;
+
+import org.apache.spark.sql.SparkSession;
+import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
+import org.apache.spark.sql.connector.catalog.CatalogManager;
+import org.apache.spark.sql.connector.catalog.Identifier;
+
+/** A base class for procedure. */
+abstract class BaseProcedure implements Procedure {
+
+    public SparkSession spark = SparkSession.active();
+
+    /**
+     * get table by database and table name.
+     *
+     * @param database if null, use current database
+     * @param table -
+     * @return -
+     */
+    public SparkTable getTable(String database, String table) {
+        Preconditions.checkArgument(table != null && !table.trim().isEmpty(), 
"tableName is empty");
+        CatalogManager catalogManager = spark.sessionState().catalogManager();
+        SparkCatalog sparkCatalog = new SparkCatalog();

Review Comment:
   Create catalog per call is not good.
   For example, hive connector will be leaked.
   
   `ProcedureBuilder` already have `TableCatalog`.



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