[GitHub] [carbondata] zzcclp commented on a change in pull request #3398: [CARBONDATA-3501] Fix update table with varchar column

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] zzcclp commented on a change in pull request #3398: [CARBONDATA-3501] Fix update table with varchar column

GitBox
zzcclp commented on a change in pull request #3398: [CARBONDATA-3501] Fix update table with varchar column
URL: https://github.com/apache/carbondata/pull/3398#discussion_r328480711
 
 

 ##########
 File path: integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonIUDRule.scala
 ##########
 @@ -37,21 +39,30 @@ class CarbonIUDRule extends Rule[LogicalPlan] with PredicateHelper {
         var isTransformed = false
         val newPlan = updatePlan transform {
           case Project(pList, child) if !isTransformed =>
-            val (dest: Seq[NamedExpression], source: Seq[NamedExpression]) = pList
+            var (dest: Seq[NamedExpression], source: Seq[NamedExpression]) = pList
               .splitAt(pList.size - cols.size)
-            val diff = cols.diff(dest.map(_.name.toLowerCase))
+            // check complex column
             cols.foreach { col =>
               val complexExists = "\"name\":\"" + col + "\""
               if (dest.exists(m => m.dataType.json.contains(complexExists))) {
                 throw new UnsupportedOperationException(
                   "Unsupported operation on Complex data type")
               }
             }
+            // check updated columns exists in table
+            val diff = cols.diff(dest.map(_.name.toLowerCase))
             if (diff.nonEmpty) {
               sys.error(s"Unknown column(s) ${ diff.mkString(",") } in table ${ table.tableName }")
             }
+            // modify plan for updated column *in place*
             isTransformed = true
-            Project(dest.filter(a => !cols.contains(a.name.toLowerCase)) ++ source, child)
+            source.foreach{ col =>
 
 Review comment:
   add a blank before '{'

----------------------------------------------------------------
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:
[hidden email]


With regards,
Apache Git Services