Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1544#discussion_r154671387
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
---
@@ -439,6 +711,31 @@ case class CarbonPreAggregateQueryRules(sparkSession:
SparkSession) extends Rule
(updatedGroupExp, updatedAggExp, newChild, updatedFilterExpression)
}
+ /**
+ * Below method will be used to get the updated sort order attribute
+ * based on pre aggregate table
+ * @param sortOrderAttr
+ * sort order attributes reference
+ * @param aggregateExpressions
+ * aggregate expression
+ * @return updated sortorder attribute
+ */
+ def getUpdatedSortOrderExpression(sortOrderAttr: AttributeReference,
+ aggregateExpressions: Seq[NamedExpression]): Expression = {
+ val updatedExpression = aggregateExpressions collectFirst {
+ // in case of alias we need to match with alias name and when alias
is not present
+ // we need to compare with attribute reference name
+ case alias@Alias(attr: AttributeReference, name) if
attr.name.equals(sortOrderAttr.name) ||
--- End diff --
format properly
---