sqlassert-dbt 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlassert_dbt/__init__.py +1 -1
- sqlassert_dbt/__main__.py +1 -1
- sqlassert_dbt/connect.py +6 -8
- sqlassert_dbt/expectations.py +2 -11
- sqlassert_dbt/project.py +1 -1
- {sqlassert_dbt-0.4.1.dist-info → sqlassert_dbt-0.4.2.dist-info}/METADATA +7 -9
- sqlassert_dbt-0.4.2.dist-info/RECORD +15 -0
- sqlassert_dbt-0.4.1.dist-info/RECORD +0 -15
- {sqlassert_dbt-0.4.1.dist-info → sqlassert_dbt-0.4.2.dist-info}/WHEEL +0 -0
- {sqlassert_dbt-0.4.1.dist-info → sqlassert_dbt-0.4.2.dist-info}/entry_points.txt +0 -0
- {sqlassert_dbt-0.4.1.dist-info → sqlassert_dbt-0.4.2.dist-info}/licenses/LICENSE +0 -0
- {sqlassert_dbt-0.4.1.dist-info → sqlassert_dbt-0.4.2.dist-info}/top_level.txt +0 -0
sqlassert_dbt/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""dbt integration: check a dbt project's tests and Property Markers from its manifest
|
|
1
|
+
"""dbt integration: check a dbt project's tests and Property Markers from its manifest.
|
|
2
2
|
|
|
3
3
|
`analyze_project(project_dir)` reads `target/manifest.json` and returns a
|
|
4
4
|
`DbtReport`: which tests the SQL proves (skippable), which it does not, which
|
sqlassert_dbt/__main__.py
CHANGED
|
@@ -59,7 +59,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
59
59
|
commands = parser.add_subparsers(dest="command", required=True)
|
|
60
60
|
check = commands.add_parser(
|
|
61
61
|
"check",
|
|
62
|
-
help="check the tests and markers of a compiled project
|
|
62
|
+
help="check the tests and markers of a compiled project",
|
|
63
63
|
description="Check a dbt project's tests and markers from its target/manifest.json (run `dbt compile` first). "
|
|
64
64
|
f"Exit status: {EXIT_OK} every marker PROVED, {EXIT_FINDINGS} a marker UNKNOWN or a diagnostic reported, "
|
|
65
65
|
f"{EXIT_USAGE} the manifest cannot be read.",
|
sqlassert_dbt/connect.py
CHANGED
|
@@ -61,14 +61,12 @@ def dbt_fetcher(project: Path, dbt_arguments: list[str]) -> Generator[DatabaseKn
|
|
|
61
61
|
"""A fetcher over the connection dbt opens for `project` with the
|
|
62
62
|
profile, target, profiles directory and vars in `dbt_arguments`, closed
|
|
63
63
|
on exit: a DuckDB file takes one writer, so close it before dbt runs again."""
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
except ImportError as error:
|
|
71
|
-
raise ConnectError(f"--connect needs dbt installed in sqlassert-dbt's Python ({error})") from error
|
|
64
|
+
import yaml
|
|
65
|
+
from dbt.adapters.factory import cleanup_connections, get_adapter, register_adapter, reset_adapters
|
|
66
|
+
from dbt.config.runtime import RuntimeConfig
|
|
67
|
+
from dbt.flags import set_from_args
|
|
68
|
+
from dbt.mp_context import get_mp_context
|
|
69
|
+
|
|
72
70
|
try:
|
|
73
71
|
args = Namespace(
|
|
74
72
|
project_dir=str(project), profiles_dir=str(_profiles_dir(project, dbt_arguments)),
|
sqlassert_dbt/expectations.py
CHANGED
|
@@ -30,14 +30,8 @@ from sqlassert.sql_parse import literal_value
|
|
|
30
30
|
# Referential Coverage (a dbt relationships test checks no Unique Set on its target).
|
|
31
31
|
type PropertyKind = Literal["unique", "key", "not_null", "enum", "coverage"]
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
# (
|
|
35
|
-
# NOT NULL only; their keys are informational. Constraints never apply to views.
|
|
36
|
-
_ENFORCED_CONSTRAINTS = {
|
|
37
|
-
"postgres": frozenset({"not_null", "unique", "primary_key", "foreign_key"}),
|
|
38
|
-
"duckdb": frozenset({"not_null", "unique", "primary_key", "foreign_key"}),
|
|
39
|
-
}
|
|
40
|
-
_NOT_NULL_ONLY = frozenset({"not_null"})
|
|
33
|
+
# Constraints a contracted table declares, whether or not the adapter enforces
|
|
34
|
+
# them (ADR 0012); they never apply to views.
|
|
41
35
|
_CONSTRAINED_MATERIALIZATIONS = {"table", "incremental"}
|
|
42
36
|
|
|
43
37
|
_IDENTIFIER = re.compile(r"[A-Za-z_][A-Za-z0-9_$]*")
|
|
@@ -315,7 +309,6 @@ def resolve(
|
|
|
315
309
|
|
|
316
310
|
|
|
317
311
|
def _constraints(relation: Relation, manifest: Manifest) -> Iterator[Expectation]:
|
|
318
|
-
enforced = _ENFORCED_CONSTRAINTS.get(manifest.adapter_type or "", _NOT_NULL_ONLY)
|
|
319
312
|
for index, constraint in enumerate(relation.constraints):
|
|
320
313
|
kind: PropertyKind
|
|
321
314
|
match constraint.type:
|
|
@@ -333,8 +326,6 @@ def _constraints(relation: Relation, manifest: Manifest) -> Iterator[Expectation
|
|
|
333
326
|
not_a_fact = "the model's contract is not enforced"
|
|
334
327
|
elif relation.materialized not in _CONSTRAINED_MATERIALIZATIONS:
|
|
335
328
|
not_a_fact = f"constraints are not applied to a {relation.materialized} materialization"
|
|
336
|
-
elif constraint.type not in enforced:
|
|
337
|
-
not_a_fact = f"{manifest.adapter_type} does not enforce {constraint.type} constraints"
|
|
338
329
|
else:
|
|
339
330
|
not_a_fact = None
|
|
340
331
|
base = Expectation(
|
sqlassert_dbt/project.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Analyze a dbt project from its `target/manifest.json
|
|
1
|
+
"""Analyze a dbt project from its `target/manifest.json`.
|
|
2
2
|
|
|
3
3
|
The project is one Program (`program.py`), built once per run: each model's
|
|
4
4
|
tests are Assertions, the passing tests of what it reads are Property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlassert-dbt
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Check a dbt project's tests and sqlassert markers from its compiled manifest.
|
|
5
5
|
Author: Fred Israel
|
|
6
6
|
License-Expression: MIT
|
|
@@ -14,10 +14,10 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
+
Requires-Dist: dbt-core>=1.12
|
|
17
18
|
Requires-Dist: sqlassert>=0.3.1
|
|
18
19
|
Requires-Dist: sqlglot<31,>=30.30
|
|
19
20
|
Provides-Extra: test
|
|
20
|
-
Requires-Dist: dbt-core>=1.12; extra == "test"
|
|
21
21
|
Requires-Dist: dbt-duckdb>=1.11; extra == "test"
|
|
22
22
|
Requires-Dist: duckdb; extra == "test"
|
|
23
23
|
Requires-Dist: pytest; extra == "test"
|
|
@@ -64,10 +64,9 @@ A `profiles.yml` kept in the project directory is found without
|
|
|
64
64
|
`--profiles-dir` (by `build`, `test` and `suggest`), unless the working
|
|
65
65
|
directory has one or `DBT_PROFILES_DIR` is set.
|
|
66
66
|
|
|
67
|
-
## Check
|
|
67
|
+
## Check
|
|
68
68
|
|
|
69
|
-
`check` reads
|
|
70
|
-
where it runs (a CI step after `dbt compile`, say):
|
|
69
|
+
`check` reads `target/manifest.json`, so run it after `dbt compile`:
|
|
71
70
|
|
|
72
71
|
```bash
|
|
73
72
|
$ dbt compile
|
|
@@ -122,7 +121,7 @@ manifest cannot be read.
|
|
|
122
121
|
A model's own tests are what gets proved. Upstream tests are evidence, used
|
|
123
122
|
only when they fail on any failing row: not a test with `severity: warn`, a
|
|
124
123
|
`where:` config, or `error_if`/`fail_calc` thresholds. A constraint counts only
|
|
125
|
-
on a
|
|
124
|
+
on a table with an enforced contract, whether or not the adapter checks it.
|
|
126
125
|
|
|
127
126
|
## Suggest from the models you're editing
|
|
128
127
|
|
|
@@ -217,8 +216,7 @@ read then. An enforced contract's table is still declared from the contract,
|
|
|
217
216
|
since the build may not have made it yet; every other table comes from the
|
|
218
217
|
warehouse.
|
|
219
218
|
As with `analyze_database`, a connection only adds proofs. A key the
|
|
220
|
-
warehouse does not enforce is trusted
|
|
221
|
-
own are.
|
|
219
|
+
warehouse does not enforce is trusted, as the SQL's own are.
|
|
222
220
|
|
|
223
221
|
```bash
|
|
224
222
|
$ sqlassert-dbt build --connect .
|
|
@@ -238,7 +236,7 @@ report = analyze_project(project, fetcher=DuckDBKnowledgeFetcher(duckdb.connect(
|
|
|
238
236
|
```
|
|
239
237
|
|
|
240
238
|
`suggest_models(..., fetcher=...)` takes one too. `check` stays
|
|
241
|
-
connectionless
|
|
239
|
+
connectionless.
|
|
242
240
|
|
|
243
241
|
## Details
|
|
244
242
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
sqlassert_dbt/__init__.py,sha256=A21obXKXpKdrUMqCuzN7IgJYjpVVsVa_1MoTMIfjAfM,1242
|
|
2
|
+
sqlassert_dbt/__main__.py,sha256=jnPtWYRElxavsoMGZ0R0N06TnO1awo3SvlpGR2_FIPY,16869
|
|
3
|
+
sqlassert_dbt/connect.py,sha256=nDwEfXqsYy8juctv5f1lLqc72anyIutZxGxf231uggg,5584
|
|
4
|
+
sqlassert_dbt/expectations.py,sha256=LgnH6xp-CoginIrMNXVF-JDKk6h4vgqnX2HLwHVdBoU,17176
|
|
5
|
+
sqlassert_dbt/jinja.py,sha256=uT-XJv54yhWie-Oi8jN8WpTFpE97N8KvSL-tGjYgi0w,12238
|
|
6
|
+
sqlassert_dbt/manifest.py,sha256=gEw-CrzotOpivVfJMJmUbWX80QfKQRwKu0kDLoFnG5w,14316
|
|
7
|
+
sqlassert_dbt/program.py,sha256=S8lOCbHmPdcJTLkAlolHecj5ZLkvJ8WLrVQeungkoAI,59555
|
|
8
|
+
sqlassert_dbt/project.py,sha256=8DHCCXxy26pxMQDp5JGVHJpDQoTS_aQJQZl7PD4gKpY,32772
|
|
9
|
+
sqlassert_dbt/report.py,sha256=q4z789ZDlulIonPAEJVh5TpU0uC-fdVY5tYb0CZE2Bs,10359
|
|
10
|
+
sqlassert_dbt-0.4.2.dist-info/licenses/LICENSE,sha256=KCR0_j-gr5ufUNxamIKNzeyyiI6g-S69oecRjZ07l_A,1068
|
|
11
|
+
sqlassert_dbt-0.4.2.dist-info/METADATA,sha256=VntgYjtpEt9dhXPyIFI2Rob4BNgyT4jFrnB4LUFfY4s,11443
|
|
12
|
+
sqlassert_dbt-0.4.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
13
|
+
sqlassert_dbt-0.4.2.dist-info/entry_points.txt,sha256=4J9EK9q9ozlR8A8fJj7oPJmYtvl5HzM0oXX49HDB_vk,62
|
|
14
|
+
sqlassert_dbt-0.4.2.dist-info/top_level.txt,sha256=w2-3Vq1UafNmPEBbCwdq4aZ-hsvRaBwKvouODJDNc1M,14
|
|
15
|
+
sqlassert_dbt-0.4.2.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
sqlassert_dbt/__init__.py,sha256=28jsIwXiNt_my5AQMGNQtsRC9tZs-4zmN_Tjum14bQ0,1255
|
|
2
|
-
sqlassert_dbt/__main__.py,sha256=Hh3rTq-RLTdAqcLdWUZ416FG9nvE8c2hqVTwPVUBXnk,16882
|
|
3
|
-
sqlassert_dbt/connect.py,sha256=7y2fIXFa1ICJDqTEMnuIauGpyrf9oztZVZurJw0WSUw,5753
|
|
4
|
-
sqlassert_dbt/expectations.py,sha256=_icggkgjnSTQA9pPM4MkZhaYOAk8WAZiuPlmnEfOfM4,17739
|
|
5
|
-
sqlassert_dbt/jinja.py,sha256=uT-XJv54yhWie-Oi8jN8WpTFpE97N8KvSL-tGjYgi0w,12238
|
|
6
|
-
sqlassert_dbt/manifest.py,sha256=gEw-CrzotOpivVfJMJmUbWX80QfKQRwKu0kDLoFnG5w,14316
|
|
7
|
-
sqlassert_dbt/program.py,sha256=S8lOCbHmPdcJTLkAlolHecj5ZLkvJ8WLrVQeungkoAI,59555
|
|
8
|
-
sqlassert_dbt/project.py,sha256=eLv8QzdTi_gVrByrcCnaJ4p0db7Pt0mXDMJvNqX78DI,32785
|
|
9
|
-
sqlassert_dbt/report.py,sha256=q4z789ZDlulIonPAEJVh5TpU0uC-fdVY5tYb0CZE2Bs,10359
|
|
10
|
-
sqlassert_dbt-0.4.1.dist-info/licenses/LICENSE,sha256=KCR0_j-gr5ufUNxamIKNzeyyiI6g-S69oecRjZ07l_A,1068
|
|
11
|
-
sqlassert_dbt-0.4.1.dist-info/METADATA,sha256=KORP05kSQfq36ysKQ18dFmlh8AG6Nr_75I7d759fw24,11570
|
|
12
|
-
sqlassert_dbt-0.4.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
13
|
-
sqlassert_dbt-0.4.1.dist-info/entry_points.txt,sha256=4J9EK9q9ozlR8A8fJj7oPJmYtvl5HzM0oXX49HDB_vk,62
|
|
14
|
-
sqlassert_dbt-0.4.1.dist-info/top_level.txt,sha256=w2-3Vq1UafNmPEBbCwdq4aZ-hsvRaBwKvouODJDNc1M,14
|
|
15
|
-
sqlassert_dbt-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|