Alex Martin
08/28/2023, 9:43 PM<http://df.to|df.to>_sql()
statement for the initial table creation.
• For the sake of resiliency, I've included both create (schema and table) if not exists executions in the asset that writes that initial raw data
My question is, what is your preferred implementation for those raw layer create table statements when working with dbt and dagster?
• Are you hard-coding them in the software defined assets?
• Do you have a 'raw' subdirectory nested in your dbt models for those statements?
• Do you have a sql specific directory in your dagster project that you reference in your Dagster assets?
• Something else?
Thanks ya'll.rex
08/28/2023, 9:51 PM• Are you hard-coding them in the software defined assets?Putting the logic to create the table before populating in the body of the software-defined asset sounds fine to me. We do that in the tutorial, fwiw: https://docs.dagster.io/integrations/dbt/using-dbt-with-dagster/upstream-assets. Separating that logic out from the population of the table seems too granular.
Alex Martin
08/28/2023, 9:59 PMBrendan Jackson
08/29/2023, 12:53 PMresources.py
. In there is also an`SqlResource`, that holds things like sql credentials and is used by the io-manager. On run startup, that resource runs all the CREATE TABLE IF NOT EXISTS
statements (just looping over all the enumeration values) -- implemented by overriding setup_for_execution
on the resource.Alex Martin
08/29/2023, 9:02 PM