Repository navigation
Commit 21a802b
authored
* feat!: add typed SQL macros and require @py./@SQL. macro calls
Add SQL macros: logic-free SQL fragments in macros/sql/ with a MACRO
header and typed arguments, in three forms decided by the body (an
expression, a WITH list of CTEs, or a SELECT list of columns). Calls are
written @sql.name(...), expand in place in the declaration pass, and are
checked on their own and again in every caller. Parameters are written
@name in bodies; types follow schema declaration types, with CONST for
compile-time scalars, LIST/SET, ENUM, RELATION and COLUMN OF arguments.
Runtime parameters in literal-only positions are rejected. Formatting,
rules and column lineage see through calls, and macro-mode unit tests
and __macro__ mocks work for SQL macros.
BREAKING CHANGE: Python macros now live in macros/python/ (and the
python/ folder of scoped macro roots) and are called as @py.name(...).
A macro file directly under a macros/ folder fails with D013, and a bare
@name(...) call fails with P014; move files into macros/python/ and
replace @name( with @py.name( in project SQL.
* fix: check SQL macro arguments against caller types and harden call placement
Report RELATION columns, COLUMN OF names and typed arguments that do not fit
at the call, with the parameter's declaration. Accept every comma spelling
around CTE-list and column-list calls, reject aliases on column-list calls,
resolve macro bodies in the macro file's own scope, keep valid SQL macros
when another fails inventory, use real call spans, read backslash-escaped
strings, parenthesise before AT, OVER and FILTER, keep separators in mocks,
record hook-only SQL macro dependencies, and format expression bodies and
MACRO headers.
* refactor: resolve SQL macro bodies through native scope contexts
Check cache-hit models' SQL macro arguments too, resolve macro body
declarations through the native per-file declaration context, build related
locations as native records, and keep the SQL macro helpers flat.
* fix: skip SQL macro argument checks the probe cannot place
Treat typed arguments in subqueries or set-operation scopes as unknown,
resolve a FROM alias before a same-named CTE, keep DISTINCT ON calls
rejected as before, and keep string literal lines when unwrapping
formatted expression bodies.
* perf: infer SQL macro argument types without full query analysis
Merge a scope's typed arguments into one probe, infer probe output types
directly instead of running full analysis per probe, check a wave's models
together, and locate calls without re-scanning the whole file.
* fix: keep macro kind folders when moves carry declaration layouts
Apply group-folder layout rules within a macro's python/ or sql/ folder,
migrate the layout and move tests to kind folders and @py. calls, and teach
the agent skill SQL macros and kind-prefixed calls.
* docs: say which SQL macro calls the argument check skips
* refactor: keep SQL macro probe helpers to plain loops
* fix: pass SQL macro arguments read through untyped sources
Treat a probe as unknown when any FROM or JOIN source in it cannot be
typed, so stars over unnest() or table functions no longer report missing
columns. Teach kind-prefixed macro calls in the remaining docs.
* test: import the compile-reuse rounding helper from macros/python
* refactor: take the code SQL macro findings supersede from analysis
The render-stage view filtered unknown-column findings inside macro calls
by redeclaring B002, which the render code inventory reads as a code it
emits. Name the analysis-owned constant instead.
* perf: find @ with memchr when looking for bare macro calls
The byte-by-byte scan cost about 4 instructions per byte of every authored
SQL text, 0.15% of a 10,000-model compile without SQL macros.
* test: regenerate goldens for kind-prefixed macro calls
* test: move --since fixtures to macro kind folders and @py. calls
* feat: compare SQL macros by their definitions for --since
Fingerprint a SQL macro declaration by its form, typed arguments, result
type and normalised body, ignoring layout, comments and its description,
and keep the edges to the SQL macros it calls.
* test: call semantic corpus and layered project macros with @py.
* test: move the rename and move batch fixtures to macro kind folders
1 parent d46ee4b commit 21a802b
392 files changed
Lines changed: 16418 additions & 4691 deletions
File tree
- benchmarks/dbt-compare
- crates
- sqlbuild-analysis
- src
- assembly/analysis_session
- _helpers
- tests
- binding_locations
- main
- compiler
- _helpers/sql_tests
- tests
- definition_changes
- _helpers
- main
- tests
- query_analysis
- _helpers
- main
- semantic_validation/tests
- sql_macros
- _helpers
- main
- tests
- sql_test_attachment/tests
- sqlbuild-attachments/src/audits
- _helpers
- tests
- sqlbuild-cache/src/digest/tests
- sqlbuild-core/src
- format_command
- init_command
- sqlbuild-discovery/src
- declaration_files/tests
- declarations
- _helpers
- tests
- model_files/tests
- sqlbuild-model-config/src
- config_presence
- _helpers
- tests
- model_config_build/tests
- sqlbuild-project/src
- tests
- sqlbuild-python/src/bindings/_helpers
- analysis_session
- change_selection
- compile_driver
- compile_records
- compiled_views
- input_loops
- record_behaviours
- records
- render
- sqltext
- sqlbuild-refactor/src/refactoring
- _helpers/scanning
- tests
- sqlbuild-render/src
- macro_arguments
- _helpers
- tests
- macro_calls
- _helpers
- main
- tests
- sqlbuild-rules/src
- dsl_headers
- _helpers
- main
- tests
- engine/tests
- lint_text
- _helpers
- main
- tests
- sql_lint/_helpers
- sqlbuild-scopes/src
- placement
- _helpers
- main
- tests
- relationship_names
- _helpers
- tests
- scope_report/_helpers
- scripts
- cold_compile_performance/_helpers
- compiler_differential
- _helpers
- corpus
- coverage
- classes
- rules_benchmark/_helpers
- src/sqlbuild
- .agents/skills/sqlbuild
- references
- docs
- cli
- concepts
- declaration-scopes
- macros
- models/hooks
- compiler/compile/_helpers/render
- playground_templates/waffle_shop
- macros/python
- models/marts
- _sqlbuild/_macros/python
- tests/unit
- tests
- e2e
- fixtures/waffle_shop
- macros/python
- models/marts
- _macros/python
- tests/unit
- src/sqlbuild/cli/commands/main
- build
- clickhouse
- compile
- attachment_errors
- fixtures/semantic
- sql_macros
- sql_test_errors
- refactor
- rules
- scope
- sqlite
- sqlserver
- test
- goldens
- compiler
- example
- failure
- fixture
- seed
- python_oracle
- integration/src/sqlbuild
- cli
- commands/main
- entry
- compiler
- attachments
- compiled_project
- expected
- compile
- discovery
- model_config
- pipeline
- scopes
- sql_test_glue
- rule_engine/host_payload
- unit
- scripts/compiler_differential/_helpers/coverage
- src/sqlbuild
- cli/commands
- _helpers
- lineage
- scope
- main
- init
- playground
- compiler
- compile
- _helpers
- discovery
- _helpers
- macro_bridge
- _helpers
- classes
- manifest
- planner/_helpers/sql_test_assembly
- scopes
- lint
- _helpers
- website
- examples/waffle-shop
- macros/python
- models/marts
- _sqlbuild/_macros/python
- tests/unit
- src
- content/docs/docs
- cli
- concepts
- declaration-scopes
- macros
- models/hooks
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
176 | 177 | | |
177 | 178 | | |
178 | | - | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
279 | 283 | | |
280 | 284 | | |
281 | 285 | | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
288 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
289 | 336 | | |
290 | 337 | | |
291 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
262 | 267 | | |
263 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
45 | 56 | | |
0 commit comments