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 553dec4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +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
def _sa_type_to_str( # noqa: PLR6301
self,
data_type: sa.types.TypeEngine,
) -> str:
Expand Down Expand Up @@ -908,6 +908,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 +921,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 +949,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 553dec4

Please sign in to comment.