-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leverage "show table extended" for Relation type metadata #50
Conversation
Tested ithis on EMR/Glue data catalog. |
|
||
relations = [] | ||
quote_policy = { | ||
'schema': True, | ||
'identifier': True | ||
} | ||
for _database, name, _ in results: | ||
for _database, name, _, information in results: | ||
rel_type = ('view' if 'Type: VIEW' in information else 'table') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've had issues in the past with other adapters where we assumed that a relation was either of type "table" or "view". In practice, some databases support other relation types, like materialized views or external tables. In this case, I think this logic looks A-OK, but I did want to flag it as something to keep in mind for the future!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM! Nice work on this one :)
show table extended in ... like '*'
statement to get metadata on all relational objects in each database/schema, including theirType
information
column result of the statement for the substring'Type: VIEW'
. If found in the text result, setrelation.type
to'view'
, otherwise set to'table'
. (I am seeingType: MANAGED
for tables that dbt creates in Databricks.)Database ... not found
exception if dbt runs the statement for a database that doesn't (yet) exist. I encountered this error after creating a dbt model with a custom schema and executing a dbt commands which did not run that model (e.g.dbt seed
).