Skip to content

Do not join remaining tables with CrossJoins during buildSingleLookupPlan#3417

Merged
angelamayxie merged 4 commits intomainfrom
angela/joinplanning
Feb 5, 2026
Merged

Do not join remaining tables with CrossJoins during buildSingleLookupPlan#3417
angelamayxie merged 4 commits intomainfrom
angela/joinplanning

Conversation

@angelamayxie
Copy link
Copy Markdown
Contributor

fixes dolthub/dolt#10304

Despite what the comment said, it's not safe to join remaining tables with CrossJoins during buildSingleLookupPlan. It is only safe to do so if every filter has been successfully matched to currentlyJoinedTables. Otherwise, we end up dropping filters.

For example, we could have a query like select from A, B, inner join C on B.c0 <=> C.c0 where table A has a primary key and tables B and C are keyless. columnKey matches A's primary key column and A would be added to currentlyJoinedTables. Since the only filter references B and C and neither are part of currentlyJoinedTabes, nothing is ever added to joinCandidates. However, it's unsafe to join all the tables with CrossJoins because we still need to account for the filter on B and C.

@angelamayxie angelamayxie marked this pull request as ready for review February 5, 2026 03:01
Copy link
Copy Markdown
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

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

LGTM

@angelamayxie angelamayxie merged commit d9c710c into main Feb 5, 2026
8 checks passed
@angelamayxie angelamayxie deleted the angela/joinplanning branch February 5, 2026 19:57
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.

Invalid CrossJoin in query plan

2 participants