Skip to content

Commit

Permalink
Add support for connections to remote models
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarAdserballe committed Aug 2, 2024
1 parent f7001ad commit 921adf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "dbt_ml"
version: "0.6.0"
version: "0.6.1"

config-version: 2

Expand Down
20 changes: 16 additions & 4 deletions macros/materializations/model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,30 @@
{%- set ml_config = config.get('ml_config', {}) -%}
{%- set raw_labels = config.get('labels', {}) -%}
{%- set sql_header = config.get('sql_header', none) -%}
{%- set has_sql = true -%}

{%- if ml_config.get('MODEL_TYPE', ml_config.get('model_type', '')).lower() == 'tensorflow' -%}
{%- set has_sql = false -%}
{%- endif -%}

{{ sql_header if sql_header is not none }}

create or replace model {{ relation }}

{% if ml_config.get("connection_name") %}
remote with connection `{{ ml_config.pop("connection_name") }}`
{% set has_sql = false %}
{% endif %}

{{ dbt_ml.model_options(
ml_config=ml_config,
labels=raw_labels
) }}
{%- if ml_config.get('MODEL_TYPE', ml_config.get('model_type', '')).lower() != 'tensorflow' -%}
as (
{{ sql }}
);

{%- if has_sql -%}
as (
{{ sql }}
);
{%- endif -%}
{% endmacro %}

Expand Down

0 comments on commit 921adf5

Please sign in to comment.