Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add batching to sources and fix batch size for tests #348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions macros/upload_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
{% for node in graph.nodes.values() | selectattr("resource_type", "equalto", "test") %}
{% do tests_set.append(node) %}
{% endfor %}
{# upload tests in chunks of 5000 tests (750 for BigQuery), or less #}
{% set upload_limit = 750 if target.type == 'bigquery' else 5000 %}
{# upload tests in chunks of 5000 tests (300 for BigQuery), or less #}
{% set upload_limit = 300 if target.type == 'bigquery' else 5000 %}
{% for i in range(0, tests_set | length, upload_limit) -%}
{% set content_tests = dbt_artifacts.upload_tests(tests_set[i: i + upload_limit]) %}
{{ dbt_artifacts.insert_into_metadata_table(
Expand Down Expand Up @@ -126,14 +126,22 @@

{% do log("Uploading sources", true) %}
{% set sources = dbt_artifacts.get_relation('sources') %}
{% set content_sources = dbt_artifacts.upload_sources(graph) %}
{{ dbt_artifacts.insert_into_metadata_table(
database_name=sources.database,
schema_name=sources.schema,
table_name=sources.identifier,
content=content_sources
)
}}
{% set sources_set = [] %}
{% for node in graph.sources.values() %}
{% do sources_set.append(node) %}
{% endfor %}
{# upload sources in chunks of 5000 sources (300 for BigQuery), or less #}
{% set upload_limit = 300 if target.type == 'bigquery' else 5000 %}
{% for i in range(0, sources_set | length, upload_limit) -%}
{% set content_sources = dbt_artifacts.upload_sources(sources_set[i: i + upload_limit]) %}
{{ dbt_artifacts.insert_into_metadata_table(
database_name=sources.database,
schema_name=sources.schema,
table_name=sources.identifier,
content=content_sources
)
}}
{%- endfor %}

{% do log("Uploading snapshots", true) %}
{% set snapshots = dbt_artifacts.get_relation('snapshots') %}
Expand Down
6 changes: 1 addition & 5 deletions macros/upload_sources.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{% macro upload_sources(graph) -%}
{% set sources = [] %}
{% for node in graph.sources.values() %}
{% do sources.append(node) %}
{% endfor %}
{% macro upload_sources(sources) -%}
{{ return(adapter.dispatch('get_sources_dml_sql', 'dbt_artifacts')(sources)) }}
{%- endmacro %}

Expand Down