From 5a9d74e9a91422e32d4f85aac8dccfaaa5564df6 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Sun, 15 Feb 2026 14:44:30 +0000 Subject: [PATCH 1/2] chore: md prettier the docs files --- BUILD.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index 8afafdce8..cf64cfc51 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -26,6 +26,7 @@ filegroup( [ ".github/**/*.yaml", ".github/**/*.yml", + "docs/**/*.md", ], ) + [ "README.md", @@ -42,6 +43,7 @@ prettier_bin.prettier_test( "--check", "--config", ".prettierrc.json", + "docs", "editors", "playground", "*.md", @@ -64,6 +66,7 @@ prettier_bin.prettier_binary( "--write", "--config", ".prettierrc.json", + "docs", "editors", "playground", "*.md", From 022cdaf5e920e2ae4d0df408bd35ec81890645c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Feb 2026 14:50:29 +0000 Subject: [PATCH 2/2] chore: auto-fix formatting --- docs/experimental/lineage.md | 57 ++++++++++++++----------- docs/index.md | 6 +++ docs/reference/sample-configurations.md | 5 +-- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/docs/experimental/lineage.md b/docs/experimental/lineage.md index 66aa71d5f..543c5f145 100644 --- a/docs/experimental/lineage.md +++ b/docs/experimental/lineage.md @@ -5,6 +5,7 @@ Sqruff includes a column lineage analysis feature that traces data flow through ## Overview Column lineage analysis answers questions like: + - Where does this column come from? - What source tables contribute to this column? - How does data flow through CTEs and subqueries? @@ -12,6 +13,7 @@ Column lineage analysis answers questions like: ## Availability The lineage feature is currently available through: + - **Web Playground**: Try it at [playground.quary.dev](https://playground.quary.dev) by selecting the "Lineage" tool - **Rust API**: For programmatic use in Rust applications @@ -81,7 +83,7 @@ FROM users AS u INNER JOIN tests AS t ON u.id = t.id ``` -### SELECT * Expansion +### SELECT \* Expansion Star projections are handled and can be traced to their source tables: @@ -124,13 +126,13 @@ for &child in &node_data.downstream { The `Lineage` builder provides several configuration options: -| Method | Description | -|--------|-------------| -| `new(parser, column, sql)` | Create a new lineage analyzer for a column | -| `schema(name, columns)` | Register table schema (column name to type mapping) | -| `source(name, sql)` | Register a source table's SQL definition | -| `disable_trim_selects()` | Keep intermediate SELECT projections in output | -| `build()` | Execute analysis and return `(Tables, Node)` | +| Method | Description | +| -------------------------- | --------------------------------------------------- | +| `new(parser, column, sql)` | Create a new lineage analyzer for a column | +| `schema(name, columns)` | Register table schema (column name to type mapping) | +| `source(name, sql)` | Register a source table's SQL definition | +| `disable_trim_selects()` | Keep intermediate SELECT projections in output | +| `build()` | Execute analysis and return `(Tables, Node)` | ### Registering Source Tables @@ -145,6 +147,7 @@ let (tables, node) = Lineage::new(parser, "a", "SELECT a FROM z") ``` This traces column `a` through: + 1. The main query (`SELECT a FROM z`) 2. Source `z` (`SELECT a FROM y`) 3. Source `y` (`SELECT * FROM x`) @@ -154,28 +157,28 @@ This traces column `a` through: Each node in the lineage tree contains: -| Field | Description | -|-------|-------------| -| `name` | Column or node identifier | -| `source` | The source expression (full query context) | -| `expression` | The specific expression for this column | -| `downstream` | Child nodes (dependencies) | -| `source_name` | Name of the source table | -| `reference_node_name` | Referenced CTE name (if applicable) | +| Field | Description | +| --------------------- | ------------------------------------------ | +| `name` | Column or node identifier | +| `source` | The source expression (full query context) | +| `expression` | The specific expression for this column | +| `downstream` | Child nodes (dependencies) | +| `source_name` | Name of the source table | +| `reference_node_name` | Referenced CTE name (if applicable) | ## Supported SQL Features -| Feature | Status | -|---------|--------| -| Basic SELECT | Supported | -| CTEs (WITH clause) | Supported | -| Subqueries | Supported | -| UNION / UNION ALL | Supported | -| JOINs | Supported | -| SELECT * | Supported | -| VALUES clause | Supported | +| Feature | Status | +| ------------------------ | --------- | +| Basic SELECT | Supported | +| CTEs (WITH clause) | Supported | +| Subqueries | Supported | +| UNION / UNION ALL | Supported | +| JOINs | Supported | +| SELECT \* | Supported | +| VALUES clause | Supported | | UNNEST / array functions | Supported | -| Multiple dialects | Supported | +| Multiple dialects | Supported | ## Limitations @@ -186,12 +189,14 @@ Each node in the lineage tree contains: ## Example Output For a query like: + ```sql WITH cte AS (SELECT a FROM source_table) SELECT a FROM cte ``` The lineage tree shows: + ``` name: a source: with cte as (select source_table.a as a from source_table) select cte.a as a from cte diff --git a/docs/index.md b/docs/index.md index 39f78ab35..1e6a0fe0c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,6 +3,7 @@ Sqruff is a SQL linter and formatter written in Rust. It focuses on formatting valid SQL for specific dialects and provides fast linting and fixing. ## Key features + - Linting: Advanced, customizable SQL linting. - Formatting: Automated, configurable formatting for SQL code consistency. - Lineage: Column-level data lineage analysis for SQL queries. @@ -10,22 +11,27 @@ Sqruff is a SQL linter and formatter written in Rust. It focuses on formatting v - Portability: Designed to integrate into workflows, including CI. ## Sqruff vs SQLFluff + Sqruff started as an exact replacement for SQLFluff but is diverging. - Accurate dialect definitions: Sqruff targets valid SQL for each dialect and does not try to fix partially correct SQL. - Configuration: The config format is currently similar to SQLFluff but may diverge over time. ## Playground + Try sqruff in your browser at https://playground.quary.dev. ## Get started + - Install the CLI in [Installation](getting-started/installation.md) - Learn basic commands: [Lint and fix](usage/lint.md) - Configure behavior in [Configuration](usage/configuration.md) ## Experimental features + - [dbt project support](experimental/dbt.md) - [SQL Column Lineage](experimental/lineage.md) ## Credits + The sqruff project is heavily inspired by [sqlfluff](https://sqlfluff.com/) and [ruff](https://github.com/astral-sh/ruff). diff --git a/docs/reference/sample-configurations.md b/docs/reference/sample-configurations.md index 6e9bc739b..78943fb1d 100644 --- a/docs/reference/sample-configurations.md +++ b/docs/reference/sample-configurations.md @@ -1,10 +1,10 @@ # Sample Configurations -The following document outlines sample configurations that may be used to achieve certain formatting/linting outcomes. +The following document outlines sample configurations that may be used to achieve certain formatting/linting outcomes. ## Aligning AS statements -Suppose you want to align as statements in a `select` to return the following outcome. +Suppose you want to align as statements in a `select` to return the following outcome. ```sql --before @@ -30,4 +30,3 @@ spacing_before = align align_within = select_clause align_scope = bracketed ``` -