Skip to content

Commit

Permalink
Added delimitied identifier conditional for sql server
Browse files Browse the repository at this point in the history
  • Loading branch information
bvkabn committed Sep 20, 2024
1 parent bc97fc0 commit 114b87c
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 129 deletions.
48 changes: 23 additions & 25 deletions models/sources/model_executions.sql
Original file line number Diff line number Diff line change
@@ -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

42 changes: 21 additions & 21 deletions models/sources/models.sql
Original file line number Diff line number Diff line change
@@ -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

42 changes: 20 additions & 22 deletions models/sources/seed_executions.sql
Original file line number Diff line number Diff line change
@@ -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

42 changes: 20 additions & 22 deletions models/sources/snapshot_executions.sql
Original file line number Diff line number Diff line change
@@ -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

39 changes: 20 additions & 19 deletions models/sources/snapshots.sql
Original file line number Diff line number Diff line change
@@ -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

40 changes: 20 additions & 20 deletions models/sources/sources.sql
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 114b87c

Please sign in to comment.