Indhumathi27 commented on a change in pull request #4180:
URL: https://github.com/apache/carbondata/pull/4180#discussion_r694885162
##########
File path:
integration/spark/src/main/scala/org/apache/spark/util/AlterTableUtil.scala
##########
@@ -1104,25 +1105,36 @@ object AlterTableUtil {
val old_column_datatype = oldDimensionInfo.getDataType.getName
val new_column_name = newDimensionInfo
.columnName.split(CarbonCommonConstants.POINT.toCharArray).last
- val new_column_datatype = newDimensionInfo.dataType
+ var new_column_datatype = newDimensionInfo.dataType
+
+ // check if column datatypes are altered. If altered, validate them
if (!old_column_datatype.equalsIgnoreCase(new_column_datatype)) {
- // datatypes of complex children cannot be altered. So throwing
exception for now.
- throw new UnsupportedOperationException(
- "Altering datatypes of any child column is not supported")
+ this.validateColumnDataType(newDimensionInfo, oldDimensionInfo)
+ alteredDatatypesMap += (oldDimensionInfo.getColName ->
new_column_datatype)
+ } else if
(old_column_datatype.equalsIgnoreCase(CarbonCommonConstants.DECIMAL) &&
+ old_column_datatype.equalsIgnoreCase(new_column_datatype)) {
+ val oldPrecision =
oldDimensionInfo.getDataType().asInstanceOf[DecimalType].getPrecision
+ val oldScale =
oldDimensionInfo.getDataType().asInstanceOf[DecimalType].getScale
+ if (oldPrecision != newDimensionInfo.precision || oldScale !=
newDimensionInfo.scale) {
+ this.validateColumnDataType(newDimensionInfo, oldDimensionInfo)
+ new_column_datatype = "decimal(" + newDimensionInfo.precision +
"," +
+ newDimensionInfo.scale + ")"
+ alteredDatatypesMap += (oldDimensionInfo.getColName ->
new_column_datatype)
+ }
}
+
+ // check if column names are altered
if (!old_column_name.equalsIgnoreCase(new_column_name)) {
alteredColumnNamesMap += (oldDimensionInfo.getColName ->
newDimensionInfo.columnName)
}
- if (old_column_datatype.equalsIgnoreCase(CarbonCommonConstants.MAP) ||
- new_column_datatype.equalsIgnoreCase(CarbonCommonConstants.MAP)) {
- throw new UnsupportedOperationException(
- "Cannot alter complex structure that includes map type column")
- } else if
(new_column_datatype.equalsIgnoreCase(CarbonCommonConstants.ARRAY) ||
+ if (new_column_datatype.equalsIgnoreCase(CarbonCommonConstants.ARRAY)
||
Review comment:
we can just check if data type is complex type here right. can move this
to new method and reuse
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]