Github user kumarvishal09 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/3045#discussion_r245273039
  
    --- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateTableHelper.scala
 ---
    @@ -110,22 +109,42 @@ case class PreAggregateTableHelper(
         // Datamap table name and columns are automatically added prefix with 
parent table name
         // in carbon. For convenient, users can type column names same as the 
ones in select statement
         // when config dmproperties, and here we update column names with 
prefix.
    -    val longStringColumn = 
tableProperties.get(CarbonCommonConstants.LONG_STRING_COLUMNS)
    +    // If longStringColumn is not present in dmproperties then we take 
long_string_columns from
    +    // the parent table.
    +    var longStringColumn = 
tableProperties.get(CarbonCommonConstants.LONG_STRING_COLUMNS)
    +    val longStringColumnInParents = 
parentTable.getTableInfo.getFactTable.getTableProperties.asScala
    +      .getOrElse(CarbonCommonConstants.LONG_STRING_COLUMNS, 
"").split(",").map(_.trim)
    +    var varcharDatamapFields = ""
    +    fieldRelationMap foreach (fields => {
    +      val aggFunc = fields._2.aggregateFunction
    +      if (aggFunc == "") {
    +        val relationList = (fields._2.columnTableRelationList)
    +        relationList.foreach(rel => {
    +          rel.foreach(col => {
    +            if (longStringColumnInParents.contains(col.parentColumnName)) {
    +              varcharDatamapFields += col.parentColumnName + ","
    +            }
    +          })
    +        })
    +      }
    +    })
    +    if (varcharDatamapFields.size != 0) {
    +      longStringColumn = Option(varcharDatamapFields.slice(0, 
varcharDatamapFields.length - 1))
    +    }
         if (longStringColumn != None) {
           val fieldNames = fields.map(_.column)
    -      val newLongStringColumn = 
longStringColumn.get.split(",").map(_.trim).map{ colName =>
    +      val newLongStringColumn = 
longStringColumn.get.split(",").map(_.trim).map { colName =>
             val newColName = parentTable.getTableName.toLowerCase() + "_" + 
colName
             if (!fieldNames.contains(newColName)) {
               throw new MalformedDataMapCommandException(
                 CarbonCommonConstants.LONG_STRING_COLUMNS.toUpperCase() + ":" 
+ colName
    -              + " does not in datamap")
    +            + " does not in datamap")
    --- End diff --
    
    revery this change


---

Reply via email to