gengliangwang commented on a change in pull request #28805:
URL: https://github.com/apache/spark/pull/28805#discussion_r448143802
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
##########
@@ -249,8 +251,36 @@ trait PredicateHelper extends Logging {
resultStack.top
}
- private def groupExpressionsByQualifier(expressions: Seq[Expression]):
Seq[Expression] = {
-
expressions.groupBy(_.references.map(_.qualifier)).map(_._2.reduceLeft(And)).toSeq
+ /**
+ * Convert an expression to conjunctive normal form when pushing predicates
through Join,
+ * when expand predicates, we can group by the qualifier avoiding generate
unnecessary
+ * expression to control the length of final result since there are multiple
tables.
+ *
+ * @param condition condition need to be converted
+ * @return the CNF result as sequence of disjunctive expressions. If the
number of expressions
+ * exceeds threshold on converting `Or`, `Seq.empty` is returned.
+ */
+ def conjunctiveNormalFormAndGroupExpsByQualifier(condition: Expression):
Seq[Expression] = {
+ conjunctiveNormalForm(condition, (expressions: Seq[Expression]) =>
+
expressions.groupBy(_.references.map(_.qualifier)).map(_._2.reduceLeft(And)).toSeq)
+ }
+
+ /**
+ * Convert an expression to conjunctive normal form for predicate pushdown
and partition pruning.
+ * When expanding predicates, this method groups expressions by their
references for reducing
+ * the size of pushed down predicates and corresponding codegen. In
partition pruning strategies,
+ * we split filters by [[splitConjunctivePredicates]] and partition filters
by judging if it's
+ * references is subset of partCols, if we combine expressions group by
reference when expand
+ * predicate of [[Or]], it won't impact final predicate pruning result since
+ * [[splitConjunctivePredicates]] won't split [[Or]] expression.
+ *
+ * @param condition condition need to be converted
+ * @return the CNF result as sequence of disjunctive expressions. If the
number of expressions
+ * exceeds threshold on converting `Or`, `Seq.empty` is returned.
+ */
+ def conjunctiveNormalFormAndGroupExpsByReference(condition: Expression):
Seq[Expression] = {
Review comment:
How about changing to `CNFWithGroupExpressionsByReference`?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]