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. so if parent name has changed, children names will also be changed. 
But since this is an indirect change we are not adding them to the map.




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