Skip to content

feat(sql): index SQL files and Dataform sqlx models - #1757

Open
paran-hiberuscom wants to merge 6 commits into
colbymchenry:mainfrom
paran-hiberuscom:feat/sql-upstream
Open

feat(sql): index SQL files and Dataform sqlx models#1757
paran-hiberuscom wants to merge 6 commits into
colbymchenry:mainfrom
paran-hiberuscom:feat/sql-upstream

Conversation

@paran-hiberuscom

Copy link
Copy Markdown

Closes #1756. Six commits, rebased on today's main, no refactor dependencies.

Files: src/extraction/languages/sql.ts, src/extraction/sqlx-extractor.ts, src/extraction/wasm/tree-sitter-sql.wasm, registry and types.ts wiring, tree-sitter-helpers.ts line index shared with the MyBatis extractor, tests in extraction.test.ts and sqlx-extractor.test.ts, README, CHANGELOG and the site languages table.

Verified:

  • npx vitest run __tests__/extraction.test.ts __tests__/sqlx-extractor.test.ts: 667 pass.
  • Full suite on Windows: same set of pre-existing platform failures as main, none added.
  • scripts/add-lang/verify-extraction.mjs on jOOQ/sakila: PASS, 34 files, 483 symbols, 768 edges.
  • jaffle_shop (dbt): 0 symbols, because Jinja templating breaks the grammar. Documented as a limitation in the languages table.

Not done: the three-repo agent A/B benchmark from the add-lang skill. Happy to run it if you want it before review.

Vendors the DerekStride/tree-sitter-sql grammar (ABI 15) to extract
tables, views, functions, columns, function calls, and the tables a
query reads from FROM/JOIN and INSERT/UPDATE/DELETE targets.
A .sqlx file becomes one model node (kind class, qualified schema.name from
its config), and every model it names through ref()/resolve() in a ${...} span
or a js block, or lists in the config dependencies, becomes a resolved
references edge so impact and explore walk the model DAG.

A hand scanner in the shape of MyBatisExtractor, not a grammar: a .sqlx is not
valid SQL until the Dataform blocks and interpolations are masked, and the
edges live in those spans rather than in the SQL tree. The masked remainder
still goes through the SQL extractor, so literal FROM/JOIN source tables are
referenced too.
Two Dataform idioms produced no edge. A pre_operations / post_operations
body is SQL, so the ${...} refs written inside it are collected like any
other; the block itself is still blanked from the SQL body.

A backtick quotes an identifier in BigQuery, not a string, so `${ref("x")}`
is a table name being interpolated. The SQL-body scan now reads through
backticks; single and double quotes remain strings that hide what they hold.
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.

SQL and Dataform sqlx language support

1 participant