You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit be45fd8
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: read analysis natively, plan SQL tests on a native thread and trim hot spots (#1118)
* refactor(analysis): host InferredNullability natively
InferredNullability becomes a native StrEnum registered with the compiler
enums, so Rust reads it through the typed registry instead of importing
sqlbuild.compiler.lineage.types in thirteen places. Python callers import
it from sqlbuild._native and the shape-only module is deleted. Stage
captures keep the original captured shape name.
* refactor(analysis): read compiled models' analysis as native data
Semantic shapes, coverage, type recovery, completion, metadata and lineage
read each compiled model's inferred columns, declared columns, star flags,
unchecked outputs, lineage, binding validation and dynamic proof through
typed accessors. Native model views answer from their owner's Rust facts
without building Python projections; hand-built records are converted at
the read.
* refactor(rules): read proven dynamic contracts natively for SQL rule paths
* refactor: plan SQL tests on a native thread instead of a Python thread and future
SQL test planning ran on a Python threading.Thread whose target was the
native planning function, reporting through a concurrent.futures.Future.
It now runs on a Rust thread that attaches to the interpreter and sends
its outcome over a channel; the planner and `start_sql_test_planning`
read it through the native `SqlTestPlanning` handle. The atexit hook
waits, without the GIL and for at most five seconds, until no planning
thread runs, so finalization never ends one inside native code. The
planning entry is still looked up on the module, so tests can replace it.
* refactor: call per-model planner helpers directly instead of through the module
Model plan entries, audit entries, relation contexts and cursor
resolution looked up native helpers on `sqlbuild._native` and called
them with keyword dictionaries once or more per model. They now call the
Rust functions directly: authored config strings and cursor bounds, the
model plan action, SQL, hooks, full-refresh and microbatch limit
resolution, model plan entry assembly, audit selection, attachment kind,
effective run scope and lineage reads. Results are unchanged.
* perf(sqltext): reject code bytes before dialect comment and quote checks
Dialect non-code scanning is called once per byte by many SQL test and
analysis scanners. Return early when the byte cannot open a block
comment, line comment, dollar quote or quoted text, instead of running
prefix comparisons at every offset. Results are unchanged.
* perf(rules): run the interpolation-site pattern only at possible site starts
Lint and format site patterns can only match at '@', '$' or '_'; skip the
anchored regex search at every other code byte.
* perf(analysis): find the end of a SQL test select list in one scan
Projection-name validation scanned each branch once per clause keyword.
Scan once and stop at the first top-level FROM or clause keyword with the
same name and IS [NOT] DISTINCT FROM rules.
* perf(cache): stop re-hashing replay stdout when reading a stored compile
The store's whole-body checksum already verifies the stdout record stored
under its digest, so reading a project reuse entry no longer hashes the
full compile output a second time. Persisted bytes are unchanged.
* perf: use FxHash indexes for hot in-memory lookups
Add rustc-hash (already in the lock file) as the workspace fast hasher.
Index hosted shape names once instead of scanning every shape per lookup,
match UNION BY NAME outputs through a name index instead of quadratic
scans, and use FxHash for hot sets and maps in function-name validation,
CTE column rules, lint additional facts and SQL test identifier tokens.
None of these maps' iteration order reaches output.
* perf: stream the custom-rule host payload pickle to disk
The parent pickled the whole host payload into one bytes object before
writing it, holding a second copy of the payload (about 285 MB for a
10,000-model project) alive during the rules phase. Pickle straight into
the partial file instead; the atomic rename and the payload the hosts
read are unchanged.
* chore: drop the unused hosted shape index after the registry replaced reverse lookups
* fix: mark SQL test planning finished on panic and drop an unused cache dependency
sql:"WITH __ref__orders AS (SELECT 1 AS id), __expected__orders AS (SELECT 'completed' IS DISTINCT FROM 'x' AS status, a IS NOT /* c */ DISTINCT FROM b AS same FROM __ref__orders) SELECT 1",
170
170
expected_outcome:accepted_outcome(false),
171
171
},
172
+
ExtractionRuleTestCase{
173
+
description:"clause keywords after a dot or inside parentheses do not end the select list",
174
+
mode:"model",
175
+
raw:false,
176
+
syntax:"generic",
177
+
sql:"WITH __ref__orders AS (SELECT 1 AS id), __expected__orders AS (SELECT t.order, t.limit AS l, (SELECT max(id) FROM __ref__orders WHERE id > 0 ORDER BY 1) AS m FROM __ref__orders t WHERE t.id > 0 ORDER BY 1) SELECT 1",
178
+
expected_outcome:accepted_outcome(false),
179
+
},
180
+
ExtractionRuleTestCase{
181
+
description:"the first top-level clause keyword ends a select list without FROM",
182
+
mode:"model",
183
+
raw:false,
184
+
syntax:"generic",
185
+
sql:"WITH __ref__orders AS (SELECT 1 AS id), __expected__orders AS (SELECT 1 AS id WHERE TRUE LIMIT 1) SELECT 1",
186
+
expected_outcome:accepted_outcome(false),
187
+
},
172
188
ExtractionRuleTestCase{
173
189
description:"IS DISTINCT FROM without an alias is rejected",
0 commit comments