mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-15 04:59:50 +00:00
MINOR: databricks describe table query update (#17396)
* databricks describe table query update * remove extra args --------- Co-authored-by: Ayush Shah <ayush@getcollate.io>
This commit is contained in:
parent
6a31c579f6
commit
c84b77859e
@ -295,7 +295,8 @@ def get_table_names(
|
||||
else:
|
||||
table_name = row[0]
|
||||
if schema:
|
||||
table_type = get_table_type(connection, schema, table_name)
|
||||
database = kw.get("db_name")
|
||||
table_type = get_table_type(connection, database, schema, table_name)
|
||||
if not table_type or table_type == "FOREIGN":
|
||||
# skip the table if it's foreign table / error in fetching table_type
|
||||
logger.debug(
|
||||
@ -310,20 +311,23 @@ def get_table_names(
|
||||
return [table for table in tables if table not in views]
|
||||
|
||||
|
||||
def get_table_type(connection, schema, table):
|
||||
def get_table_type(connection, database, schema, table):
|
||||
"""get table type (regular/foreign)"""
|
||||
try:
|
||||
if database:
|
||||
query = DATABRICKS_GET_TABLE_COMMENTS.format(
|
||||
schema_name=schema, table_name=table
|
||||
database_name=database, schema_name=schema, table_name=table
|
||||
)
|
||||
else:
|
||||
query = f"DESCRIBE TABLE EXTENDED {schema}.{table}"
|
||||
rows = connection.execute(query)
|
||||
for row in rows:
|
||||
row_dict = dict(row)
|
||||
if row_dict.get("col_name") == "Type":
|
||||
# get type of table
|
||||
return row_dict.get("data_type")
|
||||
except Exception:
|
||||
pass
|
||||
except DatabaseError as err:
|
||||
logger.error(f"Failed to fetch table type for table {table} due to: {err}")
|
||||
return
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user