Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d6a8eb0
Add test for append handler
cat-wates Apr 21, 2026
def1403
Add utils for finding new nested fields
shugewang Apr 21, 2026
3e6331e
Add to dos
shugewang Apr 22, 2026
a9ac57a
Append missing fields to target table fields
cat-wates Apr 22, 2026
a1d8a83
[WIP] reconstruction logic
cat-wates Apr 22, 2026
be542cc
Refactor utils to use FieldLineage class, change append_new_fields to…
shugewang Apr 22, 2026
0e1bfd8
WIP - add failing test for build_predicted_table() and minor refactoring
shugewang Apr 22, 2026
89a489e
WIP - add missing fields and build predicted table
shugewang Apr 22, 2026
58c9c24
Add unit tests for add_missing_fields
shugewang Apr 22, 2026
1dd4875
Delete sample test
cat-wates Apr 22, 2026
e4b36f8
Change append_new_columns_handler to use util functions
cat-wates Apr 22, 2026
7c3c1ae
Add test for preserving nest column order
cat-wates Apr 22, 2026
169b9bb
Rename
shugewang Apr 22, 2026
6175011
build_predicted_table -> build_predicted_fields
shugewang Apr 22, 2026
19d289f
Refactor build_predicted_fields to work for sync_all_columns handler
shugewang Apr 27, 2026
1f78320
Add more tests for schema change handlers
shugewang Apr 27, 2026
5a03b09
Formating
shugewang Apr 27, 2026
5380476
Limit number of nested record types to 15 to match BQ limit
shugewang Apr 27, 2026
debc9db
Set max level of recursion for collect_field_lineages
shugewang Apr 27, 2026
0a41cb7
Test repeated structs (arrays) are supported
shugewang Apr 27, 2026
81dd0ce
Comment
shugewang Apr 27, 2026
22cec77
Refactor FieldPath class to use tuple instead of str for path
shugewang Apr 28, 2026
2940522
Rename functions and util file
shugewang Apr 28, 2026
5ea0134
Add integration test
shugewang Apr 28, 2026
748a7e8
Rename test file
shugewang Apr 28, 2026
5e6595c
WIP - make test sql non-recursive (test now failing as result)
shugewang Apr 30, 2026
387476c
WIP - remove obviated test and change common_field_names() to return …
shugewang May 5, 2026
a21e8df
WIP - add error handling for removing nested field, failing integrati…
shugewang May 5, 2026
5b41014
dry runner will object to removing fields from within records/structs
evie-autotrader May 6, 2026
5371bb7
add limitation to README
evie-autotrader May 6, 2026
af4a53a
formatting, linting, type checking
evie-autotrader May 6, 2026
a52c282
separate methods to check adding vs removing fields from nested structs
evie-autotrader May 6, 2026
5a1a198
Remove comments
shugewang May 6, 2026
0c4ab6b
Refactor - test names
shugewang May 6, 2026
047fb3a
Linting
shugewang May 6, 2026
9e434ed
add Evie to authors
evie-autotrader May 6, 2026
e11ae1f
fix indentation
evie-autotrader May 6, 2026
26e3a34
update limitations
evie-autotrader May 6, 2026
be16e4d
rename get_updated_schema
evie-autotrader May 6, 2026
eed1476
rename ensure_no_removed_nested_fields
evie-autotrader May 6, 2026
faee492
add is_top_level property to table FieldPath
evie-autotrader May 6, 2026
89cf194
make references to missing fields more specific
evie-autotrader May 6, 2026
cdbe714
rename collect field paths method to add context
evie-autotrader May 6, 2026
ec4c817
refactor to add context around missing fields and make error messages…
evie-autotrader May 6, 2026
86037eb
Refactor sync_all_columns_handler logic for removing top level fields
shugewang May 7, 2026
8305489
partial refactor for abstraction
evie-autotrader May 7, 2026
b080919
New test, linting
shugewang May 7, 2026
d086a0d
rename nested_schema_change to remove unneeded qualifier
evie-autotrader May 7, 2026
3333368
Fix imports
shugewang May 7, 2026
247c35c
refactor - make nested field removal check more abstract
evie-autotrader May 7, 2026
da5987c
refactored to clarify responsibilities and privacy of schema_change m…
evie-autotrader May 7, 2026
e7b0b3b
Rename functions
shugewang May 8, 2026
bb90992
WIP - renaming in merge_table_fields
shugewang May 8, 2026
118aa5a
test cases for merge_table_fields
evie-autotrader May 8, 2026
b4a15a4
schema change handlers raise error when nested field removed
evie-autotrader May 8, 2026
23a7015
Make methods in schema_manipulation role-agnostic
shugewang May 8, 2026
25728e3
WIP - add fail handler integration tests (nested failing)
shugewang May 8, 2026
3acc558
Update fail_handler to detect nested changes
shugewang May 8, 2026
0d47ad5
Refactor assert_no_nested_fields_removed to use is_top_level property
shugewang May 8, 2026
23c1bc0
Add path to TableField, removing the need for FieldPath. Move _collec…
shugewang May 11, 2026
40c50bf
Move assert to schema_change_handlers.py
evie-autotrader May 11, 2026
671f548
remove path property from TableField, recreate FieldPath type class
evie-autotrader May 11, 2026
b57986a
bump version and add details to changelog
evie-autotrader May 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dbt_dry_run/models/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def validate_type_field(cls, field: str) -> BigQueryFieldType:
TableField.model_rebuild()


class FieldLineage(BaseModel):
Comment thread
shugewang marked this conversation as resolved.
Outdated
lineage: str
field: TableField


class Table(BaseModel):
fields: List[TableField]

Expand Down
23 changes: 13 additions & 10 deletions dbt_dry_run/schema_change_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dbt_dry_run.models import OnSchemaChange, Table
from dbt_dry_run.models.dry_run_result import DryRunResult
from dbt_dry_run.models.report import DryRunStatus
from dbt_dry_run.utils import find_missing_fields, build_predicted_fields


def ignore_handler(dry_run_result: DryRunResult, target_table: Table) -> DryRunResult:
Expand All @@ -15,15 +16,11 @@ def append_new_columns_handler(
) -> DryRunResult:
if dry_run_result.table is None:
return dry_run_result

target_column_names = set(field.name for field in target_table.fields)
new_columns = [
new_field
for new_field in dry_run_result.table.fields
if new_field.name not in target_column_names
]
final_fields = target_table.fields + new_columns
return dry_run_result.replace_table(Table(fields=final_fields))
missing_fields = find_missing_fields(
dry_run_result.table.fields, target_table.fields
)
predicted_fields = build_predicted_fields(target_table, missing_fields)
return dry_run_result.replace_table(Table(fields=predicted_fields))


def sync_all_columns_handler(
Expand All @@ -43,7 +40,13 @@ def sync_all_columns_handler(
for existing_field in target_table.fields
if existing_field.name in predicted_column_names
]
final_fields = existing_columns + new_columns
final_field_names = set(field.name for field in existing_columns + new_columns)
missing_fields = find_missing_fields(dry_run_result.table.fields, existing_columns)
final_fields = build_predicted_fields(
target_table=target_table,
missing_fields=missing_fields,
included_top_level_field_names=final_field_names,
)
return dry_run_result.replace_table(Table(fields=final_fields))


Expand Down
Loading
Loading