You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by vi...@apache.org on 2021/09/27 17:38:16 UTC
[spark] branch master updated: [SPARK-36848][SQL] Migrate
ShowCurrentNamespaceStatement to v2 command framework
This is an automated email from the ASF dual-hosted git repository.
viirya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new e4e64c7 [SPARK-36848][SQL] Migrate ShowCurrentNamespaceStatement to v2 command framework
e4e64c7 is described below
commit e4e64c7552713182eb421f227c7d6b2bb96ed36e
Author: Huaxin Gao <hu...@apple.com>
AuthorDate: Mon Sep 27 10:36:55 2021 -0700
[SPARK-36848][SQL] Migrate ShowCurrentNamespaceStatement to v2 command framework
### What changes were proposed in this pull request?
Migrate `ShowCurrentNamespaceStatement` to v2 command framework
### Why are the changes needed?
Migrate to the standard V2 framework
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing tests
Closes #34104 from huaxingao/namesp.
Authored-by: Huaxin Gao <hu...@apple.com>
Signed-off-by: Liang-Chi Hsieh <vi...@gmail.com>
---
.../org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala | 3 ---
.../main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala | 4 ++--
.../org/apache/spark/sql/catalyst/plans/logical/statements.scala | 5 -----
.../org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala | 2 +-
.../scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala | 2 +-
.../spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala | 2 +-
6 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala
index 64f37b3..6e412b6 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala
@@ -88,9 +88,6 @@ class ResolveCatalogs(val catalogManager: CatalogManager)
val namespace = if (ns.nonEmpty) Some(ns) else None
SetCatalogAndNamespace(catalogManager, Some(catalog.name()), namespace)
}
-
- case ShowCurrentNamespaceStatement() =>
- ShowCurrentNamespace(catalogManager)
}
object NonSessionCatalogAndTable {
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index 5ca0be4..1d0fcf5 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -3573,11 +3573,11 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with SQLConfHelper with Logg
}
/**
- * Create a [[ShowCurrentNamespaceStatement]].
+ * Create a [[ShowCurrentNamespace]].
*/
override def visitShowCurrentNamespace(
ctx: ShowCurrentNamespaceContext) : LogicalPlan = withOrigin(ctx) {
- ShowCurrentNamespaceStatement()
+ ShowCurrentNamespace()
}
/**
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
index 81a44e6..cd4309d 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
@@ -279,11 +279,6 @@ case class InsertIntoStatement(
case class UseStatement(isNamespaceSet: Boolean, nameParts: Seq[String]) extends LeafParsedStatement
/**
- * A SHOW CURRENT NAMESPACE statement, as parsed from SQL
- */
-case class ShowCurrentNamespaceStatement() extends LeafParsedStatement
-
-/**
* CREATE FUNCTION statement, as parsed from SQL
*/
case class CreateFunctionStatement(
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
index 07010f7..2d025b1 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
@@ -639,7 +639,7 @@ case class RefreshTable(child: LogicalPlan) extends UnaryCommand {
/**
* The logical plan of the SHOW CURRENT NAMESPACE command.
*/
-case class ShowCurrentNamespace(catalogManager: CatalogManager) extends LeafCommand {
+case class ShowCurrentNamespace() extends LeafCommand {
override val output: Seq[Attribute] = Seq(
AttributeReference("catalog", StringType, nullable = false)(),
AttributeReference("namespace", StringType, nullable = false)())
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
index b3765fa..5d79e51 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
@@ -2104,7 +2104,7 @@ class DDLParserSuite extends AnalysisTest {
test("show current namespace") {
comparePlans(
parsePlan("SHOW CURRENT NAMESPACE"),
- ShowCurrentNamespaceStatement())
+ ShowCurrentNamespace())
}
test("alter table: SerDe properties") {
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
index cbfd5eb..1868898 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
@@ -336,7 +336,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
SetCatalogAndNamespaceExec(catalogManager, catalogName, ns) :: Nil
case r: ShowCurrentNamespace =>
- ShowCurrentNamespaceExec(r.output, r.catalogManager) :: Nil
+ ShowCurrentNamespaceExec(r.output, session.sessionState.catalogManager) :: Nil
case r @ ShowTableProperties(rt: ResolvedTable, propertyKey, output) =>
ShowTablePropertiesExec(output, rt.table, propertyKey) :: Nil
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org