vbarua commented on code in PR #12495:
URL: https://github.com/apache/datafusion/pull/12495#discussion_r1762024765
##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -432,38 +445,39 @@ pub fn to_substrait_rel(
}
LogicalPlan::Window(window) => {
let input = to_substrait_rel(window.input.as_ref(), ctx,
extensions)?;
- // If the input is a Project relation, we can just append the
WindowFunction expressions
- // before returning
- // Otherwise, wrap the input in a Project relation before
appending the WindowFunction
- // expressions
- let mut project_rel: Box<ProjectRel> = match
&input.as_ref().rel_type {
- Some(RelType::Project(p)) => Box::new(*p.clone()),
- _ => {
- // Create Projection with field referencing all output
fields in the input relation
- let expressions = (0..window.input.schema().fields().len())
- .map(substrait_field_ref)
- .collect::<Result<Vec<_>>>()?;
- Box::new(ProjectRel {
- common: None,
- input: Some(input),
- expressions,
- advanced_extension: None,
- })
- }
- };
Review Comment:
This is potentially a useful optimization, however it becomes a bit more
complicated with the introduction of the `output_mapping` because you a need to
modify it along with the expressions. I've opted to simplify this for now to
favour simplicity and correctness.
As well, I think this is better handled in when consuming plans and/or by
the optimizer.
--
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]