mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-15 13:10:44 +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:
|
else:
|
||||||
table_name = row[0]
|
table_name = row[0]
|
||||||
if schema:
|
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":
|
if not table_type or table_type == "FOREIGN":
|
||||||
# skip the table if it's foreign table / error in fetching table_type
|
# skip the table if it's foreign table / error in fetching table_type
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@ -310,20 +311,23 @@ def get_table_names(
|
|||||||
return [table for table in tables if table not in views]
|
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)"""
|
"""get table type (regular/foreign)"""
|
||||||
try:
|
try:
|
||||||
|
if database:
|
||||||
query = DATABRICKS_GET_TABLE_COMMENTS.format(
|
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)
|
rows = connection.execute(query)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_dict = dict(row)
|
row_dict = dict(row)
|
||||||
if row_dict.get("col_name") == "Type":
|
if row_dict.get("col_name") == "Type":
|
||||||
# get type of table
|
# get type of table
|
||||||
return row_dict.get("data_type")
|
return row_dict.get("data_type")
|
||||||
except Exception:
|
except DatabaseError as err:
|
||||||
pass
|
logger.error(f"Failed to fetch table type for table {table} due to: {err}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user