Commit 53ade57
committed
perf: reuse columns from process_schema_changes in incremental materialization
Incremental materialization previously discarded the return value of
`process_schema_changes`, causing each strategy macro (`merge`, `append`,
`delete+insert`) to issue a second `DESCRIBE TABLE EXTENDED` on the target
relation even though `check_for_schema_changes` had just DESCRIBEd it.
This change:
- captures the columns returned by `process_schema_changes` in both V1
and V2 paths
- falls back to a single `adapter.get_columns_in_relation(existing_relation)`
when `on_schema_change == 'ignore'`
- threads the result through `strategy_arg_dict['dest_columns']`
- teaches `databricks__get_merge_sql`, `get_delete_insert_sql`, and
`get_insert_into_sql` to honor a pre-supplied `dest_columns` and skip
their own `DESCRIBE` when provided
Net effect: one fewer `DESCRIBE TABLE EXTENDED … AS JSON` round-trip per
incremental model, per run.
Verified on a project with 9 incremental stg models (V1 path,
`on_schema_change: 'fail'`): target DESCRIBE count drops from 2 to 1 per
model across merge, append, and delete+insert strategies.
Resolves #1411
Co-authored-by: Isaac1 parent 86d26c9 commit 53ade57
3 files changed
Lines changed: 48 additions & 12 deletions
File tree
- dbt/include/databricks/macros/materializations/incremental
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
62 | 69 | | |
63 | | - | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
142 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
143 | 157 | | |
144 | 158 | | |
145 | 159 | | |
146 | 160 | | |
147 | 161 | | |
148 | | - | |
| 162 | + | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| |||
225 | 239 | | |
226 | 240 | | |
227 | 241 | | |
228 | | - | |
| 242 | + | |
229 | 243 | | |
230 | 244 | | |
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
234 | 248 | | |
235 | 249 | | |
236 | | - | |
| 250 | + | |
237 | 251 | | |
238 | 252 | | |
239 | 253 | | |
| |||
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
218 | 224 | | |
219 | 225 | | |
220 | 226 | | |
221 | | - | |
| 227 | + | |
222 | 228 | | |
223 | | - | |
224 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
225 | 236 | | |
226 | 237 | | |
227 | 238 | | |
| |||
272 | 283 | | |
273 | 284 | | |
274 | 285 | | |
275 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
276 | 292 | | |
277 | 293 | | |
278 | 294 | | |
| |||
0 commit comments