Skip to content

fix: Add alias_tokens parameter to _parse_join() for sqlglot 30.9.0 compactibilty #5847

Open
iawanish wants to merge 4 commits into
SQLMesh:mainfrom
iawanish:fix/sqlglot-30-9-compatibility-clean
Open

fix: Add alias_tokens parameter to _parse_join() for sqlglot 30.9.0 compactibilty #5847
iawanish wants to merge 4 commits into
SQLMesh:mainfrom
iawanish:fix/sqlglot-30-9-compatibility-clean

Conversation

@iawanish

@iawanish iawanish commented Jun 18, 2026

Copy link
Copy Markdown

Description

Fixes #5840
This PR fixes compatibility with sqlglot 30.9.0 by updating the overridden _parse_join() method in sqlmesh/core/dialect.py to match the upstream parser signature.

Problem

With sqlglot 30.9.0+, SQLMesh raises:

TypeError: _parse_join() got an unexpected keyword argument 'alias_tokens'

This happens because sqlglot introduced the alias_tokens parameter in Parser._parse_join(), while SQLMesh's override was still using the older method signature.

Changes

  • Added the optional alias_tokens parameter to _parse_join().
  • Forwarded alias_tokens to the internal __parse_join() calls.
  • Preserved backward compatibility by making the parameter optional.

This change allows SQLMesh to work correctly with sqlglot 30.9.0+ without affecting existing behavior.

Test Plan

  • Tested with sqlglot==30.9.0.
  • Verified that the previous TypeError no longer occurs.
  • Tested the DB2 adapter using the external DB2 sqlglot dialect.
  • Confirmed that SQL parsing behaves as expected after the change.

Checklist

  • [] I have run make style and fixed any issues
  • I have added tests for my changes (if applicable) - No new tests needed; existing tests verify the fix
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO
…ompatibility

- Add missing alias_tokens parameter to _parse_join() method signature
- Pass alias_tokens to internal __parse_join() calls
- Maintain backward compatibility with optional parameter
- Fixes TypeError when using sqlglot 30.9.0 or later

Resolves compatibility issue where SQLMesh's _parse_join() override
was incompatible with sqlglot 30.9.0's updated method signature.

Signed-off-by: Awanish Gupta <awanishgupta159@gmail.com>
@StuffbyYuki

StuffbyYuki commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

@iawanish Thanks for the PR!

A few nits:

  • perhaps fix the title typo, correct the “tests added” checklist item, and confirm CI passes.
  • If the goal is official sqlglot 30.9 support (not just compatibility when users override the pin), consider a follow-up to bump sqlglot~=30.9.0 and run the full test suite.

Also it looks like a bunch of ci tests failed. Prob due to sqlglot version changes in this pr

- Update sqlglot dependency from ~=30.8.0 to ~=30.9.0
- This makes sqlglot 30.9.0 the officially supported version
- Works in conjunction with the alias_tokens parameter fix
- Enables full sqlglot 30.9.0 feature support

Signed-off-by: Awanish Gupta <awanishgupta159@gmail.com>
@iawanish iawanish force-pushed the fix/sqlglot-30-9-compatibility-clean branch from 83ab276 to 0c1abe1 Compare June 22, 2026 10:42
iawanish and others added 2 commits June 24, 2026 08:42
The previous implementation used self.__parse_join() which relies on Python's
name mangling and doesn't work correctly. This changes it to use super(Parser, self)._parse_join()
which properly calls the parent class method.

This fixes the mypy error: Parser has no attribute __parse_join

Signed-off-by: Awanish Gupta <awanishgupta159@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants