Skip to content

Fix(optimizer): infinite recursion in the resolver#7737

Merged
georgesittas merged 1 commit into
mainfrom
jo/fix_recursion_issue_resolver
Jun 11, 2026
Merged

Fix(optimizer): infinite recursion in the resolver#7737
georgesittas merged 1 commit into
mainfrom
jo/fix_recursion_issue_resolver

Conversation

@georgesittas

Copy link
Copy Markdown
Collaborator

Closes #7732

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

This comment was marked as resolved.

@github-actions

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:jo/fix_recursion_issue_resolver @ sqlglot cbb7255)
  • baseline (main @ sqlglot df507aa)

Overall

main: 192441 total, 153536 passed (pass rate: 79.8%)

sqlglot:jo/fix_recursion_issue_resolver: 180247 total, 142391 passed (pass rate: 79.0%)

Transitions:
No change

Dialect pair changes: 0 previous results not found, 3 current results not found

✅ All tests passed

@georgesittas georgesittas merged commit 2284484 into main Jun 11, 2026
9 checks passed
@georgesittas georgesittas deleted the jo/fix_recursion_issue_resolver branch June 11, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants