cloud-fan commented on a change in pull request #23057: [SPARK-26078][SQL]
Dedup self-join attributes on IN subqueries
URL: https://github.com/apache/spark/pull/23057#discussion_r241477432
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/subquery.scala
##########
@@ -43,31 +43,44 @@ import org.apache.spark.sql.types._
* condition.
*/
object RewritePredicateSubquery extends Rule[LogicalPlan] with PredicateHelper
{
- private def dedupJoin(joinPlan: LogicalPlan): LogicalPlan = joinPlan match {
+
+ private def buildJoin(
+ outerPlan: LogicalPlan,
+ subplan: LogicalPlan,
+ joinType: JoinType,
+ condition: Option[Expression]): Join = {
+ // Deduplicate conflicting attributes if any.
+ val dedupSubplan = dedupSubqueryOnSelfJoin(outerPlan, subplan)
+ Join(outerPlan, dedupSubplan, joinType, condition)
Review comment:
we need to refactor the code a little bit
```
...
val duplicates = outerRefs.intersect(subplan.outputSet)
condition.foreach {
case a: Attribute if duplicates.contains(a) => fail
case _ =>
}
...
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]