Skip to content

feat: derive SMJ sort options from left child during plan creation#43

Merged
rkrishn7 merged 2 commits into
branch-52from
rohan/smj-planner-derive-sort-options
Mar 31, 2026
Merged

feat: derive SMJ sort options from left child during plan creation#43
rkrishn7 merged 2 commits into
branch-52from
rohan/smj-planner-derive-sort-options

Conversation

@rkrishn7
Copy link
Copy Markdown
Collaborator

Which issue does this PR close?

  • Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the core label Mar 31, 2026
Copy link
Copy Markdown
Collaborator

@zhuqi-lucas zhuqi-lucas left a comment

Choose a reason for hiding this comment

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

One minor note: this optimization is most effective when the join key is a prefix of the left child's ordering (e.g., left ordered by [a DESC, b ASC], join key is a). When the join key is deeper in the ordering (e.g., join key is b), the extracted sort direction is correct but won't avoid a re-sort — same as the previous behavior though.

Copy link
Copy Markdown
Collaborator

@zhuqi-lucas zhuqi-lucas left a comment

Choose a reason for hiding this comment

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

Could you add tests for:

  1. Left child already sorted DESC on join key → verify SortExec is avoided on the left side
  2. Left child not sorted on join key → verify fallback to default ASC behavior
  3. Multi-column join key where left child's ordering partially matches

Copy link
Copy Markdown
Collaborator

@zhuqi-lucas zhuqi-lucas left a comment

Choose a reason for hiding this comment

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

LGTM — please add a test as mentioned above.

@rkrishn7
Copy link
Copy Markdown
Collaborator Author

Could you add tests for:

  1. Left child already sorted DESC on join key → verify SortExec is avoided on the left side
  2. Left child not sorted on join key → verify fallback to default ASC behavior
  3. Multi-column join key where left child's ordering partially matches

Added! Also added one more case where both sides are sorted by left side's ordering (no sort needed)

@rkrishn7 rkrishn7 merged commit 8ca2242 into branch-52 Mar 31, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants