Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/13887
  
    Thank you for your review and valuable improvement ideas, @davies . Let me 
rephrase about your ideas,
    
    1. For `IN` with single expression, we definitely had better improve the 
existing `OptimizeIn` optimizer. (like as you mentioned.)
    
    2. For **sparse** values and small IN, we also can replace `a IN (1,2,3)` 
into `a = 1 or a = 2 or a = 3`. In terms of generated java code size, the 
optimized version is smaller.
     ```scala
    scala> sql("explain codegen select * from (select 
explode(array('1','2','3')) a) where a in 
('1','2','3')").collect().foreach(println)   // 80 lines
    scala> sql("explain codegen select * from (select 
explode(array('1','2','3')) a) where a = '1' or a = '2' or a 
='3'").collect().foreach(println) // 65 lines
    ```
    3. For **consecutive and discretized** values, e.g. 2001, 2002, 2003, ..., 
2004, we can improve more cheaper by replacing 
GreaterThanOrEqual/LessThanOrEqual in Logical Optimizer layer, maybe also 
`OptimizeIn`?
    
    4. For **ordered partitioned data sources** like InMemory/Parquet, 1~3 will 
effectively improve the performance.
    
    5. For **the other data sources (unordered, partitioned or not)** and large 
IN, we need to use INSET as a fallback operation to prevent any regressions.
    
    Are these all what you advise? If I missed something, please comment me.


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