peter-toth commented on a change in pull request #24553: [SPARK-27604][SQL] 
Enhance constant propagation
URL: https://github.com/apache/spark/pull/24553#discussion_r287494130
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ConstantPropagationSuite.scala
 ##########
 @@ -37,10 +38,12 @@ class ConstantPropagationSuite extends PlanTest {
         Batch("ConstantPropagation", FixedPoint(10),
           ConstantPropagation,
           ConstantFolding,
-          BooleanSimplification) :: Nil
+          BooleanSimplification,
+          SimplifyBinaryComparison,
 
 Review comment:
   For example when we have this test: `'a < 2 && Literal(2) === 'a` and we 
expect `false` as filter and so an empty relation result 
`BooleanSimplification` has as important role:
   ```
   === Applying Rule 
org.apache.spark.sql.catalyst.optimizer.ConstantPropagation ===
   !Filter ((a#0 < 2) AND (2 = a#0))        Filter ((2 < 2) AND (2 = a#0))
    +- LocalRelation [a#0, b#1, c#2, x#3]   +- LocalRelation [a#0, b#1, c#2, 
x#3]
              
   19/05/24 21:40:59 INFO ConstantPropagationSuite$Optimize: 
   === Applying Rule org.apache.spark.sql.catalyst.optimizer.ConstantFolding ===
   !Filter ((2 < 2) AND (2 = a#0))          Filter (false AND (2 = a#0))
    +- LocalRelation [a#0, b#1, c#2, x#3]   +- LocalRelation [a#0, b#1, c#2, 
x#3]
              
   19/05/24 21:40:59 INFO ConstantPropagationSuite$Optimize: 
   === Applying Rule 
org.apache.spark.sql.catalyst.optimizer.BooleanSimplification ===
   !Filter (false AND (2 = a#0))            Filter false
    +- LocalRelation [a#0, b#1, c#2, x#3]   +- LocalRelation [a#0, b#1, c#2, 
x#3]
   ```
   
   I removed `SimplifyBinaryComparison` as it is not needed, indeed.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to