From 2f6963849563c6b5bec357c852027f27aa0de833 Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Sun, 23 Jul 2023 03:02:11 +0900 Subject: [PATCH 1/2] keep root level column name which contains nested fields --- src/dbt_osmosis/core/osmosis.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dbt_osmosis/core/osmosis.py b/src/dbt_osmosis/core/osmosis.py index c76f70e..0688948 100644 --- a/src/dbt_osmosis/core/osmosis.py +++ b/src/dbt_osmosis/core/osmosis.py @@ -350,11 +350,10 @@ def get_columns(self, parts: Tuple[str, str, str]) -> List[str]: ) return columns try: - columns = [ - self.column_casing(exp.name) - for c in self.adapter.get_columns_in_relation(table) - for exp in getattr(c, "flatten", lambda: [c])() - ] + for c in self.adapter.get_columns_in_relation(table): + if hasattr(c, "flatten"): + columns.append(self.column_casing(c.name)) + columns.extend([self.column_casing(exp.name) for exp in getattr(c, "flatten", lambda: [c])()]) except Exception as error: logger().info( ( From a011d79ad4c14dc3c6a764d01d8e02796aaea511 Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Thu, 3 Aug 2023 09:21:17 +0900 Subject: [PATCH 2/2] refactor without lambda --- src/dbt_osmosis/core/osmosis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dbt_osmosis/core/osmosis.py b/src/dbt_osmosis/core/osmosis.py index 0688948..75b0496 100644 --- a/src/dbt_osmosis/core/osmosis.py +++ b/src/dbt_osmosis/core/osmosis.py @@ -351,9 +351,9 @@ def get_columns(self, parts: Tuple[str, str, str]) -> List[str]: return columns try: for c in self.adapter.get_columns_in_relation(table): + columns.append(self.column_casing(c.name)) if hasattr(c, "flatten"): - columns.append(self.column_casing(c.name)) - columns.extend([self.column_casing(exp.name) for exp in getattr(c, "flatten", lambda: [c])()]) + columns.extend([self.column_casing(exp.name) for exp in c.flatten()]) except Exception as error: logger().info( (