[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #4113: [CARBONDATA-4161] Describe complex columns

Posted by GitBox on
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-ShreelekhyaG-opened-a-new-pull-request-4113-WIP-Describe-complex-columns-tp107265p107561.html


Indhumathi27 commented on a change in pull request #4113:
URL: https://github.com/apache/carbondata/pull/4113#discussion_r612958690



##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParserUtil.scala
##########
@@ -744,6 +747,47 @@ object CarbonSparkSqlParserUtil {
     CarbonAlterTableAddColumnCommand(alterTableAddColumnsModel)
   }
 
+  def describeColumn(
+      databaseNameOp: Option[String],
+      tableName: String,
+      inputFields: java.util.List[String]
+  ): CarbonDescribeColumnCommand = {
+    val (tableSchema, carbonTable) = getSchemaAndTable(databaseNameOp, tableName)
+    val inputColumn = tableSchema.find(_.name.equalsIgnoreCase(inputFields.get(0)))
+    if (!inputColumn.isDefined) {
+      throw new MalformedCarbonCommandException(
+        s"${inputFields.get(0)} not present in schema of table: $tableName")
+    }
+    CarbonDescribeColumnCommand(
+      carbonTable,
+      inputFields,
+      inputColumn.get
+    )
+  }
+
+  def describeShort(
+      databaseNameOp: Option[String],
+      tableName: String
+  ): CarbonDescribeShortCommand = {
+    val (tableSchema, carbonTable) = getSchemaAndTable(databaseNameOp, tableName)
+    CarbonDescribeShortCommand(
+      carbonTable,
+      tableSchema
+    )
+  }
+
+  def getSchemaAndTable(databaseNameOp: Option[String],
+      tableName: String) : (StructType, CarbonTable) = {
+    val sparkSession = SparkSQLUtil.getSparkSession
+    validateTableExists(databaseNameOp, tableName, sparkSession)

Review comment:
       Add a testcase for Describe column on table not exists. Looks like currently, it is not throwing Table not found, instead throws parsing error.




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