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

fix: in PQ post processing, revert sort columns just before propagating down pipeline #5098

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kgutwin
Copy link
Collaborator

@kgutwin kgutwin commented Jan 19, 2025

Resolves #5097 by adding logic to revert sort columns within CTEs back to their original column identifiers in the context of the main pipeline. This is necessary for proper dereferencing of sort columns in the main pipeline.

The logic around "make sure that SELECT statements in CTEs include columns present in the SORT" was moved just prior to the new "revert sort columns" logic, in order to avoid bugs caused by the change in context of the sort columns. The previous logic tried to only apply this to columns that appear in the main pipeline; because it needed to move earlier in the sequence, this optimization needed to be removed. I believe this is not very significant, because the eventual SQL query planner will ignore extra columns defined in CTEs anyway. Also, this change did not affect any of the existing test case snapshots.

@kgutwin kgutwin requested a review from aljazerzen January 19, 2025 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Input containing rename, sort, filter, join results in output ORDER BY referring to wrong table
1 participant