Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2806#discussion_r224029719
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/RefreshCarbonTableCommand.scala
---
@@ -118,6 +122,26 @@ case class RefreshCarbonTableCommand(
Seq.empty
}
+ /**
+ * Refresh the sort_column flag in column schema in case of old store.
Before V3, sort_column
+ * option is not set but by default all dimension columns should be
treated
+ * as sort columns if SORT_COLUMNS property is not defined in
tblproperties
+ *
+ * @param tableInfo
+ */
+ def refreshColumnSchema(tableInfo: TableInfo): Unit = {
+ val tableProps: mutable.Map[String, String] =
tableInfo.getFactTable.getTableProperties.asScala
+ val sortColumns = tableProps.get(CarbonCommonConstants.SORT_COLUMNS)
+ sortColumns match {
+ case Some(sortColumn) =>
+ // don't do anything
+ case None =>
+ // iterate over all the columns and make all the dimensions as
sort columns true
+ tableInfo.getFactTable.getListOfColumns.asScala
+ .filter(column =>
column.isDimensionColumn).foreach(_.setSortColumn(true))
--- End diff --
no need to look over listOfColumns 2 times. can use collect instead of
filter and foreach
---