Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/3027#discussion_r244270598
--- Diff:
integration/spark2/src/main/commonTo2.2And2.3/org/apache/spark/sql/hive/CarbonSessionUtil.scala
---
@@ -93,4 +98,34 @@ object CarbonSessionUtil {
)
}
+ /**
+ * This method alter the table for datatype change or column rename
operation, and update the
+ * external catalog directly
+ *
+ * @param tableIdentifier tableIdentifier for table
+ * @param cols all the column of table, which are updated
with datatype change of
+ * new column name
+ * @param schemaParts schemaParts
+ * @param sparkSession sparkSession
+ */
+ def alterExternalCatalogForTableWithUpdatedSchema(tableIdentifier:
TableIdentifier,
+ cols: Option[Seq[ColumnSchema]],
+ schemaParts: String,
+ sparkSession: SparkSession): Unit = {
+ val carbonTable =
CarbonEnv.getCarbonTable(tableIdentifier)(sparkSession)
+ val colArray: scala.collection.mutable.ArrayBuffer[StructField] =
ArrayBuffer()
+ cols.get.foreach(column =>
+ if (!column.isInvisible) {
+ colArray += StructField(column.getColumnName,
+ SparkTypeConverter
+ .convertCarbonToSparkDataType(column,
+ carbonTable))
+ }
+ )
+ sparkSession.sessionState.catalog.externalCatalog
+ .alterTableDataSchema(tableIdentifier.database.get,
--- End diff --
add a comment for the usage of API `alterTableDataSchema` to explain its
purpose
---