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 for commutative join types getting stuck in analysis loop #1411

Merged
merged 15 commits into from
Nov 28, 2022

Conversation

fulghum
Copy link
Contributor

@fulghum fulghum commented Nov 17, 2022

This change fixes an issue where the analyzer can get stuck in a loop bouncing back and forth between the original and commuted plan and being unable to stabilize the plan.

As part of that fix... it also deduplicates logically identical relExprs in exprGroups and changes the finalizeSubqueries analyzer rule so that it only runs once on each subquery, from the bottom of the plan tree, up.

Fixes: dolthub/dolt#4816

Dolt Tests: dolthub/dolt#4859

@fulghum fulghum marked this pull request as ready for review November 18, 2022 16:48
Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

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

I am concerned that the correctness of this relies on a pre-existing bug (my mistake). We will fix that bug at some point, and the cycling will kick in again. Details below.

enginetest/queries/join_queries.go Outdated Show resolved Hide resolved
sql/analyzer/join_order_builder.go Outdated Show resolved Hide resolved
@fulghum
Copy link
Contributor Author

fulghum commented Nov 23, 2022

@max-hoffman – this one is ready for another look now that the finalizeSubquery changes are finished.

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

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

LGTM! I will follow up with the hasJoinRelExpr simplification next week

return finalizeSubqueriesHelper(ctx, a, n, scope, sel)
}

// finalizeSubqueriesHelper recurses through the specified |node| to find all leaf subqueries and subquery expressions,
Copy link
Contributor

Choose a reason for hiding this comment

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

one confusing thing is that the traversal connectivity crosses some scope boundaries, but not others. I think it still works? for example subqueries in unions, windows, or insert sources.

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.

Analyzer error: exceeded max analysis iterations (8)
2 participants