feat: add SQL and dbt support#17
Open
tglunde wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class SQL extraction and dbt project integration to Graphify’s AST extraction pipeline, including optional dbt compile support and cross-file SQL/dbt dependency resolution during CLI builds.
Changes:
- Added a dedicated SQL extractor (tree-sitter-sequel) with dependency + FK + column lineage support and SQL-only cross-file stub resolution helpers.
- Added dbt project detection + manifest parsing + compiled-model lineage extraction, with new CLI flags to optionally run
dbt compile. - Wired SQL/dbt into the CLI build pipeline and updated architecture docs + changelog + workspace deps.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds CLI flags for dbt compile + timeout; threads dbt options into build command. |
| src/cmd_build.rs | Integrates dbt detection/extraction and runs merged SQL/dbt cross-file resolution in the AST step. |
| docs/ARCHITECTURE.md | Updates architecture docs to mention SQL/dbt and bumps supported language count. |
| crates/graphify-extract/tests/ast_extract.rs | Adds SQL routing + integration tests (including cross-file resolution scenarios). |
| crates/graphify-extract/src/treesitter/treesitter_config.rs | Explicitly bypasses generic tree-sitter config for SQL to force dedicated extractor. |
| crates/graphify-extract/src/sql.rs | New SQL extractor implementation + SQL cross-file stub resolver + extensive unit tests. |
| crates/graphify-extract/src/lib.rs | Routes .sql through the dedicated SQL extractor; documents deferral of SQL cross-file resolution. |
| crates/graphify-extract/src/dbt.rs | New dbt extractor: optional compile, manifest parsing, compiled SQL lineage attribution. |
| crates/graphify-extract/Cargo.toml | Adds dependencies needed for dbt + SQL extraction (graphify-detect, walkdir, tree-sitter-sequel). |
| crates/graphify-detect/src/lib.rs | Exposes dbt detection APIs from graphify-detect. |
| crates/graphify-detect/src/dbt.rs | New dbt project detection via dbt_project.yml + managed SQL path discovery. |
| crates/graphify-detect/src/constants.rs | Classifies .sql as a code extension. |
| crates/graphify-detect/Cargo.toml | Adds YAML parsing dependency and moves walkdir to workspace dependency. |
| crates/graphify-core/src/model.rs | Adds new node types (Application/Relation/Column/Expression) to the core model. |
| CHANGELOG.md | Documents the new SQL and dbt support under Unreleased. |
| Cargo.toml | Adds workspace-level deps for walkdir and serde_yaml_ng. |
| Cargo.lock | Locks new dependencies (serde_yaml_ng, tree-sitter-sequel, walkdir, etc.). |
| .gitignore | Ignores *.patch files. |
Comments suppressed due to low confidence (1)
src/cmd_build.rs:199
code_onlymode returns early whencode_filesis empty, which also skips dbt extraction. This makes a repo with only dbt-managed SQL (filtered out above) produce no AST/dbt output even though dbt projects were detected.
if code_files.is_empty() && code_only {
info_print!(verb, " No code files found. Nothing to extract.");
return Ok(vec![]);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+179
to
+183
| let dbt_projects = graphify_detect::detect_dbt_projects(root); | ||
| let mut dbt_managed_paths = std::collections::HashSet::new(); | ||
| for project in &dbt_projects { | ||
| dbt_managed_paths.extend(project.managed_sql_paths.iter().cloned()); | ||
| } |
Comment on lines
+265
to
+269
| fn handle_create_relation(&mut self, node: Node, kind: &str) { | ||
| if let Some(obj_ref) = self.find_child_by_kind_direct(node, "object_reference") { | ||
| let (catalog, schema, name) = self.parse_object_reference(obj_ref); | ||
| let relation_id = make_id(&["rel", catalog.as_deref().unwrap_or(""), &schema, &name]); | ||
| self.defined_relations.insert(relation_id.clone()); |
Comment on lines
+234
to
+237
| let schema = node.get("schema").and_then(|v| v.as_str()).unwrap_or(""); | ||
| let database = node.get("database").and_then(|v| v.as_str()).unwrap_or(""); | ||
| let rel_id = make_id(&["rel", database, schema, identifier]); | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
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.
Summary
Adds first-class SQL extraction and dbt project integration.
Added
Notes
Checklist