From adbf2547a9815e6672eebd7fc6b5c65546e653ca Mon Sep 17 00:00:00 2001 From: Eli Yarson Date: Tue, 20 Aug 2024 17:56:13 -0300 Subject: [PATCH 1/2] fix: add option to not replace chars --- snowflake_utils/models.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/snowflake_utils/models.py b/snowflake_utils/models.py index 67104bc..348d04d 100644 --- a/snowflake_utils/models.py +++ b/snowflake_utils/models.py @@ -56,11 +56,17 @@ class TableStructure(BaseModel): columns: dict = [str, Column] @property - def parsed_columns(self): - return ", ".join( - f'"{str.upper(k).strip().replace("-","_")}" {v.data_type}' - for k, v in self.columns.items() - ) + def parsed_columns(self, replace_chars: False) -> str: + if replace_chars: + return ", ".join( + f'"{str.upper(k).strip().replace("-","_")}" {v.data_type}' + for k, v in self.columns.items() + ) + else: + return ", ".join( + f'"{str.upper(k).strip()}" {v.data_type}' + for k, v in self.columns.items() + ) def parse_from_json(self): raise NotImplementedError("Not implemented yet") @@ -406,8 +412,10 @@ def current_tags(self) -> dict[str, dict[str, str]]: tags = defaultdict(dict) with connect() as connection: cursor = connection.cursor() - cursor.execute(f"""select lower(column_name) as column_name, lower(tag_name) as tag_name, tag_value - from table(information_schema.tag_references_all_columns('{self.fqn}', 'table'))""") + cursor.execute( + f"""select lower(column_name) as column_name, lower(tag_name) as tag_name, tag_value + from table(information_schema.tag_references_all_columns('{self.fqn}', 'table'))""" + ) for column_name, tag_name, tag_value in cursor.fetchall(): tags[column_name][tag_name] = tag_value return tags From a9a91576d7378786c560367d8f17d3b7a6dd622b Mon Sep 17 00:00:00 2001 From: Eli Yarson Date: Tue, 20 Aug 2024 18:03:54 -0300 Subject: [PATCH 2/2] fix default value --- snowflake_utils/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snowflake_utils/models.py b/snowflake_utils/models.py index 348d04d..d991d1e 100644 --- a/snowflake_utils/models.py +++ b/snowflake_utils/models.py @@ -56,7 +56,7 @@ class TableStructure(BaseModel): columns: dict = [str, Column] @property - def parsed_columns(self, replace_chars: False) -> str: + def parsed_columns(self, replace_chars: bool = False) -> str: if replace_chars: return ", ".join( f'"{str.upper(k).strip().replace("-","_")}" {v.data_type}'