Login  Register

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

Posted by GitBox on Apr 07, 2021; 5:11am
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-tp107265p107421.html


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



##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParserUtil.scala
##########
@@ -744,6 +747,52 @@ object CarbonSparkSqlParserUtil {
     CarbonAlterTableAddColumnCommand(alterTableAddColumnsModel)
   }
 
+
+  def describeColumn(
+      databaseNameOp: Option[String],
+      tableName: String,
+      inputFields: java.util.List[String]
+  ): CarbonDescribeColumnCommand = {
+    val sparkSession = SparkSQLUtil.getSparkSession
+    validateTableExists(databaseNameOp, tableName, sparkSession)
+    val relation = CarbonEnv
+      .getInstance(sparkSession)
+      .carbonMetaStore
+      .lookupRelation(databaseNameOp, tableName)(sparkSession)
+      .asInstanceOf[CarbonRelation]
+    val tableSchema = StructType.fromAttributes(relation.output)
+    val carbonTable = relation.carbonTable
+    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 sparkSession = SparkSQLUtil.getSparkSession
+    validateTableExists(databaseNameOp, tableName, sparkSession)

Review comment:
       done




--
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]