dbt-labs / dbt-external-tables

dbt macros to stage external sources
https://hub.getdbt.com/dbt-labs/dbt_external_tables/latest/
Apache License 2.0
288 stars 116 forks source link

BigQuery check if schema already exists before trying to create it #220

Closed thomas-vl closed 10 months ago

thomas-vl commented 1 year ago

Description & motivation

Before trying to create a new dataset we should check if it already exists without using the CREATE statement. It could be that the DBT SA or DBT user that runs the command does not has the permission to create a dataset.

Checklist

JCZuurmond commented 1 year ago

@thomas-vl : Do we have a test that covers this scenario: a schema exists and dbt does not try to create it again

JCZuurmond commented 1 year ago

@dataders : could you merge this PR?

I discussed testing this with @thomas-vl, however, we would need a user in the CI that has permissions to create tables and not schemas. This is the situation Thomas is facing, though less likely in a testing setup. The change can not be covered with a additional (unit) test.

Fleid commented 12 months ago

@dataders brought this up at our latest triage review, and it looks good to go! :)

jackwelty commented 11 months ago

I would add that not all users necessarily have access to INFORMATION_SCHEMA.SCHEMATA, especially if they don't have permission to create schemas. Is there a way to handle this without that access?

thomas-vl commented 11 months ago

I would add that not all users necessarily have access to INFORMATION_SCHEMA.SCHEMATA, especially if they don't have permission to create schemas. Is there a way to handle this without that access?

I think that everyone one in security will have no problem giving out read access to INFORMATION_SCHEMA in favour of not giving out create access for datasets.