[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-03 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402782282
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   The `MultipartIdentifierHelper`(toSeq) will check empty, so the local temp 
view with empty database will got AnalysisException. Thus I'm reverting back to 
use `NamespaceHelper`(toArray) to make the code concise.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402742900
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   Emm, I'll change the `toArray` back to `toSeq` when I get back to my well 
configured dev machine...


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402739332
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   Find it back in 7bd9cc662528a7fcfdb1f07b6565a0e6cac8512a. Sorry for the 
mistake.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402739163
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
 
 Review comment:
   Yea, the database name should have been resolved. Thanks! Updated in 
7bd9cc662528a7fcfdb1f07b6565a0e6cac8512a.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402723336
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   Oh..I just force pushed from another machine ... Sorry. will updated it back.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402369650
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   Yea, I see. updated in 6a4348ed9e289c6ca3cc557f9a575e1829f53fc0. Thanks


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402369650
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   Yea, I see. updated in 6a4348ed9e289c6ca3cc557f9a575e1829f53fc0.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-02 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402369650
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: namespace, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
+AttributeReference("viewName", StringType, nullable = false)(),
+AttributeReference("isTemporary", BooleanType, nullable = false)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+val catalog = sparkSession.sessionState.catalog
+val db = databaseName.getOrElse(catalog.getCurrentDatabase)
+
+// Show the information of views.
+val views = tableIdentifierPattern.map(catalog.listViews(db, _))
+  .getOrElse(catalog.listViews(db, "*"))
+views.map { tableIdent =>
+  val namespace = tableIdent.database.getOrElse("")
 
 Review comment:
   I see, updated in 6a4348ed9e289c6ca3cc557f9a575e1829f53fc0.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402031682
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: database, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
 
 Review comment:
   IMO, maybe we should use `namespace` for consistency?  Anyway, I'm changing 
the comments(line 310) to get along with current code/doc, and waiting for 
final decision. Thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402031682
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: database, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("namespace", StringType, nullable = false)(),
 
 Review comment:
   IMO, as cloud-fan suggested, maybe we should use `namespace` for 
consistency?  Anyway, I'm changing the comments(line 310) to get along with 
current code/doc, and waiting for final decision. Thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402030769
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
 ##
 @@ -860,7 +860,7 @@ case class ShowTablesCommand(
   }
 
   override def run(sparkSession: SparkSession): Seq[Row] = {
-// Since we need to return a Seq of rows, we will call getTables directly
+// Since we need to return a Seq of rows, we will call listTables directly
 
 Review comment:
   Sure, reverted the changes in 55a5997bdfe34439a171d3603fc98975b7c18129.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r402030477
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -230,22 +230,19 @@ class ResolveSessionCatalog(
 
 case d @ DescribeNamespace(SessionCatalogAndNamespace(_, ns), _) =>
   if (ns.length != 1) {
-throw new AnalysisException(
-  s"The database name is not valid: ${ns.quoted}")
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   Sure, I've reverted these untouched lines. Thanks as always @dongjoon-hyun 
@maropu !


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401701575
 
 

 ##
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
 ##
 @@ -909,6 +909,23 @@ class DataSourceV2SQLSuite
 assert(exception.getMessage.contains("The database name is not valid: 
a.b"))
   }
 
+  test("ShowViews: using v1 catalog, db name with multipartIdentifier ('a.b') 
is not allowed.") {
+val exception = intercept[AnalysisException] {
+  runShowTablesSql("SHOW VIEWS FROM a.b", Seq(), expectV2Catalog = false, 
isShowView = true)
+}
+
+assert(exception.getMessage.contains("The database name is not valid: 
a.b"))
+  }
+
+  test("ShowViews: using v2 catalog, command not supported.") {
+val exception = intercept[AnalysisException] {
+  runShowTablesSql("SHOW VIEWS FROM testcat", Seq(), expectV2Catalog = 
true, isShowView = true)
 
 Review comment:
   2f8074a48c23f3c922958fa95c56cb5ffd64bc35


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401701241
 
 

 ##
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
 ##
 @@ -909,6 +909,23 @@ class DataSourceV2SQLSuite
 assert(exception.getMessage.contains("The database name is not valid: 
a.b"))
   }
 
+  test("ShowViews: using v1 catalog, db name with multipartIdentifier ('a.b') 
is not allowed.") {
+val exception = intercept[AnalysisException] {
+  runShowTablesSql("SHOW VIEWS FROM a.b", Seq(), expectV2Catalog = false, 
isShowView = true)
 
 Review comment:
   Sure, updated in 2f8074a48c23f3c922958fa95c56cb5ffd64bc35. For same case of 
`ShowTables` tests in `DataSourceV2SQLSuite`, I'll update in another PR since 
there have been some other doc/test changes need to be done based on comments 
of this PR.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-04-01 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401698771
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -545,6 +538,23 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViews(resolved: ResolvedNamespace, pattern) =>
+  resolved match {
+case SessionCatalogAndNamespace(_, ns) =>
+  // Fallback to v1 ShowViewsCommand since there is no view API in v2 
catalog
+  val namespace = if (ns.isEmpty) {
 
 Review comment:
   Yea, that's right. Updated in 2f8074a48c23f3c922958fa95c56cb5ffd64bc35 to 
get along with `ShowTables` code style, thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-31 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401291878
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,120 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that the command also lists local temporary views 
+regardless of a given database.
 
 Review comment:
   Yea, updated in 90d70196de70b7a93b01e188fda85682a65dc24e.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-31 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401291834
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,120 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that the command also lists local temporary views 
+regardless of a given database.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+  
+
+
+### Example
+{% highlight sql %}
+-- Create views in different databases, also create global/local temp views.
+CREATE VIEW sam AS SELECT id, salary FROM employee WHERE name = 'sam';
+CREATE VIEW sam1 AS SELECT id, salary FROM employee WHERE name = 'sam1';
+CREATE VIEW suj AS SELECT id, salary FROM employee WHERE name = 'suj';
+USE userdb;
+CREATE VIEW user1 AS SELECT id, salary FROM employee WHERE name = 'user1';
+CREATE VIEW user2 AS SELECT id, salary FROM employee WHERE name = 'user2';
+USE default;
+CREATE GLOBAL TEMP VIEW temp1 AS SELECT 1 as col1;
+CREATE TEMP VIEW temp2 AS SELECT 1 as col1;
+
+-- List all views in default database
+SHOW VIEWS;
+  +-++--+--+
+  | namespace   | viewName   | isTemporary  |
+  +-++--+--+
+  | default | sam| false|
+  | default | sam1   | false|
+  | default | suj| false|
+  | | temp2  | true |
+  +-++--+--+
+
+-- List all views from userdb database 
+SHOW VIEWS FROM userdb;
+  +-++--+--+
+  | namespace   | viewName   | isTemporary  |
+  +-++--+--+
+  | userdb  | user1  | false|
+  | userdb  | user2  | false|
+  | | temp2  | true |
+  +-++--+--+
+  
+-- List all views in global temp view database 
+SHOW VIEWS IN global_temp;
+  +-++--+--+
+  | namespace   | viewName   | isTemporary  |
+  +-++--+--+
+  | global_temp | temp1  | true |
+  | | temp2  | true |
+  +-++--+--+
+
+-- List all views from default database matching the pattern `sam*`
+SHOW VIEWS FROM default LIKE 'sam*';
+  +---++--+--+
+  | namespace | viewName   | isTemporary  |
+  +---++--+--+
+  | default   | sam| false|
+  | default   | sam1   | false|
+  +---++--+--+
+
+-- List all views matching the pattern `sam|suj|temp*`
 
 Review comment:
   Updated in 90d70196de70b7a93b01e188fda85682a65dc24e, thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-31 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401291743
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
 ##
 @@ -343,6 +343,15 @@ case class ShowTableStatement(
 partitionSpec: Option[TablePartitionSpec])
   extends ParsedStatement
 
+/**
+ * A SHOW VIEWS statement, as parsed from SQL.
+ */
+case class ShowViewsStatement(
 
 Review comment:
   Thanks for the suggestions, updated in 
90d70196de70b7a93b01e188fda85682a65dc24e using v2 style `ShowViews`.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-31 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r401068120
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
 ##
 @@ -343,6 +343,15 @@ case class ShowTableStatement(
 partitionSpec: Option[TablePartitionSpec])
   extends ParsedStatement
 
+/**
+ * A SHOW VIEWS statement, as parsed from SQL.
+ */
+case class ShowViewsStatement(
 
 Review comment:
   @cloud-fan I did the implementation and got two more questions:
   1. With the v2 command style, we need to extend the `CatalogPlugin` to 
support view related interface. Which way do you prefer, add listViews function 
to `TableCatalog` or add new interface `SupportViews`? 
   2. The current `CatalogPlugin` also does not support `isTemporaryTable` 
check, so the v2 `ShowTablesExec` and `ShowViewsExec` can not support the 
isTemporary output column. Do we need to handle it here?
   
   Directly calling `SessionCatalog` API instead of  'CatalogPlugin' seems not 
elegant here, right?


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-31 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r400975336
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
 ##
 @@ -343,6 +343,15 @@ case class ShowTableStatement(
 partitionSpec: Option[TablePartitionSpec])
   extends ParsedStatement
 
+/**
+ * A SHOW VIEWS statement, as parsed from SQL.
+ */
+case class ShowViewsStatement(
 
 Review comment:
   Thanks so much for the background introduction! I think I misunderstood the 
scope between V2 command and V2 SessionCatalog, that's why I wrongly followed 
V1 command style before. 
   Sure, I'll update it to V2 command.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-29 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399800015
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   Updated and added a negative test case in `DataSourceV2SQLSuite`


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-27 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399600314
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   Thanks so much for the clarification, @cloud-fan ! I did some try and still 
working on this, will update soon.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-27 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399406192
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   I see, thanks so much for your clarification, @cloud-fan ! 
`SessionCatalogAndNamespace` is a support function to make sure the resolved 
catalog is `SessionCatalog`, which supports several V1 commands. So I think 
maybe we should just throw `AnalysisException` in `SessionCatalogAndNamespace`? 
WDYT, updated in d14b4fa698873cf0eef4f1ca50b9a501c5cd868e.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-27 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399406192
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   I see, thanks so much for your clarification, @cloud-fan ! 
`SessionCatalogAndNamespace` is a support function to make sure the resolved 
catalog is `SessionCatalog`, which supports several V1 commands. So I think 
maybe we should just throw `AnalysisException` in `SessionCatalogAndNamespace`? 
WDYT, updated in d14b4fa698873cf0eef4f1ca50b9a501c5cd868e.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-27 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399403252
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: database, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("database", StringType, nullable = false)(),
 
 Review comment:
   Updated in d14b4fa698873cf0eef4f1ca50b9a501c5cd868e, thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-27 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r399402971
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,125 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that the command always lists global and temporary 
views 
+regardless of a given database.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+  
+
+
+### Example
+{% highlight sql %}
+-- Create views in different databases, also create global/local temp views.
+CREATE VIEW sam AS SELECT id, salary FROM employee WHERE name = 'sam';
+CREATE VIEW sam1 AS SELECT id, salary FROM employee WHERE name = 'sam1';
+CREATE VIEW suj AS SELECT id, salary FROM employee WHERE name = 'suj';
+USE userdb;
+CREATE VIEW user1 AS SELECT id, salary FROM employee WHERE name = 'user1';
+CREATE VIEW user2 AS SELECT id, salary FROM employee WHERE name = 'user2';
+USE default;
+CREATE GLOBAL TEMP VIEW temp1 AS SELECT 1 as col1;
+CREATE TEMP VIEW temp2 AS SELECT 1 as col1;
+
+-- List all views in default database
+SHOW VIEWS;
+  +-++--+--+
+  | database| viewName   | isTemporary  |
+  +-++--+--+
+  | default | sam| false|
+  | default | sam1   | false|
+  | default | suj| false|
+  | global_temp | temp1  | true |
 
 Review comment:
   Thanks for your suggestions! Updated in 
d14b4fa698873cf0eef4f1ca50b9a501c5cd868e.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-25 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r397975602
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   Sorry, I'm not quite sure about the question. The `SHOW VIEWS` will resolve 
to V1 SessionCatalog which supports `listViews` I think. Do you mean a custom 
catalog implements `TableCatalog`(does not support view related commands) will 
got error? I'll keep learning the `CatalogPlugIn` related code, any suggestions 
would be helpful to me, thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-25 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r397975602
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
 
 Review comment:
   Actually, I'm not quite sure about the question. The `SHOW VIEWS` will 
resolve to V1 SessionCatalog which supports `listViews` I think. Do you mean a 
custom catalog implements `TableCatalog`(does not support view related 
commands) will got error? I'll keep learning the `CatalogPlugIn` related code, 
any suggestions would be helpful to me, thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-25 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r397969899
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -295,6 +295,41 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW VIEWS has three basic columns: database, viewName and 
isTemporary.
+  override val output: Seq[Attribute] = Seq(
+AttributeReference("database", StringType, nullable = false)(),
 
 Review comment:
   Currently `VIEW` related commands are only supported in `v1 SessionCatalog`, 
maybe we can keep it along with V1 abstraction? The `SHOW TABLES` will resolve 
to v2 `ShowTablesExec` which use attrName `namespace`, while in the v1 version 
`ShowTablesCommand` it still using attrName `database`.  WDYT @cloud-fan , I'm 
OK with both decision  :-)


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394414248
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -363,6 +370,15 @@ private[client] class Shim_v0_12 extends Shim with 
Logging {
 conf.getIntVar(HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY) * 
1000L
   }
 
+  override def getTablesByType(
+  hive: Hive,
+  dbName: String,
+  pattern: String,
+  tableType: TableType): Seq[String] = {
+throw new UnsupportedOperationException("Hive 2.2 and lower versions don't 
support " +
 
 Review comment:
   Yea, I'll implement that way instead of throwing error. Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394414248
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -363,6 +370,15 @@ private[client] class Shim_v0_12 extends Shim with 
Logging {
 conf.getIntVar(HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY) * 
1000L
   }
 
+  override def getTablesByType(
+  hive: Hive,
+  dbName: String,
+  pattern: String,
+  tableType: TableType): Seq[String] = {
+throw new UnsupportedOperationException("Hive 2.2 and lower versions don't 
support " +
 
 Review comment:
   Yea, I'll implement that way instead of throwing exception. Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394407094
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -363,6 +370,15 @@ private[client] class Shim_v0_12 extends Shim with 
Logging {
 conf.getIntVar(HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY) * 
1000L
   }
 
+  override def getTablesByType(
+  hive: Hive,
+  dbName: String,
+  pattern: String,
+  tableType: TableType): Seq[String] = {
+throw new UnsupportedOperationException("Hive 2.2 and lower versions don't 
support " +
 
 Review comment:
   Yea, before I notice the API `getTablesByType`, I was planning to implement 
it by that way. But for `HiveExternalCatalog`, calling 
`HiveClient.getTableOption` for each table would be too heavy, right?  Maybe we 
can fallback to `listTables+filter` way if `getTablesByType` not supported. And 
for hive 2.3+, we use the efficient way?  Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394407094
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -363,6 +370,15 @@ private[client] class Shim_v0_12 extends Shim with 
Logging {
 conf.getIntVar(HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY) * 
1000L
   }
 
+  override def getTablesByType(
+  hive: Hive,
+  dbName: String,
+  pattern: String,
+  tableType: TableType): Seq[String] = {
+throw new UnsupportedOperationException("Hive 2.2 and lower versions don't 
support " +
 
 Review comment:
   Yea, before I notice the API `getTablesByType`, I was planning to implement 
it by that way. But for `HiveExternalCatalog`, calling 
`HiveClient.getTableOption` for each table would be too heavy, right?  Maybe we 
can fallback to `listTables+filter` way if `getTablesByType` not supported. And 
for hive 2.3+, we use the efficient way?  Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394213754
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -1220,7 +1236,24 @@ private[client] class Shim_v2_1 extends Shim_v2_0 {
 
 private[client] class Shim_v2_2 extends Shim_v2_1
 
-private[client] class Shim_v2_3 extends Shim_v2_1
+private[client] class Shim_v2_3 extends Shim_v2_1 {
+  private lazy val getTablesByTypeMethod =
+findMethod(
+  classOf[Hive],
+  "getTablesByType",
+  classOf[String],
+  classOf[String],
+  classOf[TableType])
 
 Review comment:
   @dongjoon-hyun @maropu Would you plz share some experience on building with 
hive nightly version `2.3.7-SNAPSHOT`? I tried with modify hive version in 
`pom.xml`, but it didn't work. Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394213754
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -1220,7 +1236,24 @@ private[client] class Shim_v2_1 extends Shim_v2_0 {
 
 private[client] class Shim_v2_2 extends Shim_v2_1
 
-private[client] class Shim_v2_3 extends Shim_v2_1
+private[client] class Shim_v2_3 extends Shim_v2_1 {
+  private lazy val getTablesByTypeMethod =
+findMethod(
+  classOf[Hive],
+  "getTablesByType",
+  classOf[String],
+  classOf[String],
+  classOf[TableType])
 
 Review comment:
   @dongjoon-hyun @maropu Would you plz share some experience on building with 
hive nightly version `2.3.7-SNAPSHOT`. I tried with modify hive version in 
`pom.xml`, but it didn't work. Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394213754
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -1220,7 +1236,24 @@ private[client] class Shim_v2_1 extends Shim_v2_0 {
 
 private[client] class Shim_v2_2 extends Shim_v2_1
 
-private[client] class Shim_v2_3 extends Shim_v2_1
+private[client] class Shim_v2_3 extends Shim_v2_1 {
+  private lazy val getTablesByTypeMethod =
+findMethod(
+  classOf[Hive],
+  "getTablesByType",
+  classOf[String],
+  classOf[String],
+  classOf[TableType])
 
 Review comment:
   @dongjoon-hyun @maropu Would you plz share some experience on building with 
hive nightly version `2.3.7-SNAPSHOT`? I tried with modify hive version in 
`pom.xml`, but it didn't work. Thanks!


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-18 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394213754
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -1220,7 +1236,24 @@ private[client] class Shim_v2_1 extends Shim_v2_0 {
 
 private[client] class Shim_v2_2 extends Shim_v2_1
 
-private[client] class Shim_v2_3 extends Shim_v2_1
+private[client] class Shim_v2_3 extends Shim_v2_1 {
+  private lazy val getTablesByTypeMethod =
+findMethod(
+  classOf[Hive],
+  "getTablesByType",
+  classOf[String],
+  classOf[String],
+  classOf[TableType])
 
 Review comment:
   @dongjoon-hyun @maropu Would you plz share some experience on building with 
hive nightly version `2.3.7-SNAPSHOT`. I tried with modify hive version in 
`pom.xml`, but it didn't work.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-17 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394099946
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/inputs/show-views.sql
 ##
 @@ -0,0 +1,31 @@
+-- Test data.
+CREATE DATABASE showdb;
+USE showdb;
+CREATE TABLE tbl(a String, b Int, c String, d String) USING parquet;
+CREATE VIEW view_1 AS SELECT * FROM tbl;
+CREATE VIEW view_2 AS SELECT * FROM tbl WHERE c='a';
+CREATE TEMPORARY VIEW view_3(e int) USING parquet;
+CREATE GLOBAL TEMP VIEW view_4 AS SELECT 1 as col1;
+
+-- SHOW VIEWS
+SHOW VIEWS;
+SHOW VIEWS FROM showdb;
+SHOW VIEWS IN showdb;
+SHOW VIEWS IN global_temp;
+
+-- SHOW VIEWS WITH wildcard match
+SHOW VIEWS 'view_*';
+SHOW VIEWS LIKE 'view_1*|view_2*';
+SHOW VIEWS IN showdb 'view_*';
+SHOW VIEWS IN showdb LIKE 'view_*';
+-- Error when database not exists
+SHOW VIEWS IN wrongdb LIKE 'view_*';
+
+-- Clean Up
+DROP VIEW view_1;
+DROP VIEW view_2;
+DROP VIEW view_3;
+DROP VIEW global_temp.view_4;
+DROP TABLE tbl;
+USE default;
+DROP DATABASE showdb;
 
 Review comment:
   Yea, sure.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-17 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394100097
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala
 ##
 @@ -1220,7 +1236,24 @@ private[client] class Shim_v2_1 extends Shim_v2_0 {
 
 private[client] class Shim_v2_2 extends Shim_v2_1
 
-private[client] class Shim_v2_3 extends Shim_v2_1
+private[client] class Shim_v2_3 extends Shim_v2_1 {
+  private lazy val getTablesByTypeMethod =
+findMethod(
+  classOf[Hive],
+  "getTablesByType",
+  classOf[String],
+  classOf[String],
+  classOf[TableType])
 
 Review comment:
   I see, I'll test it manually.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-17 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394099868
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,125 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that the command always lists global and temporary 
views 
+regardless of a given database.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+
 
 Review comment:
   Emm, just copied from `SHOW TABLES` doc, I don't see a reason for this line. 
Removed in 475f21e248f9102e93263c75d7f2ef710fe4c9e1, thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-17 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r394099580
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,125 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that the command always lists global and temporary 
views 
+regardless of a given database.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+
+  
+
+
+### Example
+{% highlight sql %}
+-- Create views in different databases, also create global/local temp views.
+CREATE VIEW sam AS SELECT id, salary FROM employee WHERE name = 'sam';
+CREATE VIEW sam1 AS SELECT id, salary FROM employee WHERE name = 'sam1';
+CREATE VIEW suj AS SELECT id, salary FROM employee WHERE name = 'suj';
+USE userdb;
+CREATE VIEW user1 AS SELECT id, salary FROM employee WHERE name = 'user1';
+CREATE VIEW user2 AS SELECT id, salary FROM employee WHERE name = 'user2';
+USE default;
+CREATE GLOBAL TEMP VIEW temp1 AS SELECT 1 as col1;
+CREATE TEMP VIEW temp2 AS SELECT 1 as col1;
+
+-- List all views in default database
+SHOW VIEWS;
+  +-++--+--+
+  | database| viewName   | isTemporary  |
+  +-++--+--+
+  | default | sam| false|
+  | default | sam1   | false|
+  | default | suj| false|
+  | global_temp | temp1  | true |
+  | | temp2  | true |
+  +-++--+--+
+
+-- List all views from userdb database 
+SHOW VIEWS FROM userdb;
+  +-++--+--+
+  | database| viewName   | isTemporary  |
+  +-++--+--+
+  | userdb  | user1  | false|
+  | userdb  | user2  | false|
+  | global_temp | temp1  | true |
+  | | temp2  | true |
+  +-++--+--+
+
+-- List all views in userdb database
+SHOW VIEWS IN userdb;
+  +-++--+--+
+  | database| viewName   | isTemporary  |
+  +-++--+--+
+  | userdb  | user1  | false|
+  | userdb  | user2  | false|
+  | global_temp | temp1  | true |
+  | | temp2  | true |
+  +-++--+--+
+
+-- List all views from default database matching the pattern `sam*`
+SHOW VIEWS FROM default LIKE 'sam*';
+  +---++--+--+
+  | database  | viewName   | isTemporary  |
+  +---++--+--+
+  | default   | sam| false|
+  | default   | sam1   | false|
+  +---++--+--+
+  
+-- List all views matching the pattern `sam*|suj`
+SHOW VIEWS LIKE 'sam*|suj';
 
 Review comment:
   Yea, updated in 475f21e248f9102e93263c75d7f2ef710fe4c9e1.


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 

[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393454589
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   Yea, updated in 1d56c0e4fbe9a26232d6856a253371d16f24d4da, add negative test 
case.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393420719
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,107 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that both global and local temporary views are also 
returned.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+
+  
+
+
+### Example
+{% highlight sql %}
+-- List all views in default database
 
 Review comment:
   I see, updated in dc6e3cb21e5de2a2c591b42014cc03fc4418cca3. Will update 
`SHOW TABLES` in follow-up PR. Thanks


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393428635
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   When creating database/namespace like `CREATE NAMESPACE ns1.ns2`, it throws 
invalid database name error. Does it related V2 Session Catalog or some other 
reasons? Sorry for my lack of related knowledge.  I'm keep investigating this. 
Thanks


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393428635
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   When creating database/namespace like `CREATE NAMESPACE ns1.ns2`, it throws 
invalid database name error. Does it related V2 Session Catalog or some other 
reasons? Sorry for my lack of related knowledge.  I'm keep investigating this. 
Thanks


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393428635
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   When creating database/namespace like `CREATE NAMESPACE ns1.ns2`, it throws 
invalid database name error. Does it related V2 Session Catalog or some other 
reasons? Sorry for my lack of related knowledge. 


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393428635
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   When creating database/namespace like `CREATE NAMESPACE ns1.ns2`, it throw 
invalid database name error. Does it related V2 Session Catalog or some other 
reason? Sorry for my lack of related knowledge. 


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393428635
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +523,16 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(s"The database name is not valid: 
${ns.quoted}")
 
 Review comment:
   When creating database/namespace like `CREATE NAMESPACE ns1.ns2`, it throws 
invalid database name error. Does it related V2 Session Catalog or some other 
reason? Sorry for my lack of related knowledge. 


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393421268
 
 

 ##
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
 ##
 @@ -755,6 +755,10 @@ private[hive] class HiveClientImpl(
 client.getTablesByPattern(dbName, pattern).asScala
   }
 
+  override def listViews(dbName: String, pattern: String): Seq[String] = 
withHiveState {
+shim.getTablesByType(client, dbName, pattern, HiveTableType.VIRTUAL_VIEW)
+  }
 
 Review comment:
   Yea, updated in dc6e3cb21e5de2a2c591b42014cc03fc4418cca3. Not sure if it's 
enough.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393421062
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
 ##
 @@ -280,6 +280,44 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * A command for users to get views in the given database.
+ * If a databaseName is not given, the current database will be used.
+ * The syntax of using this command in SQL is:
+ * {{{
+ *   SHOW VIEWS [(IN|FROM) database_name] [[LIKE] 'identifier_with_wildcards'];
+ * }}}
+ */
+case class ShowViewsCommand(
+databaseName: Option[String],
+tableIdentifierPattern: Option[String]) extends RunnableCommand {
+
+  // The result of SHOW TABLES/SHOW TABLE has three basic columns: database, 
tableName and
+  // isTemporary. If `isExtended` is true, append column `information` to the 
output columns.
 
 Review comment:
   Oops, my mistake. Updated in dc6e3cb21e5de2a2c591b42014cc03fc4418cca3.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-16 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r393420719
 
 

 ##
 File path: docs/sql-ref-syntax-aux-show-views.md
 ##
 @@ -0,0 +1,107 @@
+---
+layout: global
+title: SHOW VIEWS
+displayTitle: SHOW VIEWS
+license: |
+  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.
+---
+### Description
+
+The `SHOW VIEWS` statement returns all the views for an optionally specified 
database.
+Additionally, the output of this statement may be filtered by an optional 
matching
+pattern. If no database is specified then the views are returned from the 
+current database. Note that both global and local temporary views are also 
returned.
+
+### Syntax
+{% highlight sql %}
+SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ]
+{% endhighlight %}
+
+### Parameters
+
+  { FROM | IN } database_name
+  
+ Specifies the database name from which views are listed.
+  
+  LIKE regex_pattern
+  
+ Specifies the regular expression pattern that is used to filter out 
unwanted views. 
+  
+   Except for `*` and `|` character, the pattern works like a 
regex.
+   `*` alone matches 0 or more characters and `|` is used to 
separate multiple different regexes,
+   any of which can match. 
+   The leading and trailing blanks are trimmed in the input 
pattern before processing.
+ 
+
+  
+
+
+### Example
+{% highlight sql %}
+-- List all views in default database
 
 Review comment:
   I see, udpated in dc6e3cb21e5de2a2c591b42014cc03fc4418cca3. Will update 
`SHOW TABLES` in follow-up PR. Thanks


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671951
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/results/show-views.sql.out
 ##
 @@ -0,0 +1,211 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 21
+
+
+-- !query
+CREATE DATABASE showdb
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+USE showdb
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE tbl(a String, b Int, c String, d String) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE VIEW view_1 AS SELECT * FROM tbl
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE VIEW view_2 AS SELECT * FROM tbl WHERE c='a'
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TEMPORARY VIEW view_3(e int) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE GLOBAL TEMP VIEW view_4 AS SELECT 1 as col1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SHOW VIEWS
+-- !query schema
+struct
 
 Review comment:
   I just found `HiveResult.hiveResultString` is used to update query result in 
Hive compatible form for `ShowTablesCommand`. Also add transform rule for 
`ShowViewsCommand` and updated PR description. Thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671512
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/inputs/show-views.sql
 ##
 @@ -0,0 +1,28 @@
+-- Test data.
+CREATE DATABASE showdb;
+USE showdb;
+CREATE TABLE tbl(a String, b Int, c String, d String) USING parquet;
+CREATE VIEW view_1 AS SELECT * FROM tbl;
+CREATE VIEW view_2 AS SELECT * FROM tbl WHERE c='a';
+CREATE TEMPORARY VIEW view_3(e int) USING parquet;
+CREATE GLOBAL TEMP VIEW view_4 AS SELECT 1 as col1;
+
+-- SHOW VIEWS
+SHOW VIEWS;
+SHOW VIEWS FROM showdb;
+SHOW VIEWS IN showdb;
+SHOW VIEWS IN global_temp;
+
+-- SHOW VIEWS WITH wildcard match
+SHOW VIEWS 'view_*';
+SHOW VIEWS LIKE 'view_1*|view_2*';
+SHOW VIEWS IN showdb 'view_*';
 
 Review comment:
   Sure, updated/added tests for `show-views.sql` and `show-tables.sql` in 
c5570d249426a821896ab85e37bf2e0c1d9a39ee.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671394
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -366,8 +366,8 @@ class ResolveSessionCatalog(
 case ShowTables(SessionCatalogAndNamespace(_, ns), pattern) =>
   assert(ns.nonEmpty)
   if (ns.length != 1) {
-  throw new AnalysisException(
-s"The database name is not valid: ${ns.quoted}")
+throw new AnalysisException(
+  s"The database name is not valid: ${ns.quoted}")
 
 Review comment:
   Yea, removed the line break for all cases in this file.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671408
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##
 @@ -530,6 +530,17 @@ class ResolveSessionCatalog(
 replace,
 viewType)
 
+case ShowViewsStatement(SessionCatalogAndNamespace(_, ns), pattern) =>
+  val namespace = if (ns.isEmpty) {
+None
+  } else if (ns.length == 1) {
+Some(ns.head)
+  } else {
+throw new AnalysisException(
+  s"The database name is not valid: ${ns.quoted}")
 
 Review comment:
   I see.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671362
 
 

 ##
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
 ##
 @@ -1260,6 +1260,21 @@ class DDLParserSuite extends AnalysisTest {
 Some(Map("ds" -> "2008-04-09"
   }
 
+  test("show views") {
+comparePlans(
+  parsePlan("SHOW VIEWS"),
+  ShowViewsStatement(UnresolvedNamespace(Seq.empty[String]), None))
+comparePlans(
+  parsePlan("SHOW VIEWS FROM testcat.ns1.ns2.tbl"),
+  ShowViewsStatement(UnresolvedNamespace(Seq("testcat", "ns1", "ns2", 
"tbl")), None))
+comparePlans(
+  parsePlan("SHOW VIEWS IN testcat.ns1.ns2.tbl"),
+  ShowViewsStatement(UnresolvedNamespace(Seq("testcat", "ns1", "ns2", 
"tbl")), None))
+comparePlans(
+  parsePlan("SHOW VIEWS IN tbl LIKE '*dog*'"),
 
 Review comment:
   Sure, add/update tests for `SHOW VIEWS` and `SHOW TABLES`.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671221
 
 

 ##
 File path: docs/sql-ref-ansi-compliance.md
 ##
 @@ -404,6 +404,7 @@ Below is a list of all the keywords in Spark SQL.
   
USINGreservedstrict-non-reservedreserved
   
VALUESnon-reservednon-reservedreserved
   
VIEWnon-reservednon-reservednon-reserved
+  
VIEWSnon-reservednon-reservednon-reserved
 
 Review comment:
   Sure, updated in c5570d249426a821896ab85e37bf2e0c1d9a39ee.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-15 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392671281
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
 ##
 @@ -346,6 +346,13 @@ class InMemoryCatalog(
 StringUtils.filterPattern(listTables(db), pattern)
   }
 
+  override def listViews(db: String, pattern: String): Seq[String] = 
synchronized {
+requireDbExists(db)
+val views = catalog(db).tables.filter(v => v._2.table.tableType == 
CatalogTableType.VIEW)
 
 Review comment:
   Thanks, updated in c5570d249426a821896ab85e37bf2e0c1d9a39ee.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-12 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392008757
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
 ##
 @@ -343,6 +343,15 @@ case class ShowTableStatement(
 partitionSpec: Option[TablePartitionSpec])
   extends ParsedStatement
 
+/**
+ * A SHOW VIEWS statement, as parsed from SQL.
+ */
+case class ShowViewsStatement(
+namespace: LogicalPlan,
+pattern: Option[String]) extends ParsedStatement {
+  override def children: Seq[LogicalPlan] = Seq(namespace)
+}
 
 Review comment:
   It seems we only provide views in v1 SessionCatalog, so I implemented 
ShowViews along with v1 style.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add SHOW VIEWS command

2020-03-12 Thread GitBox
Eric5553 commented on a change in pull request #27897: [SPARK-31113][SQL] Add 
SHOW VIEWS command
URL: https://github.com/apache/spark/pull/27897#discussion_r392008039
 
 

 ##
 File path: 
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
 ##
 @@ -174,7 +174,7 @@ statement
 SET TBLPROPERTIES tablePropertyList
#setTableProperties
 | ALTER (TABLE | VIEW) multipartIdentifier
 UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList 
#unsetTableProperties
-|ALTER TABLE table=multipartIdentifier
+| ALTER TABLE table=multipartIdentifier
 
 Review comment:
   fix indent


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org