Skip to content

Recognize JOIN before parenthesized subqueries - #919

Open
adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/fix-join-parenthesis
Open

adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/fix-join-parenthesis

Conversation

@adenzhou1350

Copy link
Copy Markdown

JOIN(SELECT ...) is currently consumed by the function-name lookahead. As a
result, child join(...) as p becomes a single Identifier instead of a table,
JOIN keyword and subquery alias.

Move the existing JOIN regex ahead of that lookahead, keeping it after the dotted
name guards. The regression covers bare and compound JOINs, subquery aliases,
unchanged SQL text, ordinary function names and schema.join(...).

Refs #615's JOIN example; this does not change UNNEST or ANY classification.

Validation on Windows / Python 3.14.3 / pytest 9.0.3:

  • Final regressions: unchanged source has 2 failures and 8 passing controls;
    patched source passes all 10.
  • Full upstream suite: 516 passed, 2 xfailed, 1 xpassed. The xfail/xpass outcomes
    also occur on the unchanged-source baseline.
  • ruff check sqlparse/ tests/test_join_parenthesis.py and git diff --check pass.
  • All six subquery JOIN statements also execute successfully against in-memory
    SQLite 3.50.4; no cross-dialect qualification is claimed.

Prepared with AI assistance.

Thanks for contributing!

Before submitting your pull request please have a look at the
following checklist:

  • ran the tests (pytest)
  • all style issues addressed (ruff)
  • your changes are covered by tests
  • your changes are documented, if needed (changelog)

In addition, please take care to provide a proper description
on what your change does, fixes or achieves when submitting the
pull request.


Note: This repository has automated AI code reviews enabled to help catch
potential issues early and provide suggestions. This is an experimental
feature to support maintainers and contributors – your feedback is welcome!

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.

1 participant