diff --git a/models/dim_dbt__models.sql b/models/dim_dbt__models.sql index 78e6b613..0836b0e9 100644 --- a/models/dim_dbt__models.sql +++ b/models/dim_dbt__models.sql @@ -7,9 +7,13 @@ with command_invocation_id, node_id, run_started_at, - "database", - "schema", name, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, depends_on_nodes, package_name, path, diff --git a/models/dim_dbt__seeds.sql b/models/dim_dbt__seeds.sql index 6482394d..02b16dff 100644 --- a/models/dim_dbt__seeds.sql +++ b/models/dim_dbt__seeds.sql @@ -7,9 +7,13 @@ with command_invocation_id, node_id, run_started_at, - "database", - "schema", name, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, package_name, path, checksum, diff --git a/models/dim_dbt__snapshots.sql b/models/dim_dbt__snapshots.sql index d84a962a..43d7c004 100644 --- a/models/dim_dbt__snapshots.sql +++ b/models/dim_dbt__snapshots.sql @@ -7,9 +7,13 @@ with command_invocation_id, node_id, run_started_at, - "database", - "schema", name, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, depends_on_nodes, package_name, path, diff --git a/models/dim_dbt__sources.sql b/models/dim_dbt__sources.sql index 4cf5f36f..f8a53552 100644 --- a/models/dim_dbt__sources.sql +++ b/models/dim_dbt__sources.sql @@ -7,8 +7,12 @@ with command_invocation_id, node_id, run_started_at, - "database", - "schema", + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, source_name, loader, name, diff --git a/models/fct_dbt__model_executions.sql b/models/fct_dbt__model_executions.sql index edc201ee..43a43792 100644 --- a/models/fct_dbt__model_executions.sql +++ b/models/fct_dbt__model_executions.sql @@ -16,7 +16,9 @@ with rows_affected {% if target.type == "bigquery" %}, bytes_processed {% endif %}, materialization, - "schema", -- noqa + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, name, alias, message diff --git a/models/fct_dbt__seed_executions.sql b/models/fct_dbt__seed_executions.sql index b9dd605f..f537c9da 100644 --- a/models/fct_dbt__seed_executions.sql +++ b/models/fct_dbt__seed_executions.sql @@ -15,7 +15,9 @@ with total_node_runtime, rows_affected, materialization, - "schema", + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, name, alias, message diff --git a/models/fct_dbt__snapshot_executions.sql b/models/fct_dbt__snapshot_executions.sql index 40774f04..ee35c616 100644 --- a/models/fct_dbt__snapshot_executions.sql +++ b/models/fct_dbt__snapshot_executions.sql @@ -15,7 +15,9 @@ with total_node_runtime, rows_affected, materialization, - "schema", + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, name, alias, message diff --git a/models/fct_dbt__test_executions.sql b/models/fct_dbt__test_executions.sql index 43b87d33..9a4727e1 100644 --- a/models/fct_dbt__test_executions.sql +++ b/models/fct_dbt__test_executions.sql @@ -1,29 +1,25 @@ with - base as ( - - select * - from {{ ref('stg_dbt__test_executions') }} - - ) - - , test_executions as ( + base as (select * from {{ ref("stg_dbt__test_executions") }}), + test_executions as ( select - test_execution_id - , command_invocation_id - , node_id - , run_started_at - , was_full_refresh - , thread_id - , status - , compile_started_at - , query_completed_at - , total_node_runtime - , rows_affected - , failures - , message + test_execution_id, + command_invocation_id, + node_id, + run_started_at, + was_full_refresh, + thread_id, + status, + compile_started_at, + query_completed_at, + total_node_runtime, + rows_affected, + failures, + message from base ) -select * from test_executions +select * +from test_executions + diff --git a/models/sources/model_executions.sql b/models/sources/model_executions.sql index fb76e983..e07107cf 100644 --- a/models/sources/model_executions.sql +++ b/models/sources/model_executions.sql @@ -11,7 +11,7 @@ select cast(null as {{ type_timestamp() }}) as compile_started_at, cast(null as {{ type_timestamp() }}) as query_completed_at, cast(null as {{ type_float() }}) as total_node_runtime, - cast(null as {{ type_int() }}) as rows_affected + cast(null as {{ type_int() }}) as rows_affected, {% if target.type == "bigquery" %} , cast(null as {{ type_int() }}) as bytes_processed {% endif %}, diff --git a/models/sources/snapshots.sql b/models/sources/snapshots.sql index f4992be4..77061731 100644 --- a/models/sources/snapshots.sql +++ b/models/sources/snapshots.sql @@ -4,13 +4,13 @@ with dummy_cte as (select 1 as foo) 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_timestamp() }}) as run_started_at, cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "database" {% else %} database {% endif %}, cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" {% else %} schema - {% endif %},, + {% endif %}, cast(null as {{ type_string() }}) as name, cast(null as {{ type_array() }}) as depends_on_nodes, cast(null as {{ type_string() }}) as package_name, diff --git a/models/staging/stg_dbt__model_executions.sql b/models/staging/stg_dbt__model_executions.sql index 1e1ad57b..ad2c4f50 100644 --- a/models/staging/stg_dbt__model_executions.sql +++ b/models/staging/stg_dbt__model_executions.sql @@ -1,36 +1,33 @@ with - base as ( - - select * - from {{ ref('model_executions') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("model_executions") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as model_execution_id - , command_invocation_id - , node_id - , run_started_at - , was_full_refresh - , {{ split_part('thread_id', "'-'", 2) }} as thread_id - , status - , compile_started_at - , query_completed_at - , total_node_runtime - , rows_affected - {% if target.type == 'bigquery' %} - , bytes_processed - {% endif %} - , materialization - , "schema" -- noqa - , name - , alias - , message - , adapter_response + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as model_execution_id, + command_invocation_id, + node_id, + run_started_at, + was_full_refresh, + {{ split_part("thread_id", "'-'", 2) }} as thread_id, + status, + compile_started_at, + query_completed_at, + total_node_runtime, + rows_affected + {% if target.type == "bigquery" %}, bytes_processed {% endif %}, + materialization, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, -- noqa + name, + alias, + message, + adapter_response from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__models.sql b/models/staging/stg_dbt__models.sql index eb5fc5c6..d8184183 100644 --- a/models/staging/stg_dbt__models.sql +++ b/models/staging/stg_dbt__models.sql @@ -1,31 +1,32 @@ with - base as ( - - select * - from {{ ref('models') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("models") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as model_execution_id - , command_invocation_id - , node_id - , run_started_at - , "database" - , "schema" - , name - , depends_on_nodes - , package_name - , path - , checksum - , materialization - , tags - , meta - , alias + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as model_execution_id, + command_invocation_id, + node_id, + run_started_at, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, -- noqa + name, + depends_on_nodes, + package_name, + path, + checksum, + materialization, + tags, + meta, + alias from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__seed_executions.sql b/models/staging/stg_dbt__seed_executions.sql index 31b0c2e9..90f52870 100644 --- a/models/staging/stg_dbt__seed_executions.sql +++ b/models/staging/stg_dbt__seed_executions.sql @@ -1,33 +1,32 @@ with - base as ( - - select * - from {{ ref('seed_executions') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("seed_executions") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as seed_execution_id - , command_invocation_id - , node_id - , run_started_at - , was_full_refresh - , {{ split_part('thread_id', "'-'", 2) }} as thread_id - , status - , compile_started_at - , query_completed_at - , total_node_runtime - , rows_affected - , materialization - , "schema" -- noqa - , name - , alias - , message - , adapter_response + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as seed_execution_id, + command_invocation_id, + node_id, + run_started_at, + was_full_refresh, + {{ split_part("thread_id", "'-'", 2) }} as thread_id, + status, + compile_started_at, + query_completed_at, + total_node_runtime, + rows_affected, + materialization, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, -- noqa + name, + alias, + message, + adapter_response from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__seeds.sql b/models/staging/stg_dbt__seeds.sql index 5aea6e08..0e5dcb1d 100644 --- a/models/staging/stg_dbt__seeds.sql +++ b/models/staging/stg_dbt__seeds.sql @@ -1,28 +1,29 @@ with - base as ( - - select * - from {{ ref('seeds') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("seeds") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as seed_execution_id - , command_invocation_id - , node_id - , run_started_at - , "database" - , "schema" - , name - , package_name - , path - , checksum - , meta - , alias + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as seed_execution_id, + command_invocation_id, + node_id, + run_started_at, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + name, + package_name, + path, + checksum, + meta, + alias from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__snapshot_executions.sql b/models/staging/stg_dbt__snapshot_executions.sql index dbac0734..8794b99b 100644 --- a/models/staging/stg_dbt__snapshot_executions.sql +++ b/models/staging/stg_dbt__snapshot_executions.sql @@ -1,33 +1,32 @@ with - base as ( - - select * - from {{ ref('snapshot_executions') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("snapshot_executions") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as snapshot_execution_id - , command_invocation_id - , node_id - , run_started_at - , was_full_refresh - , {{ split_part('thread_id', "'-'", 2) }} as thread_id - , status - , compile_started_at - , query_completed_at - , total_node_runtime - , rows_affected - , materialization - , "schema" -- noqa - , name - , alias - , message - , adapter_response + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as snapshot_execution_id, + command_invocation_id, + node_id, + run_started_at, + was_full_refresh, + {{ split_part("thread_id", "'-'", 2) }} as thread_id, + status, + compile_started_at, + query_completed_at, + total_node_runtime, + rows_affected, + materialization, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, -- noqa + name, + alias, + message, + adapter_response from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__snapshots.sql b/models/staging/stg_dbt__snapshots.sql index ffdd0732..8b2a66a4 100644 --- a/models/staging/stg_dbt__snapshots.sql +++ b/models/staging/stg_dbt__snapshots.sql @@ -1,30 +1,32 @@ with - base as ( + base as (select * from {{ ref("snapshots") }}), - select * - from {{ ref('snapshots') }} - - ) - - , enhanced as ( + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as snapshot_execution_id - , command_invocation_id - , node_id - , run_started_at - , "database" - , "schema" - , name - , depends_on_nodes - , package_name - , path - , checksum - , strategy - , meta - , alias + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as snapshot_execution_id, + command_invocation_id, + node_id, + run_started_at, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + name, + depends_on_nodes, + package_name, + path, + checksum, + strategy, + meta, + alias from base ) -select * from enhanced +select * +from enhanced + diff --git a/models/staging/stg_dbt__sources.sql b/models/staging/stg_dbt__sources.sql index 5c4056fc..1bd8cef1 100644 --- a/models/staging/stg_dbt__sources.sql +++ b/models/staging/stg_dbt__sources.sql @@ -1,28 +1,29 @@ with - base as ( - - select * - from {{ ref('sources') }} - - ) - - , enhanced as ( + base as (select * from {{ ref("sources") }}), + enhanced as ( select - {{ dbt_artifacts.generate_surrogate_key(['command_invocation_id', 'node_id']) }} as source_execution_id - , command_invocation_id - , node_id - , run_started_at - , "database" - , "schema" - , source_name - , loader - , name - , identifier - , loaded_at_field - , freshness + {{ dbt_artifacts.generate_surrogate_key(["command_invocation_id", "node_id"]) }} + as source_execution_id, + command_invocation_id, + node_id, + run_started_at, + {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + source_name, + loader, + name, + identifier, + loaded_at_field, + freshness from base ) -select * from enhanced +select * +from enhanced +