Specifying Nullability in models?

I’ve searched through the dbt documentation and the posts here but I’ve had trouble finding an answer.

I’m working in BigQuery and I’ve noticed that when materializing a model as a table, all columns are nullable. Is it possible to specify the nullability of a column or is everything created as nullable and you’re supposed to rely on dbt tests to do the enforcing? I’ll still be using the testing aspects of dbt regardless but not being able to look at a tables true schema in say GCPs Data Catalog is bound to create confusion for users of the data.

Thanks!

Since a table materialization is always going to be a SELECT INTO and therefore there’s no way to specify a schema for the destination table, the strategy I’m going to use to maintaining the schema of the destination table is to have the table created through terraform and materialize my models as incremental so as to avoid the drop and recreation of the table each time.

1 Like