Skip to content

Commit 75ca309

Browse files
committed
Add M1 macro property parsing
1 parent b24e680 commit 75ca309

12 files changed

Lines changed: 317 additions & 7 deletions

File tree

PLAN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ Exit criteria:
514514

515515
- M0 is under PR review as the Zig `0.16.0` runtime scaffold.
516516
- M1 has started on stacked branches with native Zig artifact-first parser slices.
517-
- `dxt parse` now targets the supported Tier 0 subset: project name/model paths/seed paths/macro paths, SQL model discovery, CSV seed discovery, project macro discovery, docs block discovery, literal `ref` to models or seeds, literal `source`, literal `doc` in descriptions, inline `config(materialized=..., tags=...)`, known project macro call dependencies, narrow YAML model properties for scalar descriptions, simple columns, tags, materialization, disabled SQL models, dbt-shaped `unique`, `not_null`, `accepted_values`, and `relationships` generic test nodes, dependency maps, and deterministic partial `manifest.json`. YAML generic test arguments are currently supported for scalar values plus inline and block lists required by public Jaffle Shop DuckDB-style tests.
517+
- `dxt parse` now targets the supported Tier 0 subset: project name/model paths/seed paths/macro paths, SQL model discovery, CSV seed discovery, project macro discovery, macro property YAML for descriptions and arguments, docs block discovery, literal `ref` to models or seeds, literal `source`, literal `doc` in descriptions, inline `config(materialized=..., tags=...)`, known project macro call dependencies, narrow YAML model properties for scalar descriptions, simple columns, tags, materialization, disabled SQL models, dbt-shaped `unique`, `not_null`, `accepted_values`, and `relationships` generic test nodes, dependency maps, and deterministic partial `manifest.json`. YAML generic test arguments are currently supported for scalar values plus inline and block lists required by public Jaffle Shop DuckDB-style tests.
518518
- `dxt ls` now lists dbt-selectable resources from the same parser graph with stable text/JSON output and basic name, tag, path, resource type, and exact exclude filters; macros are emitted in artifacts but not exposed as `ls` resources.
519-
- Synthetic fixtures cover one model, model refs, seed refs, source refs, combined source/model YAML, inline config/tag selection, YAML model properties and columns, emitted `unique`, `not_null`, `accepted_values`, and `relationships` generic test nodes, project macro artifacts, configured `macro-paths` replacing the default macro directory, macro calls recorded in model and macro `depends_on.macros`, docs blocks with literal `doc` descriptions, disabled models, disabled ref diagnostics, unmatched model-property warnings, duplicate model and docs diagnostics, unsupported dynamic ref/doc diagnostics, missing doc diagnostics, malformed docs block diagnostics, and unsupported unknown macro-call diagnostics.
520-
- The current M1 manual gate parses the public Jaffle Shop DuckDB project into a partial manifest with SQL models, CSV seeds, docs blocks, project macros, and supported generic test nodes, including the Jaffle `accepted_values` and `relationships` tests. The next M1 slices should add published schema validation, stronger selector parity, package macro namespaces, macro property YAML, and deeper Jaffle artifact parity.
519+
- Synthetic fixtures cover one model, model refs, seed refs, source refs, combined source/model YAML, inline config/tag selection, YAML model properties and columns, emitted `unique`, `not_null`, `accepted_values`, and `relationships` generic test nodes, project macro artifacts and macro properties, configured `macro-paths` replacing the default macro directory, macro calls recorded in model and macro `depends_on.macros`, docs blocks with literal `doc` descriptions, disabled models, disabled ref diagnostics, unmatched model-property warnings, duplicate model and docs diagnostics, unsupported dynamic ref/doc diagnostics, missing doc diagnostics, malformed docs block diagnostics, and unsupported unknown macro-call diagnostics.
520+
- The current M1 manual gate parses the public Jaffle Shop DuckDB project into a partial manifest with SQL models, CSV seeds, docs blocks, project macros, and supported generic test nodes, including the Jaffle `accepted_values` and `relationships` tests. The next M1 slices should add published schema validation, stronger selector parity, package macro namespaces, and deeper Jaffle artifact parity.

src/project.zig

Lines changed: 237 additions & 4 deletions
Large diffs are not rendered by default.

src/root.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fn commandError(err: anyerror, stderr: *Io.Writer) ExitCode {
109109
error.DuplicateSeedName => stderr.writeAll("error: duplicate seed name in supported M1 parser subset\n") catch {},
110110
error.DuplicateDocName => stderr.writeAll("error: duplicate docs block name in supported M1 parser subset\n") catch {},
111111
error.DuplicateMacroName => stderr.writeAll("error: duplicate macro name in supported M1 parser subset\n") catch {},
112+
error.DuplicateMacroProperty => stderr.writeAll("error: duplicate macro property patch in supported M1 parser subset\n") catch {},
112113
error.UnsupportedDynamicRef => stderr.writeAll("error: unsupported dynamic ref; M1 parser only supports literal ref calls\n") catch {},
113114
error.UnsupportedDynamicSource => stderr.writeAll("error: unsupported dynamic source; M1 parser only supports literal source calls\n") catch {},
114115
error.UnsupportedDynamicDoc => stderr.writeAll("error: unsupported dynamic doc; M1 parser only supports literal doc calls in descriptions\n") catch {},
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: duplicate_macro_property
2+
version: "1.0"
3+
profile: default
4+
model-paths: ["models"]
5+
target-path: target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% macro format_id(column_name) %}
2+
cast({{ column_name }} as varchar)
3+
{% endmacro %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
3+
macros:
4+
- name: format_id
5+
description: First patch.
6+
- name: format_id
7+
description: Second patch.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select {{ format_id("customer_id") }} as customer_id
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: macro_properties
2+
version: "1.0"
3+
profile: default
4+
model-paths: ["models"]
5+
target-path: target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% macro format_id(column_name) %}
2+
cast({{ column_name }} as varchar)
3+
{% endmacro %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
3+
macros:
4+
- name: format_id
5+
description: Format an identifier expression.
6+
arguments:
7+
- name: column_name
8+
type: string
9+
description: Column expression to cast.
10+
- name: optional_suffix
11+
description: Optional suffix value.

0 commit comments

Comments
 (0)