Skip to content

Conversation

@nicktobey
Copy link
Contributor

@nicktobey nicktobey commented Nov 14, 2025

This PR fixes several issues that prevent table functions from evaluating correctly when they take non-literal arguments and appear in subqueries or lateral joins.

  • 8a5f582 fixes a problem where references to an outer scope that appear in the topmost scope of a subquery won't cause the subquery to be marked as containing out-of-scope references.
    • This caused the subquery to be seen as cacheable even though it isn't, which could cause incorrect query results
    • This also caused the analyzer to incorrectly generate a CrossJoin instead of a LateralCrossJoin, which would then cause the join planner to commute the join children even though it was not safe to do so. This would ultimately cause an out-of-bounds field access while building the table function.
  • 0147ad3 fixes two other issues where join planning would drop the Lateral marker during join planning, resulting in generating a CrossJoin instead of a LateralCrossJoin
  • 0e2b6da fixes an oversight in the LateralCrossJoin RowIter that was causing rows from the parent and left scopes to not be passed into the right child

All three of these changes are required together in order to properly evaluate the newly added test queries.

@nicktobey nicktobey force-pushed the nicktobey/lateral_fix branch from 969b4f3 to 0e2b6da Compare November 14, 2025 20:12
Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

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

Looks good!

@nicktobey nicktobey merged commit b3e1e88 into main Nov 14, 2025
8 checks passed
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.

3 participants