Posted by
GitBox on
May 25, 2021; 12:24pm
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-akkio-97-opened-a-new-pull-request-4129-WIP-alter-rename-complex-types-tp108015p108387.html
akkio-97 commented on a change in pull request #4129:
URL:
https://github.com/apache/carbondata/pull/4129#discussion_r638737516##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableColRenameDataTypeChangeCommand.scala
##########
@@ -217,20 +310,52 @@ private[sql] case class CarbonAlterTableColRenameDataTypeChangeCommand(
.setPrecision(newColumnPrecision)
columnSchema.setScale(newColumnScale)
}
- if (newColumnComment.isDefined && columnSchema.getColumnProperties != null) {
- columnSchema.getColumnProperties.put(
- CarbonCommonConstants.COLUMN_COMMENT, newColumnComment.get)
- } else if (newColumnComment.isDefined) {
- val newColumnProperties = new util.HashMap[String, String]
- newColumnProperties.put(CarbonCommonConstants.COLUMN_COMMENT, newColumnComment.get)
- columnSchema.setColumnProperties(newColumnProperties)
+ // only table columns are eligible to have comment
+ if (!isComplexChild(columnSchema)) {
+ if (newColumnComment.isDefined && columnSchema.getColumnProperties != null) {
+ columnSchema.getColumnProperties.put(
+ CarbonCommonConstants.COLUMN_COMMENT, newColumnComment.get)
+ } else if (newColumnComment.isDefined) {
+ val newColumnProperties = new util.HashMap[String, String]
+ newColumnProperties.put(CarbonCommonConstants.COLUMN_COMMENT, newColumnComment.get)
+ columnSchema.setColumnProperties(newColumnProperties)
+ }
+ addColumnSchema = columnSchema
+ timeStamp = System.currentTimeMillis()
+ // make a new schema evolution entry after column rename or datatype change
+ schemaEvolutionEntry = AlterTableUtil
+ .addNewSchemaEvolutionEntry(timeStamp, addColumnSchema, deletedColumnSchema)
+ }
+ }
+
+ if (alteredColumnNamesMap.nonEmpty) {
+ // if complex-child or its children has been renamed
+ if (alteredColumnNamesMap.contains(columnSchemaName)) {
+ // matches exactly
+ val newComplexChildName = alteredColumnNamesMap(columnSchemaName)
+ columnSchema.setColumn_name(newComplexChildName)
+ } else {
+ val oldParent = checkIfParentIsAltered(columnSchemaName)
Review comment:
alteredColumnNamesMap only contains those columns whose names have been changed. Its children's names should also be changed according to the parent name change.
--
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]