Github user manishgupta88 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2990#discussion_r242870457 --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonHiveMetaStore.scala --- @@ -199,11 +202,22 @@ class CarbonHiveMetaStore extends CarbonFileMetastore { */ override def revertTableSchemaInAlterFailure(carbonTableIdentifier: CarbonTableIdentifier, thriftTableInfo: format.TableInfo, - identifier: AbsoluteTableIdentifier) + identifier: AbsoluteTableIdentifier, + timeStamp: Long) (sparkSession: SparkSession): String = { val schemaConverter = new ThriftWrapperSchemaConverterImpl val evolutionEntries = thriftTableInfo.fact_table.schema_evolution.schema_evolution_history - evolutionEntries.remove(evolutionEntries.size() - 1) + // we may need to remove two evolution entries if the operation is both col rename and datatype + // change operation + if (evolutionEntries.size() > 1 && (evolutionEntries.get(evolutionEntries.size() - 1).time_stamp + == evolutionEntries.get(evolutionEntries.size() - 2).time_stamp)) { + evolutionEntries.remove(evolutionEntries.size() - 1) + evolutionEntries.remove(evolutionEntries.size() - 2) + } else { + if (evolutionEntries.get(evolutionEntries.size() - 1).time_stamp == timeStamp) { + evolutionEntries.remove(evolutionEntries.size() - 1) + } --- End diff -- Same comment as above
---