Skip to content

Commit aadbc49

Browse files
collerekclaude
andauthored
Version 3.0.0 Proposal draft with sqlglot as the parsing library (#617)
* wip - working version with sqlglot to refactor * wip - extract bracketed names into new dialect * wip - Rewrite REPLACE INTO → INSERT INTO in _ast.py._parse() before sqlglot parses it, so sqlglot produces a proper exp.Insert AST instead of exp.Command and parses it correctly without falling back to regex * wip - Rewrite REPLACE INTO → INSERT INTO in _ast.py._parse() before sqlglot parses it, so sqlglot produces a proper exp.Insert AST instead of exp.Command and parses it correctly without falling back to regex * add docstings, refactor to simplify most complex methods, add few tests from open issues to verify if it's handling the issues better than the old version, remove internal tokens and produce only list of strings if needed, remove compatibility layer to v1 * add tests from open issues that now passes and some small fixes to accommodate additional 3 tests * accept capitalization and explicit as from sqlglot as opinionated defaults to simplify the bodies extraction * simplify logic, refactor into classes with related functionalities * additional simplification and cleanup * remove unnecessary wrappers * further simplification - add also architecture overview with charts and main notes * next portion of cleanup, renaming files, update also agents.md file, switch to ruff for formating and linting * refactor other functionalities from ast parser into separate classes * change to ruff also in CI. add mypy and fix typing errors, add mypy to CI * fix remaining mypy errors in untyped code * further fixes and duplication cleanup * fix unused code, bump coverage - add todo to revisit corner cases later for now mark nocover as unreachable from parser and this is the only entrypoint we want for majority of the tests * add features to handle unnamed queries, extracting properly hive tables from queries with subscripts, some additional issues that were already fixed were documented by tests, some cleanup and refactor to decrease unreachable paths * fix mypy - add additional test for next already solved issue * add additional test for next already solved issue * remove unreachable stars without table node handling - it's either raw star or star with table when prefixed with table name/alias - unreachable code * raise more meaningful error on invalid queries, raise on cte without name instead of silently skipping, extract mypy and ruff into separate workflows * reorder methods, refactor complicated conditions into helper methods, add more descriptive docstrings and add sample queries in majority of the code flow branches to easier navigate the code * handle redshift append clause with custom dialect, clean up table extractor and add more descriptive docstrings * fix typing to go with 3.10 flow not deprecated typing ones. add support for nested ctes, cleanup nested resolver and simplify code there. remove unnecessary guards * additional cleanup in dialect_parser.py and query_type_extractor.py * cleanup in parser and docstring refactor, cleanup of thr remaining todoes * fixes after the code review * additional changes and optimizations after initial review * break internal cyclical imports, change test to use parser instead of internal method * update docs and readme, additional cleanup when possible -> use native sqlglot features whenever possible * minor cleanup --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent d3a03ac commit aadbc49

48 files changed

Lines changed: 6382 additions & 2644 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/auto-merge-dependabot.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ jobs:
2323
if: "${{ steps.metadata.outputs.update-type ==
2424
'version-update:semver-minor' ||
2525
steps.metadata.outputs.update-type ==
26-
'version-update:semver-patch' ||
27-
steps.metadata.outputs.dependency-names ==
28-
'black' }}"
26+
'version-update:semver-patch' }}"
2927

3028
# https://cli.github.com/manual/gh_pr_merge
3129
run: gh pr merge --auto --squash "$PR_URL"

.github/workflows/black.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v6
14+
- name: Set up Python
15+
uses: actions/setup-python@v6
16+
with:
17+
python-version: "3.12"
18+
19+
- name: Install Poetry
20+
uses: snok/[email protected]
21+
with:
22+
version: latest
23+
virtualenvs-create: true
24+
virtualenvs-in-project: true
25+
26+
- name: Install dependencies with poetry
27+
run: poetry install --no-root
28+
29+
- name: Lint with ruff
30+
run: make lint

.github/workflows/python-ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
- name: Install Python wheel support to speed up things
4343
run: pip install wheel
4444

45-
- name: Pre-install black
46-
run: pip install black
47-
4845
# https://github.com/marketplace/actions/install-poetry-action
4946
- name: Install Poetry
5047
uses: snok/[email protected]
@@ -77,8 +74,5 @@ jobs:
7774
pip install coveralls
7875
poetry run coveralls --service=github
7976
80-
- name: Lint with pylint
81-
run: make lint
82-
8377
- name: Build a distribution package
8478
run: poetry build -vvv

.github/workflows/type-check.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Type Check
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
8+
jobs:
9+
type-check:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v6
14+
- name: Set up Python
15+
uses: actions/setup-python@v6
16+
with:
17+
python-version: "3.12"
18+
19+
- name: Install Poetry
20+
uses: snok/[email protected]
21+
with:
22+
version: latest
23+
virtualenvs-create: true
24+
virtualenvs-in-project: true
25+
26+
- name: Install dependencies with poetry
27+
run: poetry install --no-root
28+
29+
- name: Type check with mypy
30+
run: make type_check

0 commit comments

Comments
 (0)