You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "gruuya (via GitHub)" <gi...@apache.org> on 2025/08/06 07:47:09 UTC

[I] minor: `UnionExec` inputs validation [datafusion]

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

   ### Is your feature request related to a problem or challenge?
   
   When physical plans are directly constructed (i.e. skipping over logical plans/dataframes) in a dynamical manner, `UnionExec`s `inputs` can end up being an empty vector. 
   
   In turn, this causes a panic such as
   ```rust
   thread '...' panicked at datafusion/physical-plan/src/union.rs:542:24:
   index out of bounds: the len is 0 but the index is 0
   ```
   
   ### Describe the solution you'd like
   
   Along the lines of the existing validation for the logical union plan maybe this should be an error instead https://github.com/apache/datafusion/blob/79c4c057e67623e86a7cbe2abb1210fc71fa94e3/datafusion/expr/src/logical_plan/plan.rs#L2733-L2735
   
   Otherwise (since that would entail changing the signature of `UnionExec::new`), at least the panic can be made to have a clearer message, e.g. 
   ```diff
   --- a/datafusion/physical-plan/src/union.rs
   +++ b/datafusion/physical-plan/src/union.rs
   @@ -538,8 +538,11 @@ pub fn can_interleave<T: Borrow<Arc<dyn ExecutionPlan>>>(
                .all(|partition| partition == *reference)
    }
    
   -fn union_schema(inputs: &[Arc<dyn ExecutionPlan>]) -> SchemaRef {
   -    let first_schema = inputs[0].schema();
   +fn union_schema(inputs: &[Arc<dyn ExecutionPlan>]) -> Result<SchemaRef> {
   +    let first_schema = inputs
   +        .get(0)
   +        .expect("No union input plans provided")
   +        .schema();
   ```
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscribe@datafusion.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] minor: `UnionExec` inputs validation [datafusion]

Posted by "EeshanBembi (via GitHub)" <gi...@apache.org>.
EeshanBembi commented on issue #17052:
URL: https://github.com/apache/datafusion/issues/17052#issuecomment-3259667625

   take


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] minor: `UnionExec` inputs validation [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi closed issue #17052: minor: `UnionExec` inputs validation
URL: https://github.com/apache/datafusion/issues/17052


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org