Skip to content

Commit

Permalink
Fewer loops
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 28, 2024
1 parent ff760b0 commit fc5ecc6
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,7 @@ def get_object_names(
view_names = []
return [(t, False) for t in table_names] + [(v, True) for v in view_names]

def discover_catalog_entry_sql_datatype( # noqa: PLR6301
self,
data_type: sa.types.TypeEngine,
) -> str:
def _sa_type_to_str(self, data_type: sa.types.TypeEngine) -> str: # noqa: PLR6301
"""Retrun SQL Datatype as a string to utilize in the catalog.
Args:
Expand Down Expand Up @@ -908,6 +905,7 @@ def discover_catalog_entry(

# Initialize columns list
table_schema = th.PropertiesList()
datatypes = {}
for column_def in inspected.get_columns(table_name, schema=schema_name):
column_name = column_def["name"]
is_nullable = column_def.get("nullable", False)
Expand All @@ -920,13 +918,9 @@ def discover_catalog_entry(
required=column_name in key_properties if key_properties else False,
),
)
schema = table_schema.to_dict()
datatypes[column_def["name"]] = self._sa_type_to_str(column_def["type"])

sql_datatypes = {}
for column_def in inspected.get_columns(table_name, schema=schema_name):
sql_datatypes[str(column_def["name"])] = (
self.discover_catalog_entry_sql_datatype(column_def["type"])
)
schema = table_schema.to_dict()

# Initialize available replication methods
addl_replication_methods: list[str] = [""] # By default an empty list.
Expand All @@ -952,7 +946,7 @@ def discover_catalog_entry(
replication_method=replication_method,
key_properties=key_properties,
valid_replication_keys=None, # Must be defined by user
sql_datatypes=sql_datatypes,
sql_datatypes=datatypes,
),
database=None, # Expects single-database context
row_count=None,
Expand Down

0 comments on commit fc5ecc6

Please sign in to comment.