diff --git a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/janitor.md b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/janitor.md index d7fdcca9ed..7d23b51609 100644 --- a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/janitor.md +++ b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/janitor.md @@ -40,7 +40,7 @@ sqb --project-dir janitor [flags] | `--retention-days` | Override the configured retention period (days) before a stale relation is archived | | `--direct-state-history-versions` | Override how many state-history versions are kept per identity | | `--drop-old-name-view ` | Drop the [compatibility view](../concepts/models/migrations.md#old-names) at a renamed model's old name before it expires. Repeat for several views. Fails with `C503` if no compatibility view is recorded at the name | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | ## Targets diff --git a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/scenario.md b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/scenario.md index 457750e029..14eb08b544 100644 --- a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/scenario.md +++ b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/scenario.md @@ -40,7 +40,7 @@ sqb scenario test [flags] | `--max-snapshot-bytes` | Override per-relation byte limit for capture | | `--max-snapshot-total-bytes` | Override total byte limit for capture | | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | ### Selectors @@ -131,7 +131,7 @@ sqb scenario capture [flags] | `--max-snapshot-bytes` | Override per-relation byte limit | | `--max-snapshot-total-bytes` | Override total byte limit | | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | ### Examples diff --git a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/test.md b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/test.md index 5e4d1839cc..a4a2b7d79f 100644 --- a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/test.md +++ b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/test.md @@ -22,7 +22,7 @@ sqb --project-dir test [flags] | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | | `--select`, `-s` | Select tests targeting specific models | | `--exclude` | Exclude tests targeting specific models | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse | Parameterized cases use parent-level selection. Selecting a target model includes every case in each matching `TEST` template; case names are not model selectors. diff --git a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/concepts/project-configuration.md b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/concepts/project-configuration.md index 722b2e4f1a..ed614b0cca 100644 --- a/src/sqlbuild/.agents/skills/sqlbuild/references/docs/concepts/project-configuration.md +++ b/src/sqlbuild/.agents/skills/sqlbuild/references/docs/concepts/project-configuration.md @@ -262,11 +262,13 @@ temporary comparison tables on the `query` warehouse. The exception is `sqb dbt` | Group | Commands | |-------|----------| -| `build` | `audit`, `build`, `check`, `clone`, `dbt` (SQLBuild-owned work), `janitor`, `load`, `plan`, `scenario`, `seed`, `test` | -| `query` | `contract`, `cost`, `debug`, `diff`, `freshness`, `query` | +| `build` | `audit`, `build`, `check`, `clone`, `dbt` (SQLBuild-owned work), `load`, `plan`, `seed` | +| `query` | `contract`, `cost`, `debug`, `diff`, `freshness`, `janitor`, `query`, `scenario`, `test` | Other commands, such as `compile`, `lineage`, and `format`, never connect to a warehouse. Integrations that run builds, such as Dagster, invoke `sqb build` and use the `build` group. +Standalone `sqb test`, `sqb scenario` and `sqb janitor` use the `query` group because they work on +fixture data or catalogue metadata; tests and audits that run inside `sqb build` use the `build` group. Each developer can point ad-hoc commands at their own warehouse without editing shared configuration: diff --git a/src/sqlbuild/cli/commands/constants.py b/src/sqlbuild/cli/commands/constants.py index 9ff371fc19..1a83eab25f 100644 --- a/src/sqlbuild/cli/commands/constants.py +++ b/src/sqlbuild/cli/commands/constants.py @@ -151,18 +151,18 @@ CliCommand.CHECK: WarehouseGroup.BUILD, CliCommand.CLONE: WarehouseGroup.BUILD, CliCommand.DBT: WarehouseGroup.BUILD, - CliCommand.JANITOR: WarehouseGroup.BUILD, CliCommand.LOAD: WarehouseGroup.BUILD, CliCommand.PLAN: WarehouseGroup.BUILD, - CliCommand.SCENARIO: WarehouseGroup.BUILD, CliCommand.SEED: WarehouseGroup.BUILD, - CliCommand.TEST: WarehouseGroup.BUILD, CliCommand.CONTRACT: WarehouseGroup.QUERY, CliCommand.COST: WarehouseGroup.QUERY, CliCommand.DEBUG: WarehouseGroup.QUERY, CliCommand.DIFF: WarehouseGroup.QUERY, CliCommand.FRESHNESS: WarehouseGroup.QUERY, CliCommand.QUERY: WarehouseGroup.QUERY, + CliCommand.JANITOR: WarehouseGroup.QUERY, + CliCommand.SCENARIO: WarehouseGroup.QUERY, + CliCommand.TEST: WarehouseGroup.QUERY, CliCommand.CLEAN: None, CliCommand.COMPILE: None, CliCommand.DAG: None, diff --git a/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/_test_types.py b/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/_test_types.py index b61ca160e2..26f3acc986 100644 --- a/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/_test_types.py +++ b/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/_test_types.py @@ -2,6 +2,7 @@ from sqlbuild.cli.commands.types import CliCommand from sqlbuild.spec.contracts.models import LocalTargetConfig, TargetWarehousesConfig +from sqlbuild.spec.contracts.types import WarehouseGroup @dataclass(frozen=True) @@ -88,3 +89,10 @@ class CommandWarehouseClassificationTestCase: description: str command: CliCommand expected_classified: bool = True + + +@dataclass(frozen=True) +class CommandWarehouseGroupTestCase: + description: str + command: CliCommand + expected_group: WarehouseGroup diff --git a/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/test_warehouses.py b/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/test_warehouses.py index 954c0a516e..6bcddd2371 100644 --- a/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/test_warehouses.py +++ b/tests/unit/src/sqlbuild/cli/commands/_helpers/runtime/test_warehouses.py @@ -19,9 +19,11 @@ from sqlbuild.cli.commands.types import CliCommand from sqlbuild.compiler.discovery.models import DiscoveredProjectInputs from sqlbuild.spec.contracts.models import LocalTargetConfig, TargetWarehousesConfig +from sqlbuild.spec.contracts.types import WarehouseGroup from tests.unit.src.sqlbuild.cli.commands._helpers.runtime._test_types import ( CommandWarehouseClassificationTestCase, CommandWarehouseErrorTestCase, + CommandWarehouseGroupTestCase, CommandWarehouseResolutionTestCase, WarehouseFlagParseTestCase, WarehouseFlagRejectedTestCase, @@ -339,5 +341,47 @@ def test_given_command_without_group_when_parsing_warehouse_flag_then_it_is_reje assert test_case.expected_error_fragment in capsys.readouterr().err +@pytest.mark.parametrize( + "test_case", + [ + CommandWarehouseGroupTestCase( + description="standalone SQL tests use fixture data", + command=CliCommand.TEST, + expected_group=WarehouseGroup.QUERY, + ), + CommandWarehouseGroupTestCase( + description="scenarios build against fixture data", + command=CliCommand.SCENARIO, + expected_group=WarehouseGroup.QUERY, + ), + CommandWarehouseGroupTestCase( + description="janitor works on catalogue metadata", + command=CliCommand.JANITOR, + expected_group=WarehouseGroup.QUERY, + ), + CommandWarehouseGroupTestCase( + description="audits scan built tables", + command=CliCommand.AUDIT, + expected_group=WarehouseGroup.BUILD, + ), + CommandWarehouseGroupTestCase( + description="Python checks read real outputs", + command=CliCommand.CHECK, + expected_group=WarehouseGroup.BUILD, + ), + CommandWarehouseGroupTestCase( + description="builds execute project resources", + command=CliCommand.BUILD, + expected_group=WarehouseGroup.BUILD, + ), + ], + ids=lambda case: case.description, +) +def test_given_cli_command_when_resolving_group_then_matches_its_workload( + test_case: CommandWarehouseGroupTestCase, +) -> None: + assert COMMAND_WAREHOUSE_GROUPS[test_case.command] is test_case.expected_group + + if __name__ == "__main__": pytest.main([__file__, "-vv"]) diff --git a/website/src/content/docs/docs/cli/janitor.mdx b/website/src/content/docs/docs/cli/janitor.mdx index 83d87ad7b2..91089bee3f 100644 --- a/website/src/content/docs/docs/cli/janitor.mdx +++ b/website/src/content/docs/docs/cli/janitor.mdx @@ -23,7 +23,7 @@ sqb --project-dir janitor [flags] | `--retention-days` | Override the configured retention period (days) before a stale relation is archived | | `--direct-state-history-versions` | Override how many state-history versions are kept per identity | | `--drop-old-name-view ` | Drop the [compatibility view](/docs/concepts/models/migrations#old-names) at a renamed model's old name before it expires. Repeat for several views. Fails with `C503` if no compatibility view is recorded at the name | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | ## Targets diff --git a/website/src/content/docs/docs/cli/scenario.mdx b/website/src/content/docs/docs/cli/scenario.mdx index 0cc83eb374..8849f86183 100644 --- a/website/src/content/docs/docs/cli/scenario.mdx +++ b/website/src/content/docs/docs/cli/scenario.mdx @@ -33,7 +33,7 @@ sqb scenario test [flags] | `--max-snapshot-bytes` | Override per-relation byte limit for capture | | `--max-snapshot-total-bytes` | Override total byte limit for capture | | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | ### Selectors @@ -124,7 +124,7 @@ sqb scenario capture [flags] | `--max-snapshot-bytes` | Override per-relation byte limit | | `--max-snapshot-total-bytes` | Override total byte limit | | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | ### Examples diff --git a/website/src/content/docs/docs/cli/test.mdx b/website/src/content/docs/docs/cli/test.mdx index 560114ae8c..2d18416993 100644 --- a/website/src/content/docs/docs/cli/test.mdx +++ b/website/src/content/docs/docs/cli/test.mdx @@ -21,7 +21,7 @@ sqb --project-dir test [flags] | `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) | | `--select`, `-s` | Select tests targeting specific models | | `--exclude` | Exclude tests targeting specific models | -| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | +| `--warehouse ` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](/docs/concepts/project-configuration#command-group-warehouses) and the connection warehouse | Parameterized cases use parent-level selection. Selecting a target model includes every case in each matching `TEST` template; case names are not model selectors. diff --git a/website/src/content/docs/docs/concepts/project-configuration.mdx b/website/src/content/docs/docs/concepts/project-configuration.mdx index 1af7573666..c0fedb7f13 100644 --- a/website/src/content/docs/docs/concepts/project-configuration.mdx +++ b/website/src/content/docs/docs/concepts/project-configuration.mdx @@ -239,11 +239,13 @@ temporary comparison tables on the `query` warehouse. The exception is `sqb dbt` | Group | Commands | |-------|----------| -| `build` | `audit`, `build`, `check`, `clone`, `dbt` (SQLBuild-owned work), `janitor`, `load`, `plan`, `scenario`, `seed`, `test` | -| `query` | `contract`, `cost`, `debug`, `diff`, `freshness`, `query` | +| `build` | `audit`, `build`, `check`, `clone`, `dbt` (SQLBuild-owned work), `load`, `plan`, `seed` | +| `query` | `contract`, `cost`, `debug`, `diff`, `freshness`, `janitor`, `query`, `scenario`, `test` | Other commands, such as `compile`, `lineage`, and `format`, never connect to a warehouse. Integrations that run builds, such as Dagster, invoke `sqb build` and use the `build` group. +Standalone `sqb test`, `sqb scenario` and `sqb janitor` use the `query` group because they work on +fixture data or catalogue metadata; tests and audits that run inside `sqb build` use the `build` group. Each developer can point ad-hoc commands at their own warehouse without editing shared configuration: