From 114b87cbc275b7081c9b53cae6eaa4c560a69321 Mon Sep 17 00:00:00 2001 From: KijkEr Date: Fri, 20 Sep 2024 07:55:43 +0200 Subject: [PATCH] Added delimitied identifier conditional for sql server --- models/sources/model_executions.sql | 48 ++++++++++++-------------- models/sources/models.sql | 42 +++++++++++----------- models/sources/seed_executions.sql | 42 +++++++++++----------- models/sources/snapshot_executions.sql | 42 +++++++++++----------- models/sources/snapshots.sql | 39 +++++++++++---------- models/sources/sources.sql | 40 ++++++++++----------- 6 files changed, 124 insertions(+), 129 deletions(-) diff --git a/models/sources/model_executions.sql b/models/sources/model_executions.sql index 193835ae..fb76e983 100644 --- a/models/sources/model_executions.sql +++ b/models/sources/model_executions.sql @@ -1,30 +1,28 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - - select 1 as foo - - ) +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_boolean() }}) as was_full_refresh - , cast(null as {{ type_string() }}) as thread_id - , cast(null as {{ type_string() }}) as status - , 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 - {% if target.type == 'bigquery' %} - , 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 message - , cast(null as {{ type_json() }}) as adapter_response + 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_boolean() }}) as was_full_refresh, + cast(null as {{ type_string() }}) as thread_id, + cast(null as {{ type_string() }}) as status, + 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 + {% if target.type == "bigquery" %} + , cast(null as {{ type_int() }}) as bytes_processed + {% endif %}, + cast(null as {{ type_string() }}) as materialization, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + cast(null as {{ type_string() }}) as name, + cast(null as {{ type_string() }}) as alias, + cast(null as {{ type_string() }}) as message, + cast(null as {{ type_json() }}) as adapter_response from dummy_cte where 1 = 0 + diff --git a/models/sources/models.sql b/models/sources/models.sql index d58bb4dd..7ac8ee84 100644 --- a/models/sources/models.sql +++ b/models/sources/models.sql @@ -1,26 +1,26 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - - select 1 as foo - - ) +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_string() }}) as "database" - , cast(null as {{ type_string() }}) as "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 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 all_results + 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 {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% 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, + cast(null as {{ type_string() }}) as path, + 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 all_results from dummy_cte where 1 = 0 + diff --git a/models/sources/seed_executions.sql b/models/sources/seed_executions.sql index 2ca0a656..95a750e6 100644 --- a/models/sources/seed_executions.sql +++ b/models/sources/seed_executions.sql @@ -1,27 +1,25 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - - select 1 as foo - - ) +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_boolean() }}) as was_full_refresh - , cast(null as {{ type_string() }}) as thread_id - , cast(null as {{ type_string() }}) as status - , 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_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 message - , cast(null as {{ type_json() }}) as adapter_response + 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_boolean() }}) as was_full_refresh, + cast(null as {{ type_string() }}) as thread_id, + cast(null as {{ type_string() }}) as status, + 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_string() }}) as materialization, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + cast(null as {{ type_string() }}) as name, + cast(null as {{ type_string() }}) as alias, + cast(null as {{ type_string() }}) as message, + cast(null as {{ type_json() }}) as adapter_response from dummy_cte where 1 = 0 + diff --git a/models/sources/snapshot_executions.sql b/models/sources/snapshot_executions.sql index 2ca0a656..95a750e6 100644 --- a/models/sources/snapshot_executions.sql +++ b/models/sources/snapshot_executions.sql @@ -1,27 +1,25 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - - select 1 as foo - - ) +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_boolean() }}) as was_full_refresh - , cast(null as {{ type_string() }}) as thread_id - , cast(null as {{ type_string() }}) as status - , 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_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 message - , cast(null as {{ type_json() }}) as adapter_response + 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_boolean() }}) as was_full_refresh, + cast(null as {{ type_string() }}) as thread_id, + cast(null as {{ type_string() }}) as status, + 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_string() }}) as materialization, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %}, + cast(null as {{ type_string() }}) as name, + cast(null as {{ type_string() }}) as alias, + cast(null as {{ type_string() }}) as message, + cast(null as {{ type_json() }}) as adapter_response from dummy_cte where 1 = 0 + diff --git a/models/sources/snapshots.sql b/models/sources/snapshots.sql index dd038939..f4992be4 100644 --- a/models/sources/snapshots.sql +++ b/models/sources/snapshots.sql @@ -1,24 +1,25 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - - select 1 as foo - ) +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_string() }}) as "database" - , cast(null as {{ type_string() }}) as "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 all_results + 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 {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% 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, + 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 all_results from dummy_cte where 1 = 0 + diff --git a/models/sources/sources.sql b/models/sources/sources.sql index 5a9f5be9..a6a1ee85 100644 --- a/models/sources/sources.sql +++ b/models/sources/sources.sql @@ -1,25 +1,25 @@ /* Bigquery won't let us `where` without `from` so we use this workaround */ -with - dummy_cte as ( - select 1 as foo - ) +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_string() }}) as "database" - , cast(null as {{ type_string() }}) as "schema" - , cast(null as {{ type_string() }}) as source_name - , cast(null as {{ type_string() }}) as loader - , cast(null as {{ type_string() }}) as name - , cast(null as {{ type_string() }}) as identifier - , cast(null as {{ type_string() }}) as loaded_at_field - {% if target.type == 'snowflake' %} - , cast(null as {{ type_array() }}) as freshness - {% else %} - , cast(null as {{ type_json() }}) as freshness - {% endif %} - , cast(null as {{ type_json() }}) as all_results + 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 {% if target.type == "sqlserver" %} "database" + {% else %} database + {% endif %}, + cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" + {% else %} schema + {% endif %},, + cast(null as {{ type_string() }}) as source_name, + cast(null as {{ type_string() }}) as loader, + cast(null as {{ type_string() }}) as name, + cast(null as {{ type_string() }}) as identifier, + cast(null as {{ type_string() }}) as loaded_at_field + {% if target.type == "snowflake" %}, cast(null as {{ type_array() }}) as freshness + {% else %}, cast(null as {{ type_json() }}) as freshness + {% endif %}, + cast(null as {{ type_json() }}) as all_results from dummy_cte where 1 = 0 +