From d4de743114497405ae75b02c3c99f821022a6f01 Mon Sep 17 00:00:00 2001 From: Josh Gilfillan Date: Mon, 7 Nov 2022 23:32:30 +1000 Subject: [PATCH] added sqlserver compatibility --- macros/column_identifier.sql | 4 + macros/insert_into_metadata_table.sql | 8 ++ macros/quote_reserved_keywords.sql | 24 +++++ macros/upload_exposures.sql | 56 +++++++++++ macros/upload_invocations.sql | 91 +++++++++++++++++ macros/upload_model_executions.sql | 99 +++++++++++++++++-- macros/upload_models.sql | 68 +++++++++++-- macros/upload_seed_executions.sql | 99 +++++++++++++++++-- macros/upload_seeds.sql | 59 +++++++++-- macros/upload_snapshot_executions.sql | 97 ++++++++++++++++-- macros/upload_snapshots.sql | 65 ++++++++++-- macros/upload_sources.sql | 53 ++++++++++ macros/upload_test_executions.sql | 78 +++++++++++++++ macros/upload_tests.sql | 44 +++++++++ models/dim_dbt__current_models.sql | 13 ++- models/dim_dbt__models.sql | 7 +- models/dim_dbt__models.yml | 2 - models/dim_dbt__seeds.sql | 7 +- models/dim_dbt__seeds.yml | 2 - models/dim_dbt__snapshots.sql | 7 +- models/dim_dbt__snapshots.yml | 2 - models/dim_dbt__sources.sql | 4 +- models/docs.md | 4 - models/fct_dbt__model_executions.sql | 5 +- models/fct_dbt__model_executions.yml | 2 - models/fct_dbt__seed_executions.sql | 5 +- models/fct_dbt__seed_executions.yml | 2 - models/fct_dbt__snapshot_executions.sql | 5 +- models/fct_dbt__snapshot_executions.yml | 2 - models/sources/model_executions.sql | 5 +- models/sources/models.sql | 7 +- models/sources/seed_executions.sql | 5 +- models/sources/seeds.sql | 7 +- models/sources/snapshot_executions.sql | 5 +- models/sources/snapshots.sql | 7 +- models/sources/sources.sql | 4 +- models/staging/stg_dbt__model_executions.sql | 5 +- models/staging/stg_dbt__model_executions.yml | 2 - models/staging/stg_dbt__models.sql | 9 +- models/staging/stg_dbt__models.yml | 2 - models/staging/stg_dbt__seed_executions.sql | 5 +- models/staging/stg_dbt__seed_executions.yml | 2 - models/staging/stg_dbt__seeds.sql | 9 +- models/staging/stg_dbt__seeds.yml | 2 - .../staging/stg_dbt__snapshot_executions.sql | 5 +- .../staging/stg_dbt__snapshot_executions.yml | 2 - models/staging/stg_dbt__snapshots.sql | 9 +- models/staging/stg_dbt__snapshots.yml | 2 - models/staging/stg_dbt__sources.sql | 6 +- 49 files changed, 862 insertions(+), 152 deletions(-) create mode 100644 macros/quote_reserved_keywords.sql diff --git a/macros/column_identifier.sql b/macros/column_identifier.sql index 9e1d0665..75ad34a4 100644 --- a/macros/column_identifier.sql +++ b/macros/column_identifier.sql @@ -13,3 +13,7 @@ {% macro spark__column_identifier(column_index) -%} col{{ column_index }} {%- endmacro %} + +{% macro sqlserver__column_identifier(column_index) -%} + col{{ column_index }} +{%- endmacro %} diff --git a/macros/insert_into_metadata_table.sql b/macros/insert_into_metadata_table.sql index bc464f6a..e20bd50b 100644 --- a/macros/insert_into_metadata_table.sql +++ b/macros/insert_into_metadata_table.sql @@ -34,5 +34,13 @@ {%- endmacro %} +{% macro sqlserver__insert_into_metadata_table(database_name, schema_name, table_name, content) -%} + {% set insert_into_table_query %} + insert into {{ schema_name }}.{{ table_name }} + {{ content }} + {% endset %} + {# do run_query(insert_into_table_query) #} +{%- endmacro %} + {% macro default__insert_into_metadata_table(database_name, schema_name, table_name, content) -%} {%- endmacro %} diff --git a/macros/quote_reserved_keywords.sql b/macros/quote_reserved_keywords.sql new file mode 100644 index 00000000..063b4ecd --- /dev/null +++ b/macros/quote_reserved_keywords.sql @@ -0,0 +1,24 @@ +{% macro quote_reserved_keywords(column_name) -%} + {{ return(adapter.dispatch('quote_reserved_keywords')(column_name)) }} +{%- endmacro %} + +{% macro default__quote_reserved_keywords(column_name) -%} + {{ column_name }} +{%- endmacro %} + +{% macro snowflake__quote_reserved_keywords(column_name) -%} + {{ column_name }} +{%- endmacro %} + +{% macro spark__quote_reserved_keywords(column_name) -%} + {{ column_name }} +{%- endmacro %} + +{% macro sqlserver__quote_reserved_keywords(column_name) -%} + {%- set reserved_keywords = ["database", "schema", "name"] -%} + {%- if column_name in reserved_keywords -%} + "{{ column_name }}" + {%- else -%} + {{ column_name }} + {%- endif -%} +{%- endmacro %} diff --git a/macros/upload_exposures.sql b/macros/upload_exposures.sql index 93f10517..e5bd6107 100644 --- a/macros/upload_exposures.sql +++ b/macros/upload_exposures.sql @@ -74,3 +74,59 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_exposures_dml_sql(exposures) -%} + + {% if exposures != [] %} + {% set exposure_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(6)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }} + from (values + {% for exposure in exposures -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ exposure.unique_id | replace("'","\\'") }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ exposure.name | replace("'","\\'") }}', {# name #} + '{{ exposure.type }}', {# type #} + '{{ tojson(exposure.owner) }}', {# owner #} + '{{ exposure.maturity }}', {# maturity #} + '{{ exposure.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ exposure.description | replace("'","\\'") }}', {# description #} + '{{ exposure.url }}', {# url #} + '{{ exposure.package_name }}', {# package_name #} + '{{ tojson(exposure.depends_on.nodes) }}' {# depends_on_nodes #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as exposure_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(6)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }} + ) + {% endset %} + {{ exposure_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_invocations.sql b/macros/upload_invocations.sql index 863aaba1..6e73223e 100644 --- a/macros/upload_invocations.sql +++ b/macros/upload_invocations.sql @@ -120,3 +120,94 @@ {{ invocation_values }} {% endmacro -%} + +{% macro sqlserver__get_invocations_dml_sql() -%} + {% set invocation_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + nullif({{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, ''), + nullif({{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, ''), + nullif({{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, ''), + nullif({{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }}, ''), + nullif({{ adapter.dispatch('column_identifier', 'dbt_artifacts')(15) }}, ''), + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(16)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(17)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(18)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(19)) }} + from (values + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ dbt_version }}', {# dbt_version #} + '{{ project_name }}', {# project_name #} + '{{ run_started_at }}', {# run_started_at #} + '{{ flags.WHICH }}', {# dbt_command #} + '{{ flags.FULL_REFRESH }}', {# full_refresh_flag #} + '{{ target.profile_name }}', {# target_profile_name #} + '{{ target.name }}', {# target_name #} + '{{ target.schema }}', {# target_schema #} + {{ target.threads }}, {# target_threads #} + + '{{ env_var('DBT_CLOUD_PROJECT_ID', '') }}', {# dbt_cloud_project_id #} + '{{ env_var('DBT_CLOUD_JOB_ID', '') }}', {# dbt_cloud_job_id #} + '{{ env_var('DBT_CLOUD_RUN_ID', '') }}', {# dbt_cloud_run_id #} + '{{ env_var('DBT_CLOUD_RUN_REASON_CATEGORY', '') }}', {# dbt_cloud_run_reason_category #} + '{{ env_var('DBT_CLOUD_RUN_REASON', '') | replace("'","\\'") }}', {# dbt_cloud_run_reason #} + + {% if var('env_vars', none) %} + {% set env_vars_dict = {} %} + {% for env_variable in var('env_vars') %} + {% do env_vars_dict.update({env_variable: env_var(env_variable)}) %} + {% endfor %} + '{{ tojson(env_vars_dict) }}', {# env_vars #} + {% else %} + null, {# env_vars #} + {% endif %} + + {% if var('dbt_vars', none) %} + {% set dbt_vars_dict = {} %} + {% for dbt_var in var('dbt_vars') %} + {% do dbt_vars_dict.update({dbt_var: var(dbt_var)}) %} + {% endfor %} + '{{ tojson(dbt_vars_dict) }}', {# dbt_vars #} + {% else %} + null, {# dbt_vars #} + {% endif %} + + '{{ tojson(invocation_args_dict) }}', {# invocation_args #} + '{{ tojson(dbt_metadata_envs) }}' {# dbt_custom_envs #} + + ) + ) as invocation_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(15) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(16)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(17)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(18)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(19)) }} + ) + {% endset %} + {{ invocation_values }} + +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_model_executions.sql b/macros/upload_model_executions.sql index b730a6ab..3e80428c 100644 --- a/macros/upload_model_executions.sql +++ b/macros/upload_model_executions.sql @@ -24,8 +24,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in models -%} ( @@ -67,8 +66,7 @@ null, -- rows_affected not available {# Only available in Snowflake & BigQuery #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -123,8 +121,7 @@ safe_cast('{{ model.adapter_response.bytes_processed }}' as int64), '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -151,8 +148,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in models -%} ( @@ -194,8 +190,7 @@ try_cast('{{ model.adapter_response.rows_affected }}' as int), {# rows_affected #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -205,3 +200,87 @@ {{ return("") }} {% endif %} {% endmacro -%} + +{% macro sqlserver__get_model_executions_dml_sql(models) -%} + {% if models != [] %} + {% set model_execution_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + from (values + {% for model in models -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ model.node.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + + {% set config_full_refresh = model.node.config.full_refresh %} + {% if config_full_refresh is none %} + {% set config_full_refresh = flags.FULL_REFRESH %} + {% endif %} + '{{ config_full_refresh }}', {# was_full_refresh #} + + '{{ model.thread_id }}', {# thread_id #} + '{{ model.status }}', {# status #} + + {% if model.timing != [] %} + {% for stage in model.timing if stage.name == "compile" %} + {% if loop.length == 0 %} + null, {# compile_started_at #} + {% else %} + '{{ stage.started_at }}', {# compile_started_at #} + {% endif %} + {% endfor %} + + {% for stage in model.timing if stage.name == "execute" %} + {% if loop.length == 0 %} + null, {# query_completed_at #} + {% else %} + '{{ stage.completed_at }}', {# query_completed_at #} + {% endif %} + {% endfor %} + {% else %} + null, {# compile_started_at #} + null, {# query_completed_at #} + {% endif %} + + {{ model.execution_time }}, {# total_node_runtime #} + null, -- rows_affected not available {# Only available in Snowflake & BigQuery #} + '{{ model.node.config.materialized }}', {# materialization #} + '{{ model.node.schema }}', {# schema #} + '{{ model.node.name }}' {# name #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as model_execution_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + ) + {% endset %} + {{ model_execution_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_models.sql b/macros/upload_models.sql index 8657739b..a38afa36 100644 --- a/macros/upload_models.sql +++ b/macros/upload_models.sql @@ -23,8 +23,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}, - {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(13)) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(13)) }} from values {% for model in models -%} ( @@ -40,8 +39,7 @@ '{{ model.checksum.checksum }}', {# checksum #} '{{ model.config.materialized }}', {# materialization #} '{{ tojson(model.tags) }}', {# tags #} - '{{ tojson(model.config.meta) }}', {# meta #} - '{{ model.alias }}' {# alias #} + '{{ tojson(model.config.meta) }}' {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -69,8 +67,7 @@ '{{ model.checksum.checksum }}', {# checksum #} '{{ model.config.materialized }}', {# materialization #} {{ tojson(model.tags) }}, {# tags #} - parse_json('{{ tojson(model.config.meta) }}'), {# meta #} - '{{ model.alias }}' {# alias #} + parse_json('{{ tojson(model.config.meta) }}') {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -80,3 +77,62 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_models_dml_sql(models) -%} + + {% if models != [] %} + {% set model_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(7)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(13)) }} + from (values + {% for model in models -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ model.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ model.database }}', {# database #} + '{{ model.schema }}', {# schema #} + '{{ model.name }}', {# name #} + '{{ tojson(model.depends_on.nodes) | replace('\\', '\\\\') }}', {# depends_on_nodes #} + '{{ model.package_name }}', {# package_name #} + '{{ model.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ model.checksum.checksum }}', {# checksum #} + '{{ model.config.materialized }}', {# materialization #} + '{{ tojson(model.tags) }}', {# tags #} + '{{ tojson(model.config.meta) }}' {# meta #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as model_values ( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(7)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(13)) }} + ) + {% endset %} + {{ model_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_seed_executions.sql b/macros/upload_seed_executions.sql index b6604499..f77f6c66 100644 --- a/macros/upload_seed_executions.sql +++ b/macros/upload_seed_executions.sql @@ -24,8 +24,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in seeds -%} ( @@ -67,8 +66,7 @@ null, -- rows_affected not available {# Only available in Snowflake #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -122,8 +120,7 @@ null, -- rows_affected not available {# Databricks #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -150,8 +147,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in seeds -%} ( @@ -193,8 +189,7 @@ try_cast('{{ model.adapter_response.rows_affected }}' as int), {# rows_affected #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -204,3 +199,87 @@ {{ return("") }} {% endif %} {% endmacro -%} + +{% macro sqlserver__get_seed_executions_dml_sql(seeds) -%} + {% if seeds != [] %} + {% set seed_execution_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + from (values + {% for model in seeds -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ model.node.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + + {% set config_full_refresh = model.node.config.full_refresh %} + {% if config_full_refresh is none %} + {% set config_full_refresh = flags.FULL_REFRESH %} + {% endif %} + '{{ config_full_refresh }}', {# was_full_refresh #} + + '{{ model.thread_id }}', {# thread_id #} + '{{ model.status }}', {# status #} + + {% if model.timing != [] %} + {% for stage in model.timing if stage.name == "compile" %} + {% if loop.length == 0 %} + null, {# compile_started_at #} + {% else %} + '{{ stage.started_at }}', {# compile_started_at #} + {% endif %} + {% endfor %} + + {% for stage in model.timing if stage.name == "execute" %} + {% if loop.length == 0 %} + null, {# query_completed_at #} + {% else %} + '{{ stage.completed_at }}', {# query_completed_at #} + {% endif %} + {% endfor %} + {% else %} + null, {# compile_started_at #} + null, {# query_completed_at #} + {% endif %} + + {{ model.execution_time }}, {# total_node_runtime #} + null, -- rows_affected not available {# Only available in Snowflake #} + '{{ model.node.config.materialized }}', {# materialization #} + '{{ model.node.schema }}', {# schema #} + '{{ model.node.name }}' {# name #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as seed_execution_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + ) + {% endset %} + {{ seed_execution_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_seeds.sql b/macros/upload_seeds.sql index dbdc7c80..77d4c8b4 100644 --- a/macros/upload_seeds.sql +++ b/macros/upload_seeds.sql @@ -20,8 +20,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, - {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(10)) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }} + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(10)) }} from values {% for seed in seeds -%} ( @@ -34,8 +33,7 @@ '{{ seed.package_name }}', {# package_name #} '{{ seed.original_file_path | replace('\\', '\\\\') }}', {# path #} '{{ seed.checksum.checksum }}', {# checksum #} - '{{ tojson(seed.config.meta) }}', {# meta #} - '{{ seed.alias }}' {# alias #} + '{{ tojson(seed.config.meta) }}' {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -60,8 +58,7 @@ '{{ seed.package_name }}', {# package_name #} '{{ seed.original_file_path | replace('\\', '\\\\') }}', {# path #} '{{ seed.checksum.checksum }}', {# checksum #} - parse_json('{{ tojson(seed.config.meta) }}'), {# meta #} - '{{ seed.alias }}' {# alias #} + parse_json('{{ tojson(seed.config.meta) }}') {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -71,3 +68,53 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_seeds_dml_sql(seeds) -%} + + {% if seeds != [] %} + {% set seed_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(10)) }} + from (values + {% for seed in seeds -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ seed.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ seed.database }}', {# database #} + '{{ seed.schema }}', {# schema #} + '{{ seed.name }}', {# name #} + '{{ seed.package_name }}', {# package_name #} + '{{ seed.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ seed.checksum.checksum }}', {# checksum #} + '{{ tojson(seed.config.meta) }}' {# meta #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as seed_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(10)) }} + ) + {% endset %} + {{ seed_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_snapshot_executions.sql b/macros/upload_snapshot_executions.sql index d91775c2..72600654 100644 --- a/macros/upload_snapshot_executions.sql +++ b/macros/upload_snapshot_executions.sql @@ -24,7 +24,6 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in snapshots -%} @@ -67,8 +66,7 @@ null, -- rows_affected not available {# Only available in Snowflake #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -122,8 +120,7 @@ null, -- rows_affected not available {# Databricks #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -150,8 +147,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(14) }} + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} from values {% for model in snapshots -%} ( @@ -193,8 +189,7 @@ try_cast('{{ model.adapter_response.rows_affected }}' as int), {# rows_affected #} '{{ model.node.config.materialized }}', {# materialization #} '{{ model.node.schema }}', {# schema #} - '{{ model.node.name }}', {# name #} - '{{ model.node.alias }}' {# alias #} + '{{ model.node.name }}' {# name #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -204,3 +199,87 @@ {{ return("") }} {% endif %} {% endmacro -%} + +{% macro sqlserver__get_snapshot_executions_dml_sql(snapshots) -%} + {% if snapshots != [] %} + {% set snapshot_execution_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + from (values + {% for model in snapshots -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ model.node.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + + {% set config_full_refresh = model.node.config.full_refresh %} + {% if config_full_refresh is none %} + {% set config_full_refresh = flags.FULL_REFRESH %} + {% endif %} + '{{ config_full_refresh }}', {# was_full_refresh #} + + '{{ model.thread_id }}', {# thread_id #} + '{{ model.status }}', {# status #} + + {% if model.timing != [] %} + {% for stage in model.timing if stage.name == "compile" %} + {% if loop.length == 0 %} + null, {# compile_started_at #} + {% else %} + '{{ stage.started_at }}', {# compile_started_at #} + {% endif %} + {% endfor %} + + {% for stage in model.timing if stage.name == "execute" %} + {% if loop.length == 0 %} + null, {# query_completed_at #} + {% else %} + '{{ stage.completed_at }}', {# query_completed_at #} + {% endif %} + {% endfor %} + {% else %} + null, {# compile_started_at #} + null, {# query_completed_at #} + {% endif %} + + {{ model.execution_time }}, {# total_node_runtime #} + null, -- rows_affected not available {# Only available in Snowflake #} + '{{ model.node.config.materialized }}', {# materialization #} + '{{ model.node.schema }}', {# schema #} + '{{ model.node.name }}' {# name #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as snapshot_execution_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(12) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + ) + {% endset %} + {{ snapshot_execution_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_snapshots.sql b/macros/upload_snapshots.sql index 953315f9..d1327ea7 100644 --- a/macros/upload_snapshots.sql +++ b/macros/upload_snapshots.sql @@ -23,8 +23,7 @@ {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, - {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}, - {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(13) }} + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }} from values {% for snapshot in snapshots -%} ( @@ -39,8 +38,7 @@ '{{ snapshot.original_file_path | replace('\\', '\\\\') }}', {# path #} '{{ snapshot.checksum.checksum }}', {# checksum #} '{{ snapshot.config.strategy }}', {# strategy #} - '{{ tojson(snapshot.config.meta) }}', {# meta #} - '{{ snapshot.alias }}' {# alias #} + '{{ tojson(snapshot.config.meta) }}' {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -67,8 +65,7 @@ '{{ snapshot.original_file_path | replace('\\', '\\\\') }}', {# path #} '{{ snapshot.checksum.checksum }}', {# checksum #} '{{ snapshot.config.strategy }}', {# strategy #} - parse_json('{{ tojson(snapshot.config.meta) }}'), {# meta #} - '{{ snapshot.alias }}' {# alias #} + parse_json('{{ tojson(snapshot.config.meta) }}') {# meta #} ) {%- if not loop.last %},{%- endif %} {%- endfor %} @@ -78,3 +75,59 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_snapshots_dml_sql(snapshots) -%} + + {% if snapshots != [] %} + {% set snapshot_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(7)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }} + from (values + {% for snapshot in snapshots -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ snapshot.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ snapshot.database }}', {# database #} + '{{ snapshot.schema }}', {# schema #} + '{{ snapshot.name }}', {# name #} + '{{ tojson(snapshot.depends_on.nodes) }}', {# depends_on_nodes #} + '{{ snapshot.package_name }}', {# package_name #} + '{{ snapshot.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ snapshot.checksum.checksum }}', {# checksum #} + '{{ snapshot.config.strategy }}', {# strategy #} + '{{ tojson(snapshot.config.meta) }}' {# meta #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as snapshot_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(7)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }} + ) + {% endset %} + {{ snapshot_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_sources.sql b/macros/upload_sources.sql index b29047ba..0b62c1c6 100644 --- a/macros/upload_sources.sql +++ b/macros/upload_sources.sql @@ -71,3 +71,56 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_sources_dml_sql(sources) -%} + + {% if sources != [] %} + {% set source_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(11)) }} + from (values + {% for source in sources -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ source.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ source.database }}', {# database #} + '{{ source.schema }}', {# schema #} + '{{ source.source_name }}', {# source_name #} + '{{ source.loader }}', {# loader #} + '{{ source.name }}', {# name #} + '{{ source.identifier }}', {# identifier #} + '{{ source.loaded_at_field | replace("'","\\'") }}', {# loaded_at_field #} + '{{ tojson(source.freshness) | replace("'","\\'") }}' {# freshness #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as source_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(11)) }} + ) + {% endset %} + {{ source_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_test_executions.sql b/macros/upload_test_executions.sql index 3348da4e..cf622bac 100644 --- a/macros/upload_test_executions.sql +++ b/macros/upload_test_executions.sql @@ -125,3 +125,81 @@ {{ return("") }} {% endif %} {% endmacro -%} + +{% macro sqlserver__get_test_executions_dml_sql(tests) -%} + {% if tests != [] %} + {% set test_execution_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }} + from (values + {% for test in tests -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ test.node.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + + {% set config_full_refresh = test.node.config.full_refresh %} + {% if config_full_refresh is none %} + {% set config_full_refresh = flags.FULL_REFRESH %} + {% endif %} + '{{ config_full_refresh }}', {# was_full_refresh #} + + '{{ test.thread_id }}', {# thread_id #} + '{{ test.status }}', {# status #} + + {% if test.timing != [] %} + {% for stage in test.timing if stage.name == "compile" %} + {% if loop.length == 0 %} + null, {# compile_started_at #} + {% else %} + '{{ stage.started_at }}', {# compile_started_at #} + {% endif %} + {% endfor %} + + {% for stage in test.timing if stage.name == "execute" %} + {% if loop.length == 0 %} + null, {# query_completed_at #} + {% else %} + '{{ stage.completed_at }}', {# query_completed_at #} + {% endif %} + {% endfor %} + {% else %} + null, {# compile_started_at #} + null, {# query_completed_at #} + {% endif %} + + {{ test.execution_time }}, {# total_node_runtime #} + null, {# rows_affected not available in Databricks #} + {{ 'null' if test.failures is none else test.failures }} {# failures #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as test_execution_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(5) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }} + ) + {% endset %} + {{ test_execution_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/macros/upload_tests.sql b/macros/upload_tests.sql index f08e74c7..a99e2182 100644 --- a/macros/upload_tests.sql +++ b/macros/upload_tests.sql @@ -62,3 +62,47 @@ {{ return("") }} {% endif %} {%- endmacro %} + +{% macro sqlserver__get_tests_dml_sql(tests) -%} + + {% if tests != [] %} + {% set test_values %} + select + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(5)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(8)) }} + from (values + {% for test in tests -%} + ( + '{{ invocation_id }}', {# command_invocation_id #} + '{{ test.unique_id }}', {# node_id #} + '{{ run_started_at }}', {# run_started_at #} + '{{ test.name }}', {# name #} + '{{ tojson(test.depends_on.nodes) }}', {# depends_on_nodes #} + '{{ test.package_name }}', {# package_name #} + '{{ test.original_file_path | replace('\\', '\\\\') }}', {# test_path #} + '{{ tojson(test.tags) }}' {# tags #} + ) + {%- if not loop.last %},{%- endif %} + {%- endfor %} + ) as test_values( + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(1) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(2) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(3) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(4) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(5)) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }}, + {{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }}, + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(8)) }} + ) + {% endset %} + {{ test_values }} + {% else %} + {{ return("") }} + {% endif %} +{% endmacro -%} \ No newline at end of file diff --git a/models/dim_dbt__current_models.sql b/models/dim_dbt__current_models.sql index c78a063b..2bb697e7 100644 --- a/models/dim_dbt__current_models.sql +++ b/models/dim_dbt__current_models.sql @@ -39,9 +39,9 @@ latest_models_runs as ( latest_model_stats as ( select node_id - , max(case when was_full_refresh then query_completed_at end) as last_full_refresh_run_completed_at - , max(case when was_full_refresh then total_node_runtime end) as last_full_refresh_run_total_runtime - , max(case when was_full_refresh then rows_affected end) as last_full_refresh_run_rows_affected + , max(case when was_full_refresh {% if target.type == 'sqlserver' %}= 1{% endif %} then query_completed_at end) as last_full_refresh_run_completed_at + , max(case when was_full_refresh {% if target.type == 'sqlserver' %}= 1{% endif %} then total_node_runtime end) as last_full_refresh_run_total_runtime + , max(case when was_full_refresh {% if target.type == 'sqlserver' %}= 1{% endif %} then rows_affected end) as last_full_refresh_run_rows_affected {% if target.type == 'bigquery' %} , max(case when was_full_refresh then bytes_processed end) as last_full_refresh_run_bytes_processed {% endif %} @@ -53,7 +53,12 @@ latest_model_stats as ( {% endif %} from latest_models_runs where run_idx = 1 - group by 1 + group by + {% if target.type == 'sqlserver' -%} + node_id + {%- else -%} + 1 + {%- endif %} ), final as ( diff --git a/models/dim_dbt__models.sql b/models/dim_dbt__models.sql index 2722ce83..c03f5062 100644 --- a/models/dim_dbt__models.sql +++ b/models/dim_dbt__models.sql @@ -12,8 +12,8 @@ models as ( command_invocation_id, node_id, run_started_at, - database, - schema, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, name, depends_on_nodes, package_name, @@ -21,8 +21,7 @@ models as ( checksum, materialization, tags, - meta, - alias + meta from base ) diff --git a/models/dim_dbt__models.yml b/models/dim_dbt__models.yml index d56cf4dd..c54b30ce 100644 --- a/models/dim_dbt__models.yml +++ b/models/dim_dbt__models.yml @@ -32,5 +32,3 @@ models: description: '{{ doc("tags") }}' - name: meta description: '{{ doc("meta") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/dim_dbt__seeds.sql b/models/dim_dbt__seeds.sql index d7a461ab..a9d31260 100644 --- a/models/dim_dbt__seeds.sql +++ b/models/dim_dbt__seeds.sql @@ -12,14 +12,13 @@ seeds as ( command_invocation_id, node_id, run_started_at, - database, - schema, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, name, package_name, path, checksum, - meta, - alias + meta from base ) diff --git a/models/dim_dbt__seeds.yml b/models/dim_dbt__seeds.yml index df0f938e..b11c569d 100644 --- a/models/dim_dbt__seeds.yml +++ b/models/dim_dbt__seeds.yml @@ -24,5 +24,3 @@ models: description: '{{ doc("schema") }}' - name: seed_execution_id description: '{{ doc("seed_execution_id") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/dim_dbt__snapshots.sql b/models/dim_dbt__snapshots.sql index 13f05d0e..d886b76c 100644 --- a/models/dim_dbt__snapshots.sql +++ b/models/dim_dbt__snapshots.sql @@ -12,16 +12,15 @@ snapshots as ( command_invocation_id, node_id, run_started_at, - database, - schema, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, name, depends_on_nodes, package_name, path, checksum, strategy, - meta, - alias + meta from base ) diff --git a/models/dim_dbt__snapshots.yml b/models/dim_dbt__snapshots.yml index 9c13c66a..919b6c24 100644 --- a/models/dim_dbt__snapshots.yml +++ b/models/dim_dbt__snapshots.yml @@ -28,5 +28,3 @@ models: description: '{{ doc("snapshot_execution_id") }}' - name: strategy description: '{{ doc("strategy") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/dim_dbt__sources.sql b/models/dim_dbt__sources.sql index 84b76d4d..b3f9e291 100644 --- a/models/dim_dbt__sources.sql +++ b/models/dim_dbt__sources.sql @@ -12,8 +12,8 @@ sources as ( command_invocation_id, node_id, run_started_at, - database, - schema, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, source_name, loader, name, diff --git a/models/docs.md b/models/docs.md index 6879f347..5f49ce37 100644 --- a/models/docs.md +++ b/models/docs.md @@ -389,8 +389,4 @@ Key-value pairs of environment variables passed to invocation that have the pref {% enddocs %} -{% docs alias %} -Alias of the node. - -{% enddocs %} diff --git a/models/fct_dbt__model_executions.sql b/models/fct_dbt__model_executions.sql index e902e1cb..cf4c8643 100644 --- a/models/fct_dbt__model_executions.sql +++ b/models/fct_dbt__model_executions.sql @@ -23,9 +23,8 @@ model_executions as ( bytes_processed, {% endif %} materialization, - schema, -- noqa - name, - alias + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, -- noqa + name from base ) diff --git a/models/fct_dbt__model_executions.yml b/models/fct_dbt__model_executions.yml index 96a528b9..a3852827 100644 --- a/models/fct_dbt__model_executions.yml +++ b/models/fct_dbt__model_executions.yml @@ -32,5 +32,3 @@ models: description: '{{ doc("total_node_runtime") }}' - name: was_full_refresh description: '{{ doc("was_full_refresh") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/fct_dbt__seed_executions.sql b/models/fct_dbt__seed_executions.sql index 021161f6..1e725881 100644 --- a/models/fct_dbt__seed_executions.sql +++ b/models/fct_dbt__seed_executions.sql @@ -20,9 +20,8 @@ seed_executions as ( total_node_runtime, rows_affected, materialization, - schema, - name, - alias + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, + name from base ) diff --git a/models/fct_dbt__seed_executions.yml b/models/fct_dbt__seed_executions.yml index 1f0f59ab..8a8cfbfa 100644 --- a/models/fct_dbt__seed_executions.yml +++ b/models/fct_dbt__seed_executions.yml @@ -30,5 +30,3 @@ models: description: '{{ doc("total_node_runtime") }}' - name: was_full_refresh description: '{{ doc("was_full_refresh") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/fct_dbt__snapshot_executions.sql b/models/fct_dbt__snapshot_executions.sql index 54e0cdb1..1f21e87b 100644 --- a/models/fct_dbt__snapshot_executions.sql +++ b/models/fct_dbt__snapshot_executions.sql @@ -20,9 +20,8 @@ snapshot_executions as ( total_node_runtime, rows_affected, materialization, - schema, - name, - alias + {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, + name from base ) diff --git a/models/fct_dbt__snapshot_executions.yml b/models/fct_dbt__snapshot_executions.yml index ed614411..f73c3cac 100644 --- a/models/fct_dbt__snapshot_executions.yml +++ b/models/fct_dbt__snapshot_executions.yml @@ -30,5 +30,3 @@ models: description: '{{ doc("total_node_runtime") }}' - name: was_full_refresh description: '{{ doc("was_full_refresh") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/sources/model_executions.sql b/models/sources/model_executions.sql index 7b051a8c..98c9d8b1 100644 --- a/models/sources/model_executions.sql +++ b/models/sources/model_executions.sql @@ -18,8 +18,7 @@ select cast(null as {{ type_int() }}) as bytes_processed, {% endif %} cast(null as {{ type_string() }}) as materialization, - cast(null as {{ type_string() }}) as schema, - cast(null as {{ type_string() }}) as name, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, + cast(null as {{ type_string() }}) as name from dummy_cte where 1 = 0 diff --git a/models/sources/models.sql b/models/sources/models.sql index 4cbb1adc..da95bb59 100644 --- a/models/sources/models.sql +++ b/models/sources/models.sql @@ -7,8 +7,8 @@ select cast(null as {{ type_string() }}) as command_invocation_id, cast(null as {{ type_string() }}) as node_id, cast(null as {{ type_timestamp() }}) as run_started_at, - cast(null as {{ type_string() }}) as database, - cast(null as {{ type_string() }}) as schema, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, cast(null as {{ type_string() }}) as name, cast(null as {{ type_array() }}) as depends_on_nodes, cast(null as {{ type_string() }}) as package_name, @@ -16,7 +16,6 @@ select cast(null as {{ type_string() }}) as checksum, cast(null as {{ type_string() }}) as materialization, cast(null as {{ type_array() }}) as tags, - cast(null as {{ type_json() }}) as meta, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_json() }}) as meta from dummy_cte where 1 = 0 diff --git a/models/sources/seed_executions.sql b/models/sources/seed_executions.sql index 1f79c743..08ea7f27 100644 --- a/models/sources/seed_executions.sql +++ b/models/sources/seed_executions.sql @@ -15,8 +15,7 @@ select cast(null as {{ type_float() }}) as total_node_runtime, cast(null as {{ type_int() }}) as rows_affected, cast(null as {{ type_string() }}) as materialization, - cast(null as {{ type_string() }}) as schema, - cast(null as {{ type_string() }}) as name, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, + cast(null as {{ type_string() }}) as name from dummy_cte where 1 = 0 diff --git a/models/sources/seeds.sql b/models/sources/seeds.sql index 3967d243..a34fa98c 100644 --- a/models/sources/seeds.sql +++ b/models/sources/seeds.sql @@ -7,13 +7,12 @@ select cast(null as {{ type_string() }}) as command_invocation_id, cast(null as {{ type_string() }}) as node_id, cast(null as {{ type_timestamp() }}) as run_started_at, - cast(null as {{ type_string() }}) as database, - cast(null as {{ type_string() }}) as schema, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, cast(null as {{ type_string() }}) as name, cast(null as {{ type_string() }}) as package_name, cast(null as {{ type_string() }}) as path, cast(null as {{ type_string() }}) as checksum, - cast(null as {{ type_json() }}) as meta, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_json() }}) as meta from dummy_cte where 1 = 0 diff --git a/models/sources/snapshot_executions.sql b/models/sources/snapshot_executions.sql index 1f79c743..08ea7f27 100644 --- a/models/sources/snapshot_executions.sql +++ b/models/sources/snapshot_executions.sql @@ -15,8 +15,7 @@ select cast(null as {{ type_float() }}) as total_node_runtime, cast(null as {{ type_int() }}) as rows_affected, cast(null as {{ type_string() }}) as materialization, - cast(null as {{ type_string() }}) as schema, - cast(null as {{ type_string() }}) as name, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, + cast(null as {{ type_string() }}) as name from dummy_cte where 1 = 0 diff --git a/models/sources/snapshots.sql b/models/sources/snapshots.sql index 579fea4d..0f55f79e 100644 --- a/models/sources/snapshots.sql +++ b/models/sources/snapshots.sql @@ -7,15 +7,14 @@ select cast(null as {{ type_string() }}) as command_invocation_id, cast(null as {{ type_string() }}) as node_id, cast(null as {{ type_timestamp() }}) as run_started_at, - cast(null as {{ type_string() }}) as database, - cast(null as {{ type_string() }}) as schema, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, cast(null as {{ type_string() }}) as name, cast(null as {{ type_array() }}) as depends_on_nodes, cast(null as {{ type_string() }}) as package_name, cast(null as {{ type_string() }}) as path, cast(null as {{ type_string() }}) as checksum, cast(null as {{ type_string() }}) as strategy, - cast(null as {{ type_json() }}) as meta, - cast(null as {{ type_string() }}) as alias + cast(null as {{ type_json() }}) as meta from dummy_cte where 1 = 0 diff --git a/models/sources/sources.sql b/models/sources/sources.sql index 13f69ddc..d0f240f7 100644 --- a/models/sources/sources.sql +++ b/models/sources/sources.sql @@ -7,8 +7,8 @@ select cast(null as {{ type_string() }}) as command_invocation_id, cast(null as {{ type_string() }}) as node_id, cast(null as {{ type_timestamp() }}) as run_started_at, - cast(null as {{ type_string() }}) as database, - cast(null as {{ type_string() }}) as schema, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('database') }}, + cast(null as {{ type_string() }}) as {{ adapter.dispatch('quote_reserved_keywords', 'dbt_artifacts')('schema') }}, cast(null as {{ type_string() }}) as source_name, cast(null as {{ type_string() }}) as loader, cast(null as {{ type_string() }}) as name, diff --git a/models/staging/stg_dbt__model_executions.sql b/models/staging/stg_dbt__model_executions.sql index c94c98d0..e5434fa8 100644 --- a/models/staging/stg_dbt__model_executions.sql +++ b/models/staging/stg_dbt__model_executions.sql @@ -23,9 +23,8 @@ enhanced as ( bytes_processed, {% endif %} materialization, - schema, -- noqa - name, - alias + "schema", -- noqa + "name" from base ) diff --git a/models/staging/stg_dbt__model_executions.yml b/models/staging/stg_dbt__model_executions.yml index 99eca179..a14cfe52 100644 --- a/models/staging/stg_dbt__model_executions.yml +++ b/models/staging/stg_dbt__model_executions.yml @@ -14,8 +14,6 @@ models: description: '{{ doc("model_execution_id") }}' - name: name description: '{{ doc("name") }}' - - name: alias - description: '{{ doc("alias") }}' - name: node_id description: '{{ doc("node_id") }}' - name: query_completed_at diff --git a/models/staging/stg_dbt__models.sql b/models/staging/stg_dbt__models.sql index 1208b604..2b9d7a8a 100644 --- a/models/staging/stg_dbt__models.sql +++ b/models/staging/stg_dbt__models.sql @@ -12,17 +12,16 @@ enhanced as ( command_invocation_id, node_id, run_started_at, - database, - schema, - name, + "database", + "schema", + "name", depends_on_nodes, package_name, path, checksum, materialization, tags, - meta, - alias + meta from base ) diff --git a/models/staging/stg_dbt__models.yml b/models/staging/stg_dbt__models.yml index c7c25610..910817b1 100644 --- a/models/staging/stg_dbt__models.yml +++ b/models/staging/stg_dbt__models.yml @@ -18,8 +18,6 @@ models: description: '{{ doc("model_execution_id") }}' - name: name description: '{{ doc("name") }}' - - name: alias - description: '{{ doc("alias") }}' - name: node_id description: '{{ doc("node_id") }}' - name: package_name diff --git a/models/staging/stg_dbt__seed_executions.sql b/models/staging/stg_dbt__seed_executions.sql index 68bcc725..95e3a3d8 100644 --- a/models/staging/stg_dbt__seed_executions.sql +++ b/models/staging/stg_dbt__seed_executions.sql @@ -20,9 +20,8 @@ enhanced as ( total_node_runtime, rows_affected, materialization, - schema, -- noqa - name, - alias + "schema", -- noqa + "name" from base ) diff --git a/models/staging/stg_dbt__seed_executions.yml b/models/staging/stg_dbt__seed_executions.yml index bd085301..fc156e1a 100644 --- a/models/staging/stg_dbt__seed_executions.yml +++ b/models/staging/stg_dbt__seed_executions.yml @@ -12,8 +12,6 @@ models: description: '{{ doc("materialization") }}' - name: name description: '{{ doc("name") }}' - - name: alias - description: '{{ doc("alias") }}' - name: node_id description: '{{ doc("node_id") }}' - name: query_completed_at diff --git a/models/staging/stg_dbt__seeds.sql b/models/staging/stg_dbt__seeds.sql index 546e5159..adbef571 100644 --- a/models/staging/stg_dbt__seeds.sql +++ b/models/staging/stg_dbt__seeds.sql @@ -12,14 +12,13 @@ enhanced as ( command_invocation_id, node_id, run_started_at, - database, - schema, - name, + "database", + "schema", + "name", package_name, path, checksum, - meta, - alias + meta from base ) diff --git a/models/staging/stg_dbt__seeds.yml b/models/staging/stg_dbt__seeds.yml index 376e3ea8..098b6c83 100644 --- a/models/staging/stg_dbt__seeds.yml +++ b/models/staging/stg_dbt__seeds.yml @@ -12,8 +12,6 @@ models: description: '{{ doc("database") }}' - name: name description: '{{ doc("name") }}' - - name: alias - description: '{{ doc("alias") }}' - name: node_id description: '{{ doc("node_id") }}' - name: package_name diff --git a/models/staging/stg_dbt__snapshot_executions.sql b/models/staging/stg_dbt__snapshot_executions.sql index 66e5ea10..ee0c6e8d 100644 --- a/models/staging/stg_dbt__snapshot_executions.sql +++ b/models/staging/stg_dbt__snapshot_executions.sql @@ -20,9 +20,8 @@ enhanced as ( total_node_runtime, rows_affected, materialization, - schema, -- noqa - name, - alias + "schema", -- noqa + "name" from base ) diff --git a/models/staging/stg_dbt__snapshot_executions.yml b/models/staging/stg_dbt__snapshot_executions.yml index f6517bd6..e5413946 100644 --- a/models/staging/stg_dbt__snapshot_executions.yml +++ b/models/staging/stg_dbt__snapshot_executions.yml @@ -12,8 +12,6 @@ models: description: '{{ doc("materialization") }}' - name: name description: '{{ doc("name") }}' - - name: alias - description: '{{ doc("alias") }}' - name: node_id description: '{{ doc("node_id") }}' - name: query_completed_at diff --git a/models/staging/stg_dbt__snapshots.sql b/models/staging/stg_dbt__snapshots.sql index ff1ee7e4..3099510d 100644 --- a/models/staging/stg_dbt__snapshots.sql +++ b/models/staging/stg_dbt__snapshots.sql @@ -12,16 +12,15 @@ enhanced as ( command_invocation_id, node_id, run_started_at, - database, - schema, - name, + "database", + "schema", + "name", depends_on_nodes, package_name, path, checksum, strategy, - meta, - alias + meta from base ) diff --git a/models/staging/stg_dbt__snapshots.yml b/models/staging/stg_dbt__snapshots.yml index e3c4e79f..aae8c088 100644 --- a/models/staging/stg_dbt__snapshots.yml +++ b/models/staging/stg_dbt__snapshots.yml @@ -28,5 +28,3 @@ models: description: '{{ doc("snapshot_execution_id") }}' - name: strategy description: '{{ doc("strategy") }}' - - name: alias - description: '{{ doc("alias") }}' diff --git a/models/staging/stg_dbt__sources.sql b/models/staging/stg_dbt__sources.sql index d35a923a..fda97b05 100644 --- a/models/staging/stg_dbt__sources.sql +++ b/models/staging/stg_dbt__sources.sql @@ -12,11 +12,11 @@ enhanced as ( command_invocation_id, node_id, run_started_at, - database, - schema, + "database", + "schema", source_name, loader, - name, + "name", identifier, loaded_at_field, freshness