jackylk commented on a change in pull request #3485: [CARBONDATA-3596] Fix exception when execute load data command or select sql on a table which includes complex columns after execute 'add column' command
URL:
https://github.com/apache/carbondata/pull/3485#discussion_r353002150
##########
File path: integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
##########
@@ -263,10 +269,26 @@ class AlterTableColumnSchemaGenerator(
alterTableModel.databaseName.getOrElse(dbName),
isSortColumn(field.name.getOrElse(field.column)),
isVarcharColumn(field.name.getOrElse(field.column)))
- allColumns ++= Seq(columnSchema)
+ if (columnSchema.getDataType == DataTypes.VARCHAR) {
+ // put the new long string columns in 'longStringCols'
+ // and add them after old long string columns
+ longStringCols ++= Seq(columnSchema)
+ } else {
+ allColumns ++= Seq(columnSchema)
+ }
newCols ++= Seq(columnSchema)
})
+ // put the old long string columns
+ allColumns ++= tableCols.filter(x =>
+ (x.isDimensionColumn && (x.getDataType == DataTypes.VARCHAR)))
+ // put the new long string columns
+ allColumns ++= longStringCols
+ // put complex type columns at the end of dimension columns
+ allColumns ++= tableCols.filter(x =>
+ (x.isDimensionColumn && (x.getDataType.isComplexType() || x.getSchemaOrdinal == -1)))
+ // original measure columns
allColumns ++= tableCols.filter(x => !x.isDimensionColumn)
+ // add new measure columns
alterTableModel.msrCols.foreach(field => {
val encoders = new java.util.ArrayList[Encoding]()
val columnSchema: ColumnSchema = TableNewProcessor.createColumnSchema(
Review comment:
please remove the empty file 'log'
----------------------------------------------------------------
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]
With regards,
Apache Git Services