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

minor(sqlparser): encapsulate PlanerContext, reduce some clones #5814

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Mar 31, 2023

Which issue does this PR close?

related to #5637 , but really a Friday afternoon project that has bothered me for a whle

Rationale for this change

The PlannerContext in the SQL planner has a map of LogicalPlans and it is cloned during planning (which deep clones the values 😱 ). Also, the LogicalPlan is cloned on use anyways.

What changes are included in this PR?

  1. Make the fields of PlannerContext non pub

Are these changes tested?

Covered by existing tests

Are there any user-facing changes?

No

@github-actions github-actions bot added the sql SQL Planner label Mar 31, 2023
self.outer_query_schema.as_ref()
}

/// sets the outer query schema, returning the existing one, if
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think having accessors also is a good place to put documentation about what they do

@@ -33,7 +33,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
// normalize name and alias
let table_ref = self.object_name_to_table_reference(name)?;
let table_name = table_ref.to_string();
let cte = planner_context.ctes.get(&table_name);
let cte = planner_context.get_cte(&table_name);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the use of ctes -- and 4 lines below it is immediately clone()d

@alamb alamb marked this pull request as ready for review April 1, 2023 11:07
@alamb alamb requested a review from tustvold April 3, 2023 13:05
@avantgardnerio avantgardnerio self-requested a review April 3, 2023 17:47
Copy link
Contributor

@avantgardnerio avantgardnerio left a comment

Choose a reason for hiding this comment

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

I went through each change. It all seems cleaner and more efficient :)

@alamb
Copy link
Contributor Author

alamb commented Apr 3, 2023

Thanks @avantgardnerio !

@alamb alamb merged commit fd350fa into apache:main Apr 3, 2023
@alamb alamb deleted the alamb/contxt_clean branch July 26, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants