andygrove opened a new issue, #2873:
URL: https://github.com/apache/datafusion-ballista/issues/2873

   **Describe the bug**
   
   `PropagateEmptyExecRule` must not null-pad a join that carries an embedded 
projection (#2200), because the join's output schema then no longer maps 
positionally onto its inputs. `as_join` in 
`ballista/scheduler/src/state/aqe/optimizer_rule/propagate_empty.rs` sets 
`has_projection` from `HashJoinExec::contains_projection()`, but hard-codes 
`has_projection: false` for `SortMergeJoinExec`.
   
   Since DataFusion 56, `SortMergeJoinExec` can also carry an embedded 
projection (`projection: Option<Vec<usize>>`), so the guard no longer covers 
sort-merge joins.
   
   **To Reproduce**
   
   With the adaptive planner on, `datafusion.optimizer.prefer_hash_join=false` 
and `ballista.planner.adaptive_join.enabled=false`:
   
   ```sql
   SELECT c.id, e.eemail FROM customers c LEFT JOIN empty e ON e.eemail = 
c.email
   ```
   
   Once the stage reading `empty` finishes with zero rows, the replan rewrites 
the join into `ProjectionExec: expr=[id@0 as id, email@1 as eemail]`, so the 
query returns `c.email` where it should return NULL. When the projected columns 
have different types (for example selecting `e.eid`), the replan fails with 
`ProjectionPushdown failed. Schema mismatch` instead.
   
   **Expected behavior**
   
   The join is left as is, and `eemail` is NULL for every row.
   
   **Additional context**
   
   Found while reviewing #2837. The fix is `has_projection: 
join.projection.is_some()`. This should land before 56.0.0 (#2872).
   


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