Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/21886#discussion_r205573413 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1407,6 +1408,87 @@ object ReplaceExceptWithAntiJoin extends Rule[LogicalPlan] { } } +/** + * Replaces logical [[Intersect]] operator using a combination of Union, Aggregate + * and Generate operator. + * + * Input Query : + * {{{ + * SELECT c1 FROM ut1 INTERSECT ALL SELECT c1 FROM ut2 + * }}} + * + * Rewritten Query: + * {{{ + * SELECT c1 + * FROM ( + * SELECT replicate_row(min_count, c1) AS (min_count, c1) + * FROM ( + * SELECT c1, + * vcol1_cnt, + * vcol2_cnt, + * IF (vcol1_cnt > vcol1_cnt, vcol2_cnt, vcol1_cnt) AS min_count --- End diff -- typo here `vcol1_cnt > vcol1_cnt` -> `vcol1_cnt > vcol2_cnt`.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org