Skip to content

Commit

Permalink
Merge pull request #15 from randypitcherii/2021-03-25--better_codegen
Browse files Browse the repository at this point in the history
made codegen database-level
  • Loading branch information
randypitcherii authored Mar 25, 2021
2 parents 7c4db7a + 39dcca0 commit 5c4d5d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 20 additions & 0 deletions dbt/macros/codegen/generate_source_yml_for_database.sql
Original file line number Diff line number Diff line change
@@ -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 %}
12 changes: 0 additions & 12 deletions dbt/macros/codegen/tpch_sf001_codegen.sql

This file was deleted.

0 comments on commit 5c4d5d3

Please sign in to comment.