wangyum commented on pull request #30222:
URL: https://github.com/apache/spark/pull/30222#issuecomment-722858604


   We can reproduce it by:
   ```scala
   spark.sql("CREATE TABLE t(a int, b int, c int) using parquet")
   spark.sql(
     """
       |SELECT *
       |  FROM   (SELECT CASE
       |    WHEN rd > 1 THEN 1
       |    WHEN b > 1000 THEN 2
       |    WHEN c < 100 THEN 3
       |    ELSE 4
       |END AS x
       |FROM (SELECT *, rand(100) as rd FROM t) t1) t2
       |WHERE  x = 2
       |""".stripMargin).explain
   ```
   
   1. `Alias.toAttribute` construct `AttributeReference` with default 
deterministic, that is true:
   
https://github.com/apache/spark/blob/ca2cfd4185586993f981cfd2f1aff30ee6b2294e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala#L181
   
   2. Therefore, deterministic is true, and`SimplifyConditionals` can simplify 
it:
   
![image](https://user-images.githubusercontent.com/5399861/98330987-9aa8ab00-2036-11eb-8acf-93f1a2b9f404.png)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to