Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: with_inputs() can use original schema to avoid recompute schema. #7069

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

jackwener
Copy link
Member

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Don't need

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core DataFusion crate labels Jul 24, 2023
final_join_result,
Arc::new(join_plan),
join_schema.clone(),
Copy link
Member Author

@jackwener jackwener Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project_schema isn't necessary equal join_schema.

Sometime, project_schema is subset of join_schema, so recompute schema is more right.

Comment on lines -1242 to -1245
let input_schema = DFSchema::new_with_metadata(
exprlist_to_fields(&projected_expr, &plan)?,
plan.schema().metadata().clone(),
)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useless, because Projection::try_new( already contains it,

@@ -482,7 +482,38 @@ impl LogicalPlan {
}

pub fn with_new_inputs(&self, inputs: &[LogicalPlan]) -> Result<LogicalPlan> {
from_plan(self, &self.expressions(), inputs)
// with_new_inputs use original expression,
// so we don't need to recompute Schema.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid useless recompution.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Nice cleanup @jackwener

@jackwener jackwener merged commit 1a0542a into apache:main Jul 25, 2023
@jackwener jackwener deleted the agg branch July 25, 2023 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants