feat(dbt): extract dbt Jinja lineage and macros from raw .sql models#584
Open
alexisperinger-ux wants to merge 6 commits into
Open
feat(dbt): extract dbt Jinja lineage and macros from raw .sql models#584alexisperinger-ux wants to merge 6 commits into
alexisperinger-ux wants to merge 6 commits into
Conversation
CREATE TABLE/VIEW/MATERIALIZED VIEW now extract as Table/View defs (were generic Variable nodes) and CREATE PROCEDURE as Function. FROM/JOIN relations are emitted as usages scoped to the enclosing CREATE def, so pass_usages resolves them into view->table USAGE lineage edges. The definition-registry allowlist gains Table/View so those defs resolve as edge targets (kept in sync across pass_definitions and pass_parallel). Adds extraction tests for the new labels and the lineage usages. Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 63054f04465ec33ffde0b9a23d6f29ce817d96df) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
CREATE TABLE/VIEW now produce Table/View nodes (63054f0) instead of the old Variable mislabel; update the label golden and the probe accordingly. Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 7cca3f4faec7d2a12ac1cc6f4e432c8bc286cd94) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
resolve_sql_func_name took the first identifier of object_reference (the schema) for schema.table names; take the last (the table) so CREATE TABLE/VIEW nodes and FROM/JOIN lineage use the real relation name. Adds a schema-qualified regression test. Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 877ad51e8c14daf901656d918ced2ef636f7a5b1) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 8ffee3834223ce58aa6c26b83c88f2902e07180e) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 23f81ed76a05c813a68a67bc5b1dc47344e160f0) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
…ates dbt models are .sql (the SQL host path); a plain .jinja/.j2 template is not a dbt model. Emit Model only on the SQL path; the JINJA2 path keeps macro and ref/source extraction. Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com> (cherry picked from commit 582ad0c0293be148a97e1e52d0043ad6c4fe0e7d) Signed-off-by: alexisperinger-ux <alexis.peringer@iss-stoxx.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Indexes raw (uncompiled) dbt
.sqlmodels without a manifest:{{ ref('m') }}/{{ source('s','t') }}becomeUSAGElineage edges (via the vendoredtree-sitter-jinja2grammar), a model file becomes a name-addressableModelnode so cross-fileref()resolves into model-to-model lineage, and{% macro name(...) %}becomes aMacronode.Modelis emitted only on the.sqlpath; a macro-defining file is treated as a library, not a model.Reuses freeform labels and the existing
USAGEedge type, so there is no schema change. Macro extraction is gated to full mode, so the new nodes require a full-mode index. Complements the manifest path (#576).Fixes #575.
Checklist
git commit -s)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)