Initial publish of dbt_f2dq (f2dq) package v0.12.1.
Clean package repo for Gitea installs via packages.yml git URL. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
{% macro insert_list_to_table(table, list, params, dtype=None,insert_size=100) %}
|
||||
|
||||
{% set single_insert_list = [] %}
|
||||
{% for el in list %}
|
||||
{% do single_insert_list.append(el) %}
|
||||
{% set single_insert_list_size = single_insert_list | length %}
|
||||
{% if single_insert_list_size == insert_size or loop.last %}
|
||||
|
||||
{% set insert_query %}
|
||||
insert into {{ table }} ({%- for p in params %}{{p}}{% if not loop.last %}, {% endif %}{% endfor %}) values
|
||||
{%- for row in single_insert_list -%}
|
||||
(
|
||||
{%- for p in params -%}
|
||||
{%- if row[p] is none -%}
|
||||
NULL
|
||||
{%- else -%}
|
||||
{%- if row[p] is string -%}
|
||||
{%- if dtype and p in dtype -%}
|
||||
{% set cast_type = dtype[p] %}
|
||||
cast ({{ f2dq.quote_string(row[p]) }} as {{ cast_type }})
|
||||
{%- else %}
|
||||
{{- f2dq.quote_string(row[p]) -}}
|
||||
{%- endif -%}
|
||||
{%- elif row[p] is number -%}
|
||||
{{-row[p]-}}
|
||||
{%- else -%}
|
||||
{{- f2dq.quote_string(tojson(row[p])) -}}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- if not loop.last -%},{%- endif -%}
|
||||
{%- endfor -%}
|
||||
)
|
||||
{%- if not loop.last -%},{%- endif %}
|
||||
{% endfor -%}
|
||||
{% endset %}
|
||||
|
||||
{% do run_query(insert_query) %}
|
||||
{% do single_insert_list.clear() %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user