Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: {}

Expand Down
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ Live validation against Sigma (needs credentials, creates nothing): `python scri

## Layout

- `macros/core` ids, string/dict helpers, `fail()`. `macros/theme` design tokens + late-bound colors. `macros/data` sources, fields, formats. `macros/elements` one file per element family plus `escape_hatches`. `macros/layout` pixel flow (`row`, `stack`, `flow`) + layout XML. `macros/report` `page`/`report`/`materialize`. `macros/components` composites and `simple_*`.
- `macros/core` ids, string/dict helpers, `fail()`, and `settings.sql` (every size and calibration constant). `macros/theme` design tokens + late-bound colors. `macros/data` sources, fields, formats. `macros/elements` one file per element family (`charts_more.sql` is the typed chart family on `channel_element`), `escape_hatches`, and the **generated** `kinds.sql`. `macros/layout` the recursive layout tree (`row`, `stack`, `flex`, `at`, `page_break`, `measure`, `place`, `flow`) + layout XML. `macros/report` `page`/`report`/`materialize`. `macros/components` composites and `simple_*`.
- `macros/schema.yml` documents every public macro. **dbt validates it against the signatures** (`validate_macro_args`); adding, renaming or removing an argument means updating it, or `dbt parse --warn-error` fails on both dbt 1 and dbt 2. Use only types from dbt's grammar: `string`, `bool`, `int`, `any`, `list[any]`, `dict[string,any]`.
- `integration_tests/` is a real dbt project (`packages.yml: local: ../`). `assert_reports.sql` = positive assertions, `assert_rejected.sql` = expected compile errors, each listed in `negative_cases.txt` with the message it must raise (the script checks the two agree). `expected/*.json` = golden copies of every compiled report; after an intended change to emitted JSON, run `UPDATE_GOLDEN=1 bash scripts/run_integration_tests_duckdb.sh` and review the diff.
- `scripts/` holds the Python tooling and its tests: `export_reports.py`, `check_layout.py` (pixel geometry), `check_golden.py`, `validate_against_sigma_schema.py` (against `integration_tests/schema/*.gz`, extracted from Sigma's OpenAPI document; `--refresh` regenerates it).

## Conventions and gotchas

- **Elements are dicts.** Keys starting with `_` are private (`_h`, `_row`, `_stack`, `_source`, ...) and stripped by `report()`. Never put a private key in output another way.
- **Reports are pixel-laid-out, workbooks are grid-laid-out.** Elements carry a height (`_h`); widths come from `row()`. Do not add a width to an element macro.
- **Reports are pixel-laid-out, workbooks are grid-laid-out.** Elements carry a natural height (`_h`, or `_auto` text to size from the width); widths come from `row()`. Do not add a width to an element macro.
- **The layout is a tree, resolved by `measure` then `place`.** Never read an element's `_h` directly in layout code: call `measure(block, width, gap)`, which handles text sizing, `_min`, flex and nesting. `measure` must not mutate; `place` takes the box it was given. Blocks are elements, `_row`, `_stack`, `_abs` (`at()`) and `_break` (`page_break()`); `check_block` keeps `_abs` / `_break` out of rows and stacks.
- **No hard-coded sizes in macros.** A default height, margin, gap, font size or calibration number is a `sigma_report.setting('name', arg)` (add the key to `default_settings()` and the README table). The argument default is `none` (documented as "the project setting"), and a per-call argument wins.
- **`kinds.sql` is generated.** After refreshing `integration_tests/schema/*.gz` run `python scripts/generate_kinds.py`; CI (`--check`) fails on drift. `raw()` / `extend()` rely on it.
- **dbt Jinja limits.** No `**kwargs`. Dict keys named `items` / `keys` / `values` collide with dict methods: use `el['values']`, never `el.values`. `{% set %}` inside a `for` doesn't leak: use `namespace`. Comments (`{# #}`) can't sit inside a `{% ... %}` tag. No `modules.re` (not portable to dbt 2): parse strings with `split`. Use `is false`, not `is sameas false`.
- **Dispatch is by adapter prefix.** A project overrides `relation_path` by defining `default__relation_path` and listing itself first in `dispatch:`; a macro named after the project is never found.
- **Every id is a hash of a stable path** (`freeze_id`). Never use timestamps, counters or `run_started_at`. Column ids include the *role* (channel) because Sigma allows a column on one channel only.
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ CI runs the suite on dbt 1.x and dbt 2.x, and both must pass. [`AGENTS.md`](AGEN

- Adding, renaming or removing a macro argument: update [`macros/schema.yml`](macros/schema.yml), or the build fails.
- Adding an element: follow "Adding an element" in [`docs/design.md`](docs/design.md), then use it in an integration report and assert on it.
- A new size, margin, font size or calibration number is a project setting (`macros/core/settings.sql`), not a literal in a macro.
- After refreshing the bundled Sigma schema, run `python scripts/generate_kinds.py` (CI fails on a stale `kinds.sql`).
- Expected compile errors get a negative test in `assert_rejected.sql` and a line in `negative_cases.txt`.
- If the change alters the emitted JSON, run `UPDATE_GOLDEN=1 bash scripts/run_integration_tests_duckdb.sh` and review the golden diff.
- If the change alters what elements look like, run `python scripts/export_reports.py --push --dry-run` against a Sigma organization and mention the result in the PR.
Expand Down
Loading
Loading