Repository navigation
Commit dc9756d
authored
refactor(native): move discovery, scopes and the model config build into plain-Rust crates (#1182)
* refactor(native): move discovery's header keys and header changes into sqlbuild-discovery
The header key sets each statement accepts and the options built from
them now live in `sqlbuild-discovery` (`constants`, `model_file_options`,
`declaration_file_options`, `sql_test_file_options`), and the bindings
call them.
The delta compile's header comparison moves too: `header_changes` digests
each header key, decides how an edit changed a model header and whether a
custom rule reads a changed key. The bindings keep only the recording of
digests into the compile image. The comparison gains unit tests.
* refactor(native): move plain scope logic from the bindings into sqlbuild-scopes
The conversions from a cached full index to the report and projection
views (`cached_report_records`, `cached_projection_index` and their
parts), the scope path and qualified identity messages, the `as_posix`
path text helpers, and the merge of new runtime usages
(`merged_usages`, with `UsageKey`) now live in `sqlbuild-scopes`. The
bindings read Python objects into those types and convert the results
back, nothing more.
`distinct_positions` and `merged_dependencies` become helpers of the
usage merge, their only remaining caller.
* feat(native): add a typed model config value and layer described models with it
`sqlbuild-model-config` gains `config_values`: `ConfigNode<H>` holds the
builtin Python values config is made of (None, bool, int, float, str,
list, tuple, dict) as Rust data, and every other value as an opaque host
value carrying its handle and the facts config logic reads of it, taken
once with the same rules as before. It implements `AuthoredNode`, so the
existing config scans read it unchanged, and `layered_config` merges one
layer over another as `_merged_with_tag_union` does.
The bindings convert Python values into nodes and project nodes back;
opaque values project to the very same object. Externally described
models now layer defaults, path defaults and headers through the typed
merge, the first consumer.
* refactor(native): build model configs as typed values in sqlbuild-model-config
The model config build (layering with tag, row-diff and tolerance unions,
hook checks, the three model template passes, the target namespace and
its templates, storage key removal, the no-macros check and header keys)
now runs in `sqlbuild-model-config::model_config_build` over
`ConfigNode`s. It asks its caller only for environment reads, the
project-var text of non-string values and the exact error of a value
that is not UTF-8 text, through `ConfigBuildHost`.
`NativeModelConfigBuilder` converts the project inputs once per compile
and each header once per model, and projects the built values back.
Opaque values are carried as their own Python objects. Which header
entries are still the header's own is tracked by provenance instead of
object identity, so native header facts apply exactly where they did.
Output is unchanged: the compiler differential passes, and a new
integration test pins values, types, order, header keys and errors for
builtin, subclassed, str-enum, date and opaque header values against the
previous build. The build runs about 2% fewer instructions on a
600-model templated project.
* refactor(native): read planner config values as typed nodes
`sqlbuild-model-config` gains the typed config reads (`checked_text`,
`checked_flag`, `checked_integer`, `checked_texts`,
`checked_cursor_bound`) with the type rules and error contents of the
`get_config_*` readers; the Python-facing readers now check through
them and still return the caller's own objects.
A config record keeps its values as typed nodes, converted from
`values` on first read and cached on the record. The planner's phase
objects, change detection, display plan, column migrations, lineage and
SQL test cursor window read through it instead of the Python dict.
* fix(native): keep header-owned config values as the header's objects
Since configs are built as typed nodes, every built container was
projected as a fresh Python object. The model loop reuses natively
parsed header columns only when `values["columns"]` is the header's own
object, so any model with `columns` beside another config key fell back
to parsing its columns again in Python.
The build now reports which header keys still hold the header's own
values (the provenance it already tracks, with set-aside hooks
included), and the projection uses the header's objects for them, so
identity holds exactly where it did before.
Stage counters record whether a model's header columns were reused or
parsed again, and an integration test pins the native path for models
with `columns` beside `materialized`, `tags` or a description.
* fix(native): read config value text through Python when only Python prints it exactly
Opaque config values were read eagerly at conversion: `str()` twice,
`repr()`, a date check and three hook-entry checks, with a raising
`__repr__` read as empty. Only cheap facts (kind, text, numbers) are now
read when a value is converted. Date checks and display text are asked
of the value's handle when a scan needs them, and the build asks its
host for `str()` and hook-entry checks, so their errors raise as before.
Text is produced in Rust only where it is exact: `None`, booleans,
integers, floats and a string's own text. A string's repr, containers
and opaque values use Python's `str()`/`repr()` of the projected object
for template operands and tag/row-diff unions. That replaces an
approximate Rust repr that printed some format, private-use and
unassigned characters unescaped.
Hook-template context values read only `database`, `schema` and `alias`
instead of converting the whole values dict.
Integration tests pin container text, item errors in template operands
and unions, and that the build never reads an opaque value's text.
* perf(native): carry header containers the config build never looks into whole
Every header value was converted into config nodes, then cloned through
layering and expansion, even large `columns` trees the build only
passes through. A header container whose native parse found no template
or macro, under a key the build never reads item by item (anything but
tags, row-diff, hook and storage keys), is now carried as the header's
own object. Dense compiles return to the instruction count they had
before the typed build.
Because such containers stay the header's own objects, models whose
other config values hold templates also reuse their natively parsed
columns now; an integration case pins it.
* perf(native): convert typed config values key by key on first read
The first typed read of a config record converted every value in
`config.values` into typed nodes, just to read one scalar key such as
`incremental_mode`. A config record now keeps a per-key cache: a value
is converted the first time its key is read, through the same
`values.get(key)`, and kept for later reads. Checked reads keep their
type rules and errors.
Lineage's microbatch check compares the mode text as Python's `==`
does again, so a string that cannot be encoded reads as not-microbatch
instead of raising.
A stage counter records each typed conversion, and an integration test
pins that keys no planner reader reads are never converted.1 parent 39dbb57 commit dc9756d
146 files changed
Lines changed: 5262 additions & 1590 deletions
File tree
- crates
- sqlbuild-discovery
- src
- _helpers
- declaration_files/main
- header_changes
- _helpers
- main
- tests
- model_files/main
- sql_tests/main
- sqlbuild-model-config/src
- config_values
- _helpers
- main
- tests
- model_config_build
- _helpers
- main
- tests
- sqlbuild-python/src/bindings/_helpers
- compile_context
- compile_delta
- compile_driver
- discovery
- input_loops
- model_config
- planner_changes
- planner_entries
- planner_migrations
- planner_phases
- planner_scenario
- planner_strategy
- scopes
- sql_test_glue
- sqlbuild-scopes/src
- compile_usages
- _helpers
- main
- tests
- scope_index
- main
- tests
- scope_report/main
- tests/integration/src/sqlbuild
- cli/commands/main
- compiler/model_config
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 | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
0 commit comments