Fix(optimizer): infinite recursion in the resolver#7737
Merged
Conversation
georgesittas
commented
Jun 11, 2026
Comment on lines
+183
to
184
| if isinstance(explode_col, exp.Column) and explode_col.table and source.parent: | ||
| col_type = self._get_unnest_column_type(explode_col, source.parent) |
Collaborator
Author
There was a problem hiding this comment.
This is the stack that shows the execution flow leading to the infinite recursion:
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 182, in get_source_columns
col_type = self._get_unnest_column_type(explode_col, source.parent)
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 380, in _get_unnest_column_type
table_identifier = parent_resolver.get_table(column)
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 45, in get_table
table_name = self._get_table_name_from_sources(column_name)
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 234, in _get_table_name_from_sources
self._get_all_source_columns()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 220, in _get_all_source_columns
source_name: self.get_source_columns(source_name)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/georgesittas/Dev/sqlglot/sqlglot/optimizer/resolver.py", line 182, in get_source_columns
col_type = self._get_unnest_column_type(explode_col, source.parent)
...
Both the happy and the unhappy paths work fine now, as demonstrated by the added tests & existing LATERAL EXPLODE tests passing.
Contributor
SQLGlot Integration Test Results✅ All tests passedComparing:
Overallmain: 192441 total, 153536 passed (pass rate: 79.8%) sqlglot:jo/fix_recursion_issue_resolver: 180247 total, 142391 passed (pass rate: 79.0%) Transitions: Dialect pair changes: 0 previous results not found, 3 current results not found ✅ All tests passed |
geooo109
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7732