VenuReddy2103 commented on a change in pull request #3938:
URL: https://github.com/apache/carbondata/pull/3938#discussion_r492626070



##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonShowTablesCommand.scala
##########
@@ -18,35 +18,23 @@
 package org.apache.spark.sql.execution.command.table
 
 import org.apache.spark.sql.{Row, SparkSession}
-import org.apache.spark.sql.catalyst.TableIdentifier
-import org.apache.spark.sql.catalyst.expressions.{Attribute, 
AttributeReference}
-import org.apache.spark.sql.execution.command.MetadataCommand
-import org.apache.spark.sql.types.{BooleanType, StringType}
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.execution.command.{MetadataCommand, 
ShowTablesCommand}
 
 
-private[sql] case class CarbonShowTablesCommand ( databaseName: Option[String],
-    tableIdentifierPattern: Option[String])  extends MetadataCommand{
+private[sql] case class CarbonShowTablesCommand(showTablesCommand: 
ShowTablesCommand)
+  extends MetadataCommand {
 
-  // The result of SHOW TABLES has three columns: database, tableName and 
isTemporary.
-  override val output: Seq[Attribute] = {
-    AttributeReference("database", StringType, nullable = false)() ::
-    AttributeReference("tableName", StringType, nullable = false)() ::
-    AttributeReference("isTemporary", BooleanType, nullable = false)() :: Nil
-  }
+  override val output: Seq[Attribute] = showTablesCommand.output
 
   override def processMetadata(sparkSession: SparkSession): Seq[Row] = {
-    // Since we need to return a Seq of rows, we will call getTables directly
-    // instead of calling tables in sparkSession.
-    val catalog = sparkSession.sessionState.catalog
-    val db = databaseName.getOrElse(catalog.getCurrentDatabase)
-    val tables =
-      tableIdentifierPattern.map(catalog.listTables(db, 
_)).getOrElse(catalog.listTables(db))
+    val rows = showTablesCommand.run(sparkSession)
     val externalCatalog = sparkSession.sharedState.externalCatalog
     // this method checks whether the table is mainTable or MV based on 
property "isVisible"
-    def isMainTable(tableIdent: TableIdentifier) = {
+    def isMainTable(db: String, table: String) = {

Review comment:
       I think, current one looks ok. Because, Filtered rows are implicitly 
returned at line 46. If we move this isMainTable() method def to after line 46, 
need to take filtered rows to temp and use it retured.




----------------------------------------------------------------
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:
[email protected]


Reply via email to