cloud-fan commented on code in PR #36588:
URL: https://github.com/apache/spark/pull/36588#discussion_r958150650


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
##########
@@ -140,6 +140,15 @@ trait PredicateHelper extends AliasHelper with Logging {
         findExpressionAndTrackLineageDown(replaceAlias(exp, aliasMap), a.child)
       case l: LeafNode if exp.references.subsetOf(l.outputSet) =>
         Some((exp, l))
+      case u: Union =>
+        val index = u.output.indexWhere(_.semanticEquals(exp))
+        if (index > -1) {
+          u.children
+            .flatMap(child => 
findExpressionAndTrackLineageDown(child.output(index), child))
+            .sortBy(_._2.stats.sizeInBytes).lastOption

Review Comment:
   After reading the code more, I don't think we have to use a heuristic here. 
We can let caller side to pass a callback function so that we can go to all the 
branches to find partitioned tables.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
##########
@@ -140,6 +140,15 @@ trait PredicateHelper extends AliasHelper with Logging {
         findExpressionAndTrackLineageDown(replaceAlias(exp, aliasMap), a.child)
       case l: LeafNode if exp.references.subsetOf(l.outputSet) =>
         Some((exp, l))
+      case u: Union =>
+        val index = u.output.indexWhere(_.semanticEquals(exp))
+        if (index > -1) {
+          u.children
+            .flatMap(child => 
findExpressionAndTrackLineageDown(child.output(index), child))
+            .sortBy(_._2.stats.sizeInBytes).lastOption

Review Comment:
   After reading the code more, I don't think we have to use a heuristic here. 
We can let the caller side pass a callback function so that we can go to all 
the branches to find partitioned tables.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to