galaxytemple opened a new issue, #27419:
URL: https://github.com/apache/datafusion/issues/27419

   ### Describe the bug
   
   `EquivalenceGroup::exprs_equal` does not compare the operator when checking 
structural equality on non-leaf nodes. As a result, expressions like `a + 5` 
and `a % 5` are considered equal even on an empty `EquivalenceGroup`.
   
   ### To Reproduce
   
   Add this unit test to `datafusion/physical-expr/src/equivalence/class.rs`:
   
   ```rust
   #[test]
   fn exprs_equal_ignores_operator() {
       let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]);
       let a = col("a", &schema).unwrap();
       let plus: Arc<dyn PhysicalExpr> =
           Arc::new(BinaryExpr::new(Arc::clone(&a), Operator::Plus, lit(5i32)));
       let modulo: Arc<dyn PhysicalExpr> =
           Arc::new(BinaryExpr::new(a, Operator::Modulo, lit(5i32)));
   
       // Fails: exprs_equal returns true because operators are not compared
       assert!(!EquivalenceGroup::default().exprs_equal(&plus, &modulo));
   }
   ```
   
   ### Expected behavior
   
   `exprs_equal` should return `false` when operators differ.
   
   ### Additional context
   
   Discussed in #27347 
(https://github.com/apache/datafusion/pull/27347#issuecomment-6873043655).
   
   In `datafusion/physical-expr/src/equivalence/class.rs:954`, `exprs_equal` 
only checks `TypeId` and child equality, skipping operator comparison on 
`BinaryExpr`.
   
   ### Willingness to contribute
   
   I cannot contribute a fix for this bug at this time


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to