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

    https://github.com/apache/spark/pull/2561#discussion_r18439341
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -226,6 +229,24 @@ object ConstantFolding extends Rule[LogicalPlan] {
     }
     
     /**
    + * Replaces [[In (value, seq[Literal])]] with optimized version[[InSet 
(value, HashSet[Literal])]]
    + * which is much faster
    + */
    +object OptimizedIn extends Rule[LogicalPlan] {
    +  def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +    case q: LogicalPlan => q transformExpressionsDown {
    +      case In(v, list) if list.exists {
    --- End diff --
    
    I don't think this is correct.  This will convert `In` expressions when 
_any_ of the expressions is a literal. Here is an example failure:
    
    ```scala
    $ sbt/sbt hive/console
    scala> sql("SELECT * FROM src WHERE key IN (1, value)")     
    res1: org.apache.spark.sql.SchemaRDD = 
    SchemaRDD[1] at RDD at SchemaRDD.scala:103
    == Query Plan ==
    == Physical Plan ==
    org.apache.spark.sql.catalyst.errors.package$TreeNodeException: No function 
to evaluate expression. type: AttributeReference, tree: value#5
    ```
    
    Instead I think you want `!list.exists(!_.isInstanceOf[Literal])`.


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

Reply via email to