Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
seed support
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesmet committed Aug 8, 2021
1 parent 650fb27 commit 1618953
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion dbt/include/presto/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,35 @@
{% endmacro %}


{% macro presto__create_csv_table(model, agate_table) %}
{%- set column_override = model['config'].get('column_types', {}) -%}
{%- set quote_seed_column = model['config'].get('quote_columns', None) -%}
{%- set _with_props = config.get('with_props') -%}

{% set sql %}
create table {{ this.render() }} (
{%- for col_name in agate_table.column_names -%}
{%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}
{%- set type = column_override.get(col_name, inferred_type) -%}
{%- set column_name = (col_name | string) -%}
{{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}
{%- endfor -%}
) {{ with_props(_with_props) }}
{% endset %}

{% call statement('_') -%}
{{ sql }}
{%- endcall %}

{{ return(sql) }}
{% endmacro %}

{% macro with_props(with_props) %}
{%- if with_props is not none -%}
WITH (
{%- for key, value in with_props.items() -%}
{{ key }} = {{ value }}
{%- if not loop.last -%}{{ '\n ' }}{%- endif -%}
{%- if not loop.last -%}{{ ',\n ' }}{%- endif -%}
{%- endfor -%}
)
{%- endif -%}
Expand Down

0 comments on commit 1618953

Please sign in to comment.