dbt-hodor 0.1.0__tar.gz
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.
- dbt_hodor-0.1.0/LICENSE +202 -0
- dbt_hodor-0.1.0/NOTICE +16 -0
- dbt_hodor-0.1.0/PKG-INFO +209 -0
- dbt_hodor-0.1.0/README.md +187 -0
- dbt_hodor-0.1.0/pyproject.toml +73 -0
- dbt_hodor-0.1.0/pyproject.toml.orig +68 -0
- dbt_hodor-0.1.0/src/dbt_hodor/__init__.py +21 -0
- dbt_hodor-0.1.0/src/dbt_hodor/cli.py +178 -0
- dbt_hodor-0.1.0/src/dbt_hodor/config.py +258 -0
- dbt_hodor-0.1.0/src/dbt_hodor/engine.py +109 -0
- dbt_hodor-0.1.0/src/dbt_hodor/explain.py +130 -0
- dbt_hodor-0.1.0/src/dbt_hodor/hashing.py +400 -0
- dbt_hodor-0.1.0/src/dbt_hodor/lineage.py +87 -0
- dbt_hodor-0.1.0/src/dbt_hodor/metadata.py +137 -0
- dbt_hodor-0.1.0/src/dbt_hodor/patches.py +178 -0
- dbt_hodor-0.1.0/src/dbt_hodor/plugin.py +96 -0
- dbt_hodor-0.1.0/src/dbt_hodor/providers.py +153 -0
- dbt_hodor-0.1.0/src/dbt_hodor/py.typed +0 -0
- dbt_hodor-0.1.0/src/dbt_hodor/records.py +156 -0
- dbt_hodor-0.1.0/src/dbt_hodor/runtime.py +734 -0
- dbt_hodor-0.1.0/src/dbt_hodor/state_config.py +57 -0
- dbt_hodor-0.1.0/src/dbt_hodor/store/__init__.py +34 -0
- dbt_hodor-0.1.0/src/dbt_hodor/store/delta.py +129 -0
- dbt_hodor-0.1.0/src/dbt_hodor/store/duckdb.py +100 -0
- dbt_hodor-0.1.0/src/dbt_hodor/store/postgres.py +186 -0
dbt_hodor-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 The dbt-hodor Authors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
dbt_hodor-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
dbt-hodor
|
|
2
|
+
Copyright 2026 The dbt-hodor Authors
|
|
3
|
+
|
|
4
|
+
This product includes software derived from dbt-state
|
|
5
|
+
(https://github.com/dbt-labs/dbt-state, commit b0f3030),
|
|
6
|
+
Copyright 2026 Fivetran, Inc., licensed under the Apache License, Version 2.0.
|
|
7
|
+
|
|
8
|
+
Files derived from dbt-state, each modified for dbt-hodor:
|
|
9
|
+
- src/dbt_hodor/state_config.py (from clients/dbt_state/src/dbt_state/plugin.py):
|
|
10
|
+
the `state:` config merge, the only upstream-derived logic in dbt-hodor
|
|
11
|
+
- src/dbt_hodor/plugin.py (from clients/dbt_state/src/dbt_state/plugin.py):
|
|
12
|
+
the plugin entry point
|
|
13
|
+
- src/dbt_hodor/patches.py (from clients/dbt_state/src/dbt_state/runner.py)
|
|
14
|
+
|
|
15
|
+
dbt is a trademark of dbt Labs, Inc. dbt-hodor is not affiliated with or
|
|
16
|
+
endorsed by dbt Labs, Inc. or Fivetran, Inc.
|
dbt_hodor-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbt-hodor
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reuse unchanged dbt nodes and rebuild only when code or upstream data changed. A free, self-hosted alternative to dbt State.
|
|
5
|
+
Author: Isa Inalcik
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Dist: dbt-core>=1.12,<1.13
|
|
12
|
+
Requires-Dist: sqlglot>=30.22,<31
|
|
13
|
+
Requires-Dist: duckdb>=1.0 ; extra == 'duckdb'
|
|
14
|
+
Requires-Dist: psycopg[binary]>=3.2 ; extra == 'lakebase'
|
|
15
|
+
Requires-Dist: databricks-sdk>=0.81 ; extra == 'lakebase'
|
|
16
|
+
Requires-Dist: psycopg[binary]>=3.2 ; extra == 'postgres'
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Provides-Extra: duckdb
|
|
19
|
+
Provides-Extra: lakebase
|
|
20
|
+
Provides-Extra: postgres
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
24
|
+
<p align="center">
|
|
25
|
+
<picture>
|
|
26
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/hodor-logo.svg">
|
|
27
|
+
<img src="docs/assets/hodor-logo-light.svg" width="420" alt="dbt-hodor: Hold Old Data, Or Rebuild">
|
|
28
|
+
</picture>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<h1 align="center">dbt-hodor</h1>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<a href="https://github.com/alaturqua/dbt-hodor/actions/workflows/ci.yml"><img src="https://github.com/alaturqua/dbt-hodor/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
35
|
+
<img src="https://img.shields.io/badge/python-3.10%20to%203.12-blue" alt="Python 3.10 to 3.12">
|
|
36
|
+
<img src="https://img.shields.io/badge/dbt--core-1.12-orange" alt="dbt-core 1.12">
|
|
37
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="Apache-2.0">
|
|
38
|
+
<a href="https://alaturqua.github.io/dbt-hodor/"><img src="https://img.shields.io/badge/docs-online-informational" alt="Documentation"></a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
**[Documentation](https://alaturqua.github.io/dbt-hodor/)** | **[Interactive guide](https://alaturqua.github.io/dbt-hodor/guide/)** with a run simulator | **[Design spec](https://alaturqua.github.io/dbt-hodor/design/)**
|
|
42
|
+
|
|
43
|
+
dbt-hodor is a free, self-hosted alternative to dbt Labs' [dbt State](https://docs.getdbt.com/docs/deploy/dbt-state-about). It runs inside dbt. For every selected node it decides whether to reuse the object that is already in the warehouse or to build it again. A node is reused when its logic has not changed and its upstream data has not changed since the last build.
|
|
44
|
+
|
|
45
|
+
It needs no dbt platform account and sends nothing to external services. State lives in a Delta table on Databricks, in a Postgres database such as Databricks Lakebase, or in a local DuckDB file.
|
|
46
|
+
|
|
47
|
+
> **Status: early development.** hodor runs inside dbt and passes end-to-end tests on dbt-duckdb. Tested live on a Databricks Unity Catalog workspace with a SQL warehouse and dbt-databricks 1.12.7 (2026-10-20 and 2026-10-21): reuse of tables, incremental models (including `replace_where`), views, seeds and snapshots, replayed tests, maintenance commits (OPTIMIZE, zero-row writes, SET TBLPROPERTIES) that keep nodes reused, and real new data or a changed seed file that rebuilds them. The live test runs twice, with `use_materialization_v2` off and on, and also covers contracts with a primary key, a row filter, column masks, date-window and stamp models, and a table swapped in by `use_safer_relation_operations`. The same live suite passes on a second, independent Databricks workspace (2026-10-21). The `postgres` store is tested end to end against Databricks Lakebase. It has not run in a large production project yet. Start in shadow mode.
|
|
48
|
+
|
|
49
|
+
## Why "hodor"
|
|
50
|
+
|
|
51
|
+
The name is a backronym: **H**old **O**ld **D**ata, **O**r **R**ebuild. That is the only decision hodor makes, once per node.
|
|
52
|
+
|
|
53
|
+
hodor holds the door in front of your warehouse. A node gets through to a rebuild only when its code changed or new data arrived upstream. Everything else keeps the data it already has.
|
|
54
|
+
|
|
55
|
+
## How it works
|
|
56
|
+
|
|
57
|
+
For each node in `dbt run`, `dbt build`, `dbt test`, `dbt seed` or `dbt snapshot`, hodor:
|
|
58
|
+
|
|
59
|
+
1. **Hashes the logic.** For a seed this is the CSV file. Otherwise the compiled SQL is normalized with [sqlglot](https://github.com/tobymao/sqlglot) (Databricks dialect), so case, quoting, comments and table aliases do not count as changes. Values that differ on every run, such as `invocation_id`, are replaced first. The node config is hashed as well.
|
|
60
|
+
2. **Checks the upstream data.** Each upstream table has a data version. On Databricks it comes from the Delta commit history; maintenance commits such as `OPTIMIZE` or `VACUUM` do not count as data changes. On DuckDB it is a content fingerprint.
|
|
61
|
+
3. **Decides.** It compares both against the record of the node's last build and returns `reuse` or `build`, with a reason code.
|
|
62
|
+
4. **Records.** It appends one record per node to the state table.
|
|
63
|
+
|
|
64
|
+
A run with no code changes skips sqlglot entirely: when the compiled SQL is byte-identical to the last build, hodor reuses the stored analysis. For 10,000 compiled models, hashing then takes about 0.1 seconds instead of about 4 minutes.
|
|
65
|
+
|
|
66
|
+
### Safety: fail open
|
|
67
|
+
|
|
68
|
+
Every failure leads to a build, never to a reuse. An error while deciding, a store that cannot be read, a table whose data version is unknown, an input hodor cannot trace (for example `read_files(...)`): in each case the node builds as plain dbt would. hodor never fails a dbt run.
|
|
69
|
+
|
|
70
|
+
### Reason codes
|
|
71
|
+
|
|
72
|
+
| Reason | Decision |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `full_refresh` | build |
|
|
75
|
+
| `unsupported` | build |
|
|
76
|
+
| `no_history` | build |
|
|
77
|
+
| `relation_missing` | build |
|
|
78
|
+
| `code_changed` | build |
|
|
79
|
+
| `config_changed` | build |
|
|
80
|
+
| `target_modified` | build |
|
|
81
|
+
| `select_star_view` | build |
|
|
82
|
+
| `view_unchanged` | reuse |
|
|
83
|
+
| `unknown_upstream` | build |
|
|
84
|
+
| `no_new_data` | reuse |
|
|
85
|
+
| `within_lag_tolerance` | reuse |
|
|
86
|
+
| `new_upstream_data` | build |
|
|
87
|
+
| `volatile_sql` | build |
|
|
88
|
+
| `hodor_error` | build |
|
|
89
|
+
|
|
90
|
+
The rules are checked in this order; the first match decides. `dbt-hodor explain -s <model>` shows the reason for one node, with the hashes and upstream data versions it compared. The full rules are in the [design spec](docs/design.md#5-decision-rules).
|
|
91
|
+
|
|
92
|
+
## Modes
|
|
93
|
+
|
|
94
|
+
| Mode | Behavior |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `off` | hodor does nothing. |
|
|
97
|
+
| `shadow` (default) | hodor decides and records, but every node builds. Use it to check the decisions before you trust them. |
|
|
98
|
+
| `on` | hodor reuses nodes. |
|
|
99
|
+
|
|
100
|
+
Installing the package never skips anything until someone sets `on`.
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
### Node configs
|
|
105
|
+
|
|
106
|
+
hodor reads the same `state:` block as dbt State, so a project can switch between the two. Set it in YAML:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
# dbt_project.yml
|
|
110
|
+
models:
|
|
111
|
+
my_project:
|
|
112
|
+
+state:
|
|
113
|
+
lag_tolerance: 4h
|
|
114
|
+
require_fresh_data_from: any
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Key | Default | Values |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| `lag_tolerance` | `45m` | `0s`, `45m`, `4h`, `1d`, `1w`, integer seconds, or `{count: 4, period: hour}` |
|
|
120
|
+
| `require_fresh_data_from` | `any` | `any`: build when any upstream has new data. `all`: build only when all of them have. |
|
|
121
|
+
| `compare_unrendered_code` | `false` | `true`: build only when both the rendered and the unrendered code changed |
|
|
122
|
+
| `execute_hooks_on_any_reuse` | `false` | `true`: run pre- and post-hooks on a reused node. `execute_hooks_on_reuse` is also accepted. |
|
|
123
|
+
| `evaluate_volatile_sql` | auto | Auto: volatile functions such as `current_date()`, `current_user()` and `current_timestamp()` count as an upstream that changes, unless they only fill a stamp column. `true`: stamp columns count too. `false`: they never count (the dbt State default). |
|
|
124
|
+
|
|
125
|
+
`pre_clone`, `allow_clones` and `defer_to_target` are accepted and ignored, with a warning.
|
|
126
|
+
|
|
127
|
+
### Settings
|
|
128
|
+
|
|
129
|
+
Set them on the `profiles.yml` target, or for one run with `--vars '{hodor_mode: off}'`. Precedence: environment variable, then `--vars`, then the profile key.
|
|
130
|
+
|
|
131
|
+
| Profile key | Env var | Default | Values |
|
|
132
|
+
| --- | --- | --- | --- |
|
|
133
|
+
| `hodor_mode` | `HODOR_MODE` | `shadow` | `off`, `shadow`, `on` |
|
|
134
|
+
| `hodor_store` | `HODOR_STORE` | `delta` | `delta`, `duckdb`, `postgres` (alias `lakebase`) |
|
|
135
|
+
| `hodor_database` | `HODOR_DATABASE` | the target's `catalog` (or `database`) | Databricks catalog; Postgres database (later). Not used by `duckdb` |
|
|
136
|
+
| `hodor_schema` | `HODOR_SCHEMA` | none for `delta` (required); `main` for `duckdb` | schema name |
|
|
137
|
+
| `hodor_table` | `HODOR_TABLE` | `hodor_state` | table name |
|
|
138
|
+
| `hodor_path` | `HODOR_PATH` | `.hodor/state.duckdb` | DuckDB database file, for `duckdb` |
|
|
139
|
+
| `hodor_metadata_threads` | `HODOR_METADATA_THREADS` | `8` | 1-64 |
|
|
140
|
+
| `hodor_lookback_days` | `HODOR_LOOKBACK_DAYS` | `90` | 1-3650 |
|
|
141
|
+
|
|
142
|
+
Name parts may contain letters, digits, `_` and `-`. hodor always quotes them.
|
|
143
|
+
|
|
144
|
+
### Where the state lives
|
|
145
|
+
|
|
146
|
+
| Store | Location | Created on first use |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| `delta` | `<hodor_database>.<hodor_schema>.<hodor_table>` | the table only. The schema must exist, because creating one needs catalog-level grants |
|
|
149
|
+
| `duckdb` | table `<hodor_schema>.<hodor_table>` in the file `hodor_path` | the file, the schema and the table |
|
|
150
|
+
| `postgres` (alias `lakebase`) | `<hodor_schema>.<hodor_table>` in the Postgres database `hodor_database` | the schema and the table |
|
|
151
|
+
|
|
152
|
+
`delta` has no default schema on purpose: hodor writes nothing to a catalog until someone names the schema. Without it, hodor turns itself off with a warning.
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
# profiles.yml
|
|
156
|
+
my_project:
|
|
157
|
+
target: prod
|
|
158
|
+
outputs:
|
|
159
|
+
prod:
|
|
160
|
+
type: databricks
|
|
161
|
+
catalog: my_catalog
|
|
162
|
+
# ... connection settings ...
|
|
163
|
+
hodor_mode: shadow
|
|
164
|
+
hodor_schema: ops
|
|
165
|
+
# state table: my_catalog.ops.hodor_state
|
|
166
|
+
local:
|
|
167
|
+
type: duckdb
|
|
168
|
+
path: dev.duckdb
|
|
169
|
+
hodor_store: duckdb
|
|
170
|
+
# state table: main.hodor_state in .hodor/state.duckdb
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The state table decides what gets skipped in prod. Grant `MODIFY` on it only to the job service principals.
|
|
174
|
+
|
|
175
|
+
## Scope of v1
|
|
176
|
+
|
|
177
|
+
Supported: models materialized as `table`, `incremental` (append, merge, delete+insert, insert_overwrite, replace_where; an unset strategy counts as merge) and `view`, seeds, snapshots, and data tests (generic and singular), on `dbt-databricks` 1.12.7 and `dbt-duckdb`, with dbt-core 1.12.x.
|
|
178
|
+
|
|
179
|
+
Model versions: each version is its own node with its own table and records. Moving `latest_version` rebuilds the models that `ref()` it.
|
|
180
|
+
|
|
181
|
+
Always built as plain dbt: clones and deferral, Python models, microbatch, materialized views, streaming tables, metric views, custom materializations, custom incremental strategies and unit tests.
|
|
182
|
+
|
|
183
|
+
Known limit: a change to dbt's or the adapter's own macros, for example a dbt-databricks upgrade, does not show in any hash. Run once with `HODOR_MODE=off` after such an upgrade. Project and package macros that a materialization or a hook runs are in the config hash.
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
Requires [uv](https://docs.astral.sh/uv/). Local development and tests run on DuckDB, with no Databricks access.
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
uv sync
|
|
191
|
+
uv run pytest
|
|
192
|
+
uv run ruff check
|
|
193
|
+
uv run ruff format
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The live Databricks test is opt-in: see [docs/development.md](docs/development.md#tests).
|
|
197
|
+
|
|
198
|
+
Build a wheel with `uv build`. The package is not published to any index yet.
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) has the setup, the
|
|
203
|
+
checks to run, and what a decision change needs. A wrong reuse, where hodor skipped a node
|
|
204
|
+
it should have rebuilt, is a security-grade bug: report it privately through the Security tab.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
Apache-2.0. [NOTICE](NOTICE) carries the attribution for the derived files and the trademark
|
|
209
|
+
notice; [LICENSE](LICENSE) is the full licence text.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
<p align="center">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/hodor-logo.svg">
|
|
5
|
+
<img src="docs/assets/hodor-logo-light.svg" width="420" alt="dbt-hodor: Hold Old Data, Or Rebuild">
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">dbt-hodor</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/alaturqua/dbt-hodor/actions/workflows/ci.yml"><img src="https://github.com/alaturqua/dbt-hodor/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/python-3.10%20to%203.12-blue" alt="Python 3.10 to 3.12">
|
|
14
|
+
<img src="https://img.shields.io/badge/dbt--core-1.12-orange" alt="dbt-core 1.12">
|
|
15
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="Apache-2.0">
|
|
16
|
+
<a href="https://alaturqua.github.io/dbt-hodor/"><img src="https://img.shields.io/badge/docs-online-informational" alt="Documentation"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
**[Documentation](https://alaturqua.github.io/dbt-hodor/)** | **[Interactive guide](https://alaturqua.github.io/dbt-hodor/guide/)** with a run simulator | **[Design spec](https://alaturqua.github.io/dbt-hodor/design/)**
|
|
20
|
+
|
|
21
|
+
dbt-hodor is a free, self-hosted alternative to dbt Labs' [dbt State](https://docs.getdbt.com/docs/deploy/dbt-state-about). It runs inside dbt. For every selected node it decides whether to reuse the object that is already in the warehouse or to build it again. A node is reused when its logic has not changed and its upstream data has not changed since the last build.
|
|
22
|
+
|
|
23
|
+
It needs no dbt platform account and sends nothing to external services. State lives in a Delta table on Databricks, in a Postgres database such as Databricks Lakebase, or in a local DuckDB file.
|
|
24
|
+
|
|
25
|
+
> **Status: early development.** hodor runs inside dbt and passes end-to-end tests on dbt-duckdb. Tested live on a Databricks Unity Catalog workspace with a SQL warehouse and dbt-databricks 1.12.7 (2026-10-20 and 2026-10-21): reuse of tables, incremental models (including `replace_where`), views, seeds and snapshots, replayed tests, maintenance commits (OPTIMIZE, zero-row writes, SET TBLPROPERTIES) that keep nodes reused, and real new data or a changed seed file that rebuilds them. The live test runs twice, with `use_materialization_v2` off and on, and also covers contracts with a primary key, a row filter, column masks, date-window and stamp models, and a table swapped in by `use_safer_relation_operations`. The same live suite passes on a second, independent Databricks workspace (2026-10-21). The `postgres` store is tested end to end against Databricks Lakebase. It has not run in a large production project yet. Start in shadow mode.
|
|
26
|
+
|
|
27
|
+
## Why "hodor"
|
|
28
|
+
|
|
29
|
+
The name is a backronym: **H**old **O**ld **D**ata, **O**r **R**ebuild. That is the only decision hodor makes, once per node.
|
|
30
|
+
|
|
31
|
+
hodor holds the door in front of your warehouse. A node gets through to a rebuild only when its code changed or new data arrived upstream. Everything else keeps the data it already has.
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
For each node in `dbt run`, `dbt build`, `dbt test`, `dbt seed` or `dbt snapshot`, hodor:
|
|
36
|
+
|
|
37
|
+
1. **Hashes the logic.** For a seed this is the CSV file. Otherwise the compiled SQL is normalized with [sqlglot](https://github.com/tobymao/sqlglot) (Databricks dialect), so case, quoting, comments and table aliases do not count as changes. Values that differ on every run, such as `invocation_id`, are replaced first. The node config is hashed as well.
|
|
38
|
+
2. **Checks the upstream data.** Each upstream table has a data version. On Databricks it comes from the Delta commit history; maintenance commits such as `OPTIMIZE` or `VACUUM` do not count as data changes. On DuckDB it is a content fingerprint.
|
|
39
|
+
3. **Decides.** It compares both against the record of the node's last build and returns `reuse` or `build`, with a reason code.
|
|
40
|
+
4. **Records.** It appends one record per node to the state table.
|
|
41
|
+
|
|
42
|
+
A run with no code changes skips sqlglot entirely: when the compiled SQL is byte-identical to the last build, hodor reuses the stored analysis. For 10,000 compiled models, hashing then takes about 0.1 seconds instead of about 4 minutes.
|
|
43
|
+
|
|
44
|
+
### Safety: fail open
|
|
45
|
+
|
|
46
|
+
Every failure leads to a build, never to a reuse. An error while deciding, a store that cannot be read, a table whose data version is unknown, an input hodor cannot trace (for example `read_files(...)`): in each case the node builds as plain dbt would. hodor never fails a dbt run.
|
|
47
|
+
|
|
48
|
+
### Reason codes
|
|
49
|
+
|
|
50
|
+
| Reason | Decision |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `full_refresh` | build |
|
|
53
|
+
| `unsupported` | build |
|
|
54
|
+
| `no_history` | build |
|
|
55
|
+
| `relation_missing` | build |
|
|
56
|
+
| `code_changed` | build |
|
|
57
|
+
| `config_changed` | build |
|
|
58
|
+
| `target_modified` | build |
|
|
59
|
+
| `select_star_view` | build |
|
|
60
|
+
| `view_unchanged` | reuse |
|
|
61
|
+
| `unknown_upstream` | build |
|
|
62
|
+
| `no_new_data` | reuse |
|
|
63
|
+
| `within_lag_tolerance` | reuse |
|
|
64
|
+
| `new_upstream_data` | build |
|
|
65
|
+
| `volatile_sql` | build |
|
|
66
|
+
| `hodor_error` | build |
|
|
67
|
+
|
|
68
|
+
The rules are checked in this order; the first match decides. `dbt-hodor explain -s <model>` shows the reason for one node, with the hashes and upstream data versions it compared. The full rules are in the [design spec](docs/design.md#5-decision-rules).
|
|
69
|
+
|
|
70
|
+
## Modes
|
|
71
|
+
|
|
72
|
+
| Mode | Behavior |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `off` | hodor does nothing. |
|
|
75
|
+
| `shadow` (default) | hodor decides and records, but every node builds. Use it to check the decisions before you trust them. |
|
|
76
|
+
| `on` | hodor reuses nodes. |
|
|
77
|
+
|
|
78
|
+
Installing the package never skips anything until someone sets `on`.
|
|
79
|
+
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
### Node configs
|
|
83
|
+
|
|
84
|
+
hodor reads the same `state:` block as dbt State, so a project can switch between the two. Set it in YAML:
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
# dbt_project.yml
|
|
88
|
+
models:
|
|
89
|
+
my_project:
|
|
90
|
+
+state:
|
|
91
|
+
lag_tolerance: 4h
|
|
92
|
+
require_fresh_data_from: any
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
| Key | Default | Values |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `lag_tolerance` | `45m` | `0s`, `45m`, `4h`, `1d`, `1w`, integer seconds, or `{count: 4, period: hour}` |
|
|
98
|
+
| `require_fresh_data_from` | `any` | `any`: build when any upstream has new data. `all`: build only when all of them have. |
|
|
99
|
+
| `compare_unrendered_code` | `false` | `true`: build only when both the rendered and the unrendered code changed |
|
|
100
|
+
| `execute_hooks_on_any_reuse` | `false` | `true`: run pre- and post-hooks on a reused node. `execute_hooks_on_reuse` is also accepted. |
|
|
101
|
+
| `evaluate_volatile_sql` | auto | Auto: volatile functions such as `current_date()`, `current_user()` and `current_timestamp()` count as an upstream that changes, unless they only fill a stamp column. `true`: stamp columns count too. `false`: they never count (the dbt State default). |
|
|
102
|
+
|
|
103
|
+
`pre_clone`, `allow_clones` and `defer_to_target` are accepted and ignored, with a warning.
|
|
104
|
+
|
|
105
|
+
### Settings
|
|
106
|
+
|
|
107
|
+
Set them on the `profiles.yml` target, or for one run with `--vars '{hodor_mode: off}'`. Precedence: environment variable, then `--vars`, then the profile key.
|
|
108
|
+
|
|
109
|
+
| Profile key | Env var | Default | Values |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| `hodor_mode` | `HODOR_MODE` | `shadow` | `off`, `shadow`, `on` |
|
|
112
|
+
| `hodor_store` | `HODOR_STORE` | `delta` | `delta`, `duckdb`, `postgres` (alias `lakebase`) |
|
|
113
|
+
| `hodor_database` | `HODOR_DATABASE` | the target's `catalog` (or `database`) | Databricks catalog; Postgres database (later). Not used by `duckdb` |
|
|
114
|
+
| `hodor_schema` | `HODOR_SCHEMA` | none for `delta` (required); `main` for `duckdb` | schema name |
|
|
115
|
+
| `hodor_table` | `HODOR_TABLE` | `hodor_state` | table name |
|
|
116
|
+
| `hodor_path` | `HODOR_PATH` | `.hodor/state.duckdb` | DuckDB database file, for `duckdb` |
|
|
117
|
+
| `hodor_metadata_threads` | `HODOR_METADATA_THREADS` | `8` | 1-64 |
|
|
118
|
+
| `hodor_lookback_days` | `HODOR_LOOKBACK_DAYS` | `90` | 1-3650 |
|
|
119
|
+
|
|
120
|
+
Name parts may contain letters, digits, `_` and `-`. hodor always quotes them.
|
|
121
|
+
|
|
122
|
+
### Where the state lives
|
|
123
|
+
|
|
124
|
+
| Store | Location | Created on first use |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| `delta` | `<hodor_database>.<hodor_schema>.<hodor_table>` | the table only. The schema must exist, because creating one needs catalog-level grants |
|
|
127
|
+
| `duckdb` | table `<hodor_schema>.<hodor_table>` in the file `hodor_path` | the file, the schema and the table |
|
|
128
|
+
| `postgres` (alias `lakebase`) | `<hodor_schema>.<hodor_table>` in the Postgres database `hodor_database` | the schema and the table |
|
|
129
|
+
|
|
130
|
+
`delta` has no default schema on purpose: hodor writes nothing to a catalog until someone names the schema. Without it, hodor turns itself off with a warning.
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
# profiles.yml
|
|
134
|
+
my_project:
|
|
135
|
+
target: prod
|
|
136
|
+
outputs:
|
|
137
|
+
prod:
|
|
138
|
+
type: databricks
|
|
139
|
+
catalog: my_catalog
|
|
140
|
+
# ... connection settings ...
|
|
141
|
+
hodor_mode: shadow
|
|
142
|
+
hodor_schema: ops
|
|
143
|
+
# state table: my_catalog.ops.hodor_state
|
|
144
|
+
local:
|
|
145
|
+
type: duckdb
|
|
146
|
+
path: dev.duckdb
|
|
147
|
+
hodor_store: duckdb
|
|
148
|
+
# state table: main.hodor_state in .hodor/state.duckdb
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The state table decides what gets skipped in prod. Grant `MODIFY` on it only to the job service principals.
|
|
152
|
+
|
|
153
|
+
## Scope of v1
|
|
154
|
+
|
|
155
|
+
Supported: models materialized as `table`, `incremental` (append, merge, delete+insert, insert_overwrite, replace_where; an unset strategy counts as merge) and `view`, seeds, snapshots, and data tests (generic and singular), on `dbt-databricks` 1.12.7 and `dbt-duckdb`, with dbt-core 1.12.x.
|
|
156
|
+
|
|
157
|
+
Model versions: each version is its own node with its own table and records. Moving `latest_version` rebuilds the models that `ref()` it.
|
|
158
|
+
|
|
159
|
+
Always built as plain dbt: clones and deferral, Python models, microbatch, materialized views, streaming tables, metric views, custom materializations, custom incremental strategies and unit tests.
|
|
160
|
+
|
|
161
|
+
Known limit: a change to dbt's or the adapter's own macros, for example a dbt-databricks upgrade, does not show in any hash. Run once with `HODOR_MODE=off` after such an upgrade. Project and package macros that a materialization or a hook runs are in the config hash.
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
Requires [uv](https://docs.astral.sh/uv/). Local development and tests run on DuckDB, with no Databricks access.
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
uv sync
|
|
169
|
+
uv run pytest
|
|
170
|
+
uv run ruff check
|
|
171
|
+
uv run ruff format
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The live Databricks test is opt-in: see [docs/development.md](docs/development.md#tests).
|
|
175
|
+
|
|
176
|
+
Build a wheel with `uv build`. The package is not published to any index yet.
|
|
177
|
+
|
|
178
|
+
## Contributing
|
|
179
|
+
|
|
180
|
+
Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) has the setup, the
|
|
181
|
+
checks to run, and what a decision change needs. A wrong reuse, where hodor skipped a node
|
|
182
|
+
it should have rebuilt, is a security-grade bug: report it privately through the Security tab.
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
Apache-2.0. [NOTICE](NOTICE) carries the attribution for the derived files and the trademark
|
|
187
|
+
notice; [LICENSE](LICENSE) is the full licence text.
|