You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/04/30 06:15:14 UTC

[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2520: Support SHOW CATALOGS syntax in Spark extensions

turboFei commented on code in PR #2520:
URL: https://github.com/apache/incubator-kyuubi/pull/2520#discussion_r862309825


##########
extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/spark/sql/catalog/ShowCatalogsCommand.scala:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.spark.sql.catalog
+
+import org.apache.spark.sql.{Row, SparkSession}
+import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
+import org.apache.spark.sql.catalyst.util.StringUtils
+import org.apache.spark.sql.connector.catalog.CatalogManager
+import org.apache.spark.sql.execution.command.RunnableCommand
+import org.apache.spark.sql.types.StringType
+
+/**
+ * The command for `SHOW CATALOGS`.
+ */
+case class ShowCatalogsCommand(pattern: Option[String]) extends RunnableCommand {
+  override val output: Seq[Attribute] = Seq(
+    AttributeReference("catalog", StringType, nullable = false)())
+
+  // The implementation use eager strategy to list catalog, which is different from SPARK-35973
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+    val configuredCatalogs = sparkSession.sessionState.conf.getAllConfs.keys
+      .filter { _ startsWith "spark.sql.catalog." }
+      .map { _ stripPrefix "spark.sql.catalog." }
+      .filterNot { _ contains "." }

Review Comment:
   but it seems that `spark.sql.catalog.`p.g`` also contains "."



##########
extensions/spark/kyuubi-extension-spark-common/src/main/scala/org/apache/spark/sql/catalog/ShowCatalogsCommand.scala:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.spark.sql.catalog
+
+import org.apache.spark.sql.{Row, SparkSession}
+import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
+import org.apache.spark.sql.catalyst.util.StringUtils
+import org.apache.spark.sql.connector.catalog.CatalogManager
+import org.apache.spark.sql.execution.command.RunnableCommand
+import org.apache.spark.sql.types.StringType
+
+/**
+ * The command for `SHOW CATALOGS`.
+ */
+case class ShowCatalogsCommand(pattern: Option[String]) extends RunnableCommand {
+  override val output: Seq[Attribute] = Seq(
+    AttributeReference("catalog", StringType, nullable = false)())
+
+  // The implementation use eager strategy to list catalog, which is different from SPARK-35973
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+    val configuredCatalogs = sparkSession.sessionState.conf.getAllConfs.keys
+      .filter { _ startsWith "spark.sql.catalog." }
+      .map { _ stripPrefix "spark.sql.catalog." }
+      .filterNot { _ contains "." }

Review Comment:
   but it seems that `spark.sql.catalog.\`p.g`` also contains "."



-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org