Skip to content

Commit

Permalink
switch to data_type over column type
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Lloyd committed Apr 24, 2023
1 parent 87e8891 commit 6e5b1a6
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions tap_mysql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"table_schema",
"table_name",
"column_name",
"column_type",
"data_type",
"is_nullable",
"column_key",
],
Expand Down Expand Up @@ -122,7 +122,7 @@ def create_catalog_entry(

# Initialize columns list
jsonschema_type: dict = self.to_jsonschema_type(
cast(sqlalchemy.types.TypeEngine, col.column_type),
cast(sqlalchemy.types.TypeEngine, col.data_type),
)
table_schema.append(
th.Property(
Expand Down Expand Up @@ -163,7 +163,6 @@ def discover_catalog_entries(self) -> list[dict]:
Returns:
The discovered catalog entries as a list.
"""
self.logger.info(f"discover catalog start: {datetime.datetime.now()}")
entries: list[dict] = []

with self._engine.connect() as connection:
Expand All @@ -183,9 +182,7 @@ def discover_catalog_entries(self) -> list[dict]:
ORDER BY table_schema, table_name
"""
)
self.logger.info(f"start table query: {datetime.datetime.now()}")
table_results = connection.execute(table_query).fetchall()
self.logger.info(f" end table query: {datetime.datetime.now()}")
table_defs: dict = {}

for mysql_schema, table, table_type in table_results:
Expand All @@ -200,7 +197,7 @@ def discover_catalog_entries(self) -> list[dict]:
table_schema
, table_name
, column_name
, column_type
, data_type
, is_nullable
, column_key
FROM information_schema.columns
Expand All @@ -214,9 +211,7 @@ def discover_catalog_entries(self) -> list[dict]:
-- LIMIT 40
"""
)
self.logger.info(f"start col query: {datetime.datetime.now()}")
col_result = connection.execute(col_query)
self.logger.info(f" end col query: {datetime.datetime.now()}")

# Parse data into useable python objects
columns = []
Expand All @@ -239,24 +234,6 @@ def discover_catalog_entries(self) -> list[dict]:
)
entries.append(entry.to_dict())

# for row in result:
# db_schema = row[0]
# table = row[1]
# column_def = {
# "name": row[3],
# "type": row[4],
# "nullable": row[5] == "YES",
# "key_type": row[6],
# }
# table_def = {"table_type": row[2], "columns": [column_def]}
# if db_schema not in instance_schema:
# instance_schema[db_schema] = {table: table_def}
# elif table not in instance_schema[db_schema]:
# instance_schema[db_schema][table] = table_def
# else:
# instance_schema[db_schema][table]["columns"].append(column_def)

self.logger.info(f"discover catalog end : {datetime.datetime.now()}")
return entries


Expand Down

0 comments on commit 6e5b1a6

Please sign in to comment.