Skip to content

Commit

Permalink
Supports ignore table comment when list all tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoyt committed Mar 4, 2023
1 parent 355ed80 commit 5e8687c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.util.regex.Pattern
import org.apache.spark.sql.{Row, SparkSession}
import org.apache.spark.sql.connector.catalog.{CatalogExtension, CatalogPlugin, SupportsNamespaces, TableCatalog}

import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.engine.spark.shim.SparkCatalogShim.SESSION_CATALOG

class CatalogShim_v3_0 extends CatalogShim_v2_4 {
Expand Down Expand Up @@ -166,10 +167,12 @@ class CatalogShim_v3_0 extends CatalogShim_v2_4 {
val identifiers = namespaces.flatMap { ns =>
tc.listTables(ns).filter(i => tp.matcher(quoteIfNeeded(i.name())).matches())
}
val listTablesOnly = spark.conf.getOption(KyuubiConf.ENGINE_SPARK_LIST_TABLES.key)
.map(_.toBoolean).getOrElse(KyuubiConf.ENGINE_SPARK_LIST_TABLES.defaultVal.get)
identifiers.map { ident =>
val table = tc.loadTable(ident)
// TODO: restore view type for session catalog
val comment = table.properties().getOrDefault(TableCatalog.PROP_COMMENT, "")
val comment = if (listTablesOnly) ""
else tc.loadTable(ident).properties().getOrDefault(TableCatalog.PROP_COMMENT, "")
val schema = ident.namespace().map(quoteIfNeeded).mkString(".")
val tableName = quoteIfNeeded(ident.name())
Row(catalog.name(), schema, tableName, "TABLE", comment, null, null, null, null, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2713,4 +2713,11 @@ object KyuubiConf {
.version("1.7.0")
.timeConf
.createWithDefault(Duration.ofSeconds(60).toMillis)

val ENGINE_SPARK_LIST_TABLES: ConfigEntry[Boolean] =
buildConf("kyuubi.engine.spark.list.tables")
.doc("Only query table identifiers when set to true. Work on Spark 3.x only.")
.version("1.8.0")
.booleanConf
.createWithDefault(false)
}

0 comments on commit 5e8687c

Please sign in to comment.