You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by liancheng <gi...@git.apache.org> on 2015/12/23 10:45:31 UTC

[GitHub] spark pull request: [SPARK-6624][WIP] Draft of another alternative...

Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10444#discussion_r48332590
  
    --- 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 --
    
    When the threshold is exceeded, the original predicate rather than the intermediate converted predicate is returned. This because the intermediate result may not be in CNF, thus:
    
    1. It doesn't bring much benefit for filter push-down, and
    2. It's much larger than the original predicate and brings extra evaluation cost.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org