Skip to content

Commit d4e2dcc

Browse files
committed
fix: include record column itself when unnesting structs
1 parent bfc629c commit d4e2dcc

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

.changes/1.1.13.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 1.1.13 - 2025-01-31
2+
### Added
3+
* Allow anchoring yml paths to the models base directory with leading `/`
4+
### Fixed
5+
* Include the record column itself when flattening struct types

.changes/unreleased/Added-20250130-234300.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
66
and is generated by [Changie](https://github.com/miniscruff/changie).
77

88

9+
## 1.1.13 - 2025-01-31
10+
### Added
11+
* Allow anchoring yml paths to the models base directory with leading `/`
12+
### Fixed
13+
* Include the record column itself when flattening struct types
14+
915
## 1.1.12 - 2025-01-30
1016
### Fixed
1117
* Ensure we don't recurse in flattening struct columns as the adapter is already recursive under the hood

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "dbt-osmosis"
7-
version = "1.1.12"
7+
version = "1.1.13"
88
description = "A dbt utility for managing YAML to make developing with dbt more delightful."
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }

src/dbt_osmosis/core/osmosis.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -853,14 +853,12 @@ def get_columns(context: YamlRefactorContext, ref: TableRef) -> dict[str, Column
853853
normalized_cols = OrderedDict()
854854
offset = 0
855855

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

859-
if hasattr(col, "flatten"):
860-
# flatten bq structs
861-
cols = getattr(col, "flatten")()
862-
else:
863-
cols = [col]
859+
cols = [c]
860+
if hasattr(c, "flatten"):
861+
cols.extend(getattr(c, "flatten")())
864862

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

0 commit comments

Comments
 (0)