Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/10444#discussion_r48516709
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
---
@@ -47,6 +48,34 @@ trait Predicate extends Expression {
override def dataType: DataType = BooleanType
}
+object Predicate extends PredicateHelper {
+ def toCNF(predicate: Expression, maybeThreshold: Option[Double] = None):
Expression = {
+ val cnf = new CNFExecutor(predicate).execute(predicate)
+ val threshold = maybeThreshold.map(predicate.size *
_).getOrElse(Double.MaxValue)
+ if (cnf.size > threshold) predicate else cnf
--- End diff --
Maximizing the number of simple predicates sounds reasonable. We may do the
conversion in a depth-first manner, i.e. always convert the left branch of an
`And` and then its right branch, until either no more predicates can be
converted or we reach the size limit. In this way the intermediate result is
still useful.
BTW, searched for CNF conversion in Hive and found [HIVE-9166][1], which
also tries to put an upper limit for ORC SARG CNF conversion. @nongli Any clues
about how Impala does this?
[1]: https://issues.apache.org/jira/browse/HIVE-9166
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]