Skip to content

Commit 5c4d5d3

Browse files
Merge pull request #15 from randypitcherii/2021-03-25--better_codegen
made codegen database-level
2 parents 7c4db7a + 39dcca0 commit 5c4d5d3

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{#
2+
Run the following dbt command:
3+
4+
dbt run-operation generate_source_yml_for_database --args '{db: my_db, generate_cols: True}'
5+
6+
Then, copy the output into your source.yml file!
7+
#}
8+
9+
{% macro generate_source_yml_for_database(db='RAW', generate_cols=True) %}
10+
11+
{# Get schemas (technically, schemata is the plural of schema - but I am a rebel) #}
12+
{% set schemas = run_query("select schema_name from " ~ db ~ ".information_schema.schemata where schema_name != 'INFORMATION_SCHEMA'").columns[0].values() %}
13+
14+
{# 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 #}
15+
{% for schema in schemas %}
16+
{{ codegen.generate_source(schema_name=schema, database_name=db, generate_columns=generate_cols) }}
17+
{% do log('\n---\n\n', true) %}
18+
{% endfor %}
19+
20+
{% endmacro %}

dbt/macros/codegen/tpch_sf001_codegen.sql

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)