diff --git a/dbt/macros/codegen/generate_source_yml_for_database.sql b/dbt/macros/codegen/generate_source_yml_for_database.sql new file mode 100644 index 0000000..6e46abd --- /dev/null +++ b/dbt/macros/codegen/generate_source_yml_for_database.sql @@ -0,0 +1,20 @@ +{# +Run the following dbt command: + + dbt run-operation generate_source_yml_for_database --args '{db: my_db, generate_cols: True}' + +Then, copy the output into your source.yml file! +#} + +{% macro generate_source_yml_for_database(db='RAW', generate_cols=True) %} + + {# Get schemas (technically, schemata is the plural of schema - but I am a rebel) #} + {% set schemas = run_query("select schema_name from " ~ db ~ ".information_schema.schemata where schema_name != 'INFORMATION_SCHEMA'").columns[0].values() %} + + {# Generate source yaml for each database. There are duplicate version entries for now but I would like to fix this in the future. For now, just buck up and clean the text by hand #} + {% for schema in schemas %} + {{ codegen.generate_source(schema_name=schema, database_name=db, generate_columns=generate_cols) }} + {% do log('\n---\n\n', true) %} + {% endfor %} + +{% endmacro %} \ No newline at end of file diff --git a/dbt/macros/codegen/tpch_sf001_codegen.sql b/dbt/macros/codegen/tpch_sf001_codegen.sql deleted file mode 100644 index 9cff4e6..0000000 --- a/dbt/macros/codegen/tpch_sf001_codegen.sql +++ /dev/null @@ -1,12 +0,0 @@ -{% macro tpch_sf001_codegen() %} - - {# - Run the following dbt command: - dbt run-operation tpch_sf001_codegen - - Then, copy the output into your source.yml file! - #} - - {{ codegen.generate_source(schema_name='TPCH_SF001', database_name='RAW', generate_columns=True) }} - -{% endmacro %} \ No newline at end of file