You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rxin <gi...@git.apache.org> on 2016/07/06 17:35:21 UTC

[GitHub] spark pull request #13876: [SPARK-16174][SQL] Improve `OptimizeIn` optimizer...

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

    https://github.com/apache/spark/pull/13876#discussion_r69775645
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala ---
    @@ -820,16 +820,26 @@ object ConstantFolding extends Rule[LogicalPlan] {
     }
     
     /**
    - * Replaces [[In (value, seq[Literal])]] with optimized version[[InSet (value, HashSet[Literal])]]
    - * which is much faster
    + * Optimize IN predicates:
    + * 1. Removes deterministic repetitions.
    + * 2. Replaces [[In (value, seq[Literal])]] with optimized version
    + *    [[InSet (value, HashSet[Literal])]] which is much faster.
      */
     case class OptimizeIn(conf: CatalystConf) extends Rule[LogicalPlan] {
       def apply(plan: LogicalPlan): LogicalPlan = plan transform {
         case q: LogicalPlan => q transformExpressionsDown {
    -      case In(v, list) if !list.exists(!_.isInstanceOf[Literal]) &&
    -          list.size > conf.optimizerInSetConversionThreshold =>
    -        val hSet = list.map(e => e.eval(EmptyRow))
    -        InSet(v, HashSet() ++ hSet)
    +      case i @ In(v, list) =>
    +        val (deterministics, others) = list.partition(_.deterministic)
    --- End diff --
    
    one question i have is how often do we see an in expression with some expressions being deterministic and some nondeterministic? if not, i'd just simplify this so we only do it if everything is deterministic.



---
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