jonahgao opened a new pull request, #10954: URL: https://github.com/apache/datafusion/pull/10954
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> Closes #10914. ## Rationale for this change Each query should have its own scope-visible CTEs and be able to inherit the CTEs from the outer query. CTEs defined within a subquery should be visible only inside that subquery without affecting the outer query. These goals can be achieved by cloning `PlannerContext` for each query. ## What changes are included in this PR? - Clone the `PlannerContext` for each query/subquery to fix the CTE scope bug. - Use `Arc` to make cloning the `PlannerContext` cheaper. - Eliminate the cloning of the `PlannerContext` during planning joins and SetExprs, as this has already been done in each subquery. ## Are these changes tested? Yes. By existing tests and new tests. ## Are there any user-facing changes? No -- 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]
