Skip to content

Commit

Permalink
fix: include record column itself when unnesting structs
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma committed Jan 31, 2025
1 parent bfc629c commit d4e2dcc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changes/1.1.13.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 1.1.13 - 2025-01-31
### Added
* Allow anchoring yml paths to the models base directory with leading `/`
### Fixed
* Include the record column itself when flattening struct types
3 changes: 0 additions & 3 deletions .changes/unreleased/Added-20250130-234300.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](/~https://github.com/miniscruff/changie).


## 1.1.13 - 2025-01-31
### Added
* Allow anchoring yml paths to the models base directory with leading `/`
### Fixed
* Include the record column itself when flattening struct types

## 1.1.12 - 2025-01-30
### Fixed
* Ensure we don't recurse in flattening struct columns as the adapter is already recursive under the hood
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "dbt-osmosis"
version = "1.1.12"
version = "1.1.13"
description = "A dbt utility for managing YAML to make developing with dbt more delightful."
readme = "README.md"
license = { text = "Apache-2.0" }
Expand Down
10 changes: 4 additions & 6 deletions src/dbt_osmosis/core/osmosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,14 +853,12 @@ def get_columns(context: YamlRefactorContext, ref: TableRef) -> dict[str, Column
normalized_cols = OrderedDict()
offset = 0

def process_column(col: BaseColumn | ColumnMetadata) -> None:
def process_column(c: BaseColumn | ColumnMetadata, /) -> None:
nonlocal offset

if hasattr(col, "flatten"):
# flatten bq structs
cols = getattr(col, "flatten")()
else:
cols = [col]
cols = [c]
if hasattr(c, "flatten"):
cols.extend(getattr(c, "flatten")())

for col in cols:
if any(re.match(b, col.name) for b in context.ignore_patterns):
Expand Down

0 comments on commit d4e2dcc

Please sign in to comment.