akashrn5 commented on a change in pull request #3690: [CARBONDATA-3762] Block 
creating Materialized view's with duplicate column
URL: https://github.com/apache/carbondata/pull/3690#discussion_r403123959
 
 

 ##########
 File path: 
integration/spark/src/main/scala/org/apache/spark/sql/optimizer/MVMatcher.scala
 ##########
 @@ -1342,6 +1343,40 @@ private object SelectSelectGroupbyChildDelta
     }
   }
 
+  /**
+   * Removes duplicate projection in the output list for query matching
+   */
+  def getDistinctOutputList(outputList: Seq[NamedExpression]): 
Seq[NamedExpression] = {
+    var distinctOList: Seq[NamedExpression] = Seq.empty
+    outputList.foreach { output =>
+      if (distinctOList.isEmpty) {
+        distinctOList = distinctOList :+ output
+      } else {
+        // get output name
+        var outputName = output.name
+        if (output.isInstanceOf[Alias]) {
+          // In case of queries with join on more than one table and 
projection list having
+          // aggregation of same column name on join tables like 
sum(t1.column), sum(t2.column),
+          // in that case, compare alias name with column id, as alias name 
will be same for
+          // both output(sum(t1))
+          val projectName = output.simpleString
+          outputName = projectName.substring(0, projectName.indexOf(" AS"))
+        }
+        if (!distinctOList.exists(oList =>
+          if (oList.isInstanceOf[Alias]) {
 
 Review comment:
   `oList` rename to may be outPutColumn

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to