From e2a0255f80c62f12cefeaf14ae9028cdbe6bcf3a Mon Sep 17 00:00:00 2001 From: shah Date: Tue, 5 Nov 2024 16:22:42 -0800 Subject: [PATCH 01/18] near fact_blocks deploy success --- Makefile | 19 ++++++++++ macros/near/near.yaml.sql | 31 ++++++++++++++++ macros/near/near_live_views.sql | 55 ++++++++++++++++++++++++++++ macros/near/near_primitives.yaml.sql | 22 +++++++++++ models/deploy/near/near__mainnet.sql | 5 +++ 5 files changed, 132 insertions(+) create mode 100644 Makefile create mode 100644 macros/near/near.yaml.sql create mode 100644 macros/near/near_live_views.sql create mode 100644 macros/near/near_primitives.yaml.sql create mode 100644 models/deploy/near/near__mainnet.sql diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f43759f --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +SHELL := /bin/bash + +rm_logs: + rm -r logs + +deploy_near_mainnet_lv: rm_logs + dbt run \ + -s livequery_models.deploy.near.near__mainnet \ + --vars '{UPDATE_UDFS_AND_SPS: true}' \ + --profiles-dir ~/.dbt \ + --profile livequery \ + --target dev + +compile_near_mainnet: rm_logs + dbt compile \ + -s livequery_models.deploy.near.near__mainnet \ + --profiles-dir ~/.dbt \ + --profile livequery \ + --target dev diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql new file mode 100644 index 0000000..b417149 --- /dev/null +++ b/macros/near/near.yaml.sql @@ -0,0 +1,31 @@ +{% macro config_near_high_level_abstractions(blockchain, network) -%} +{# + This macro is used to generate the high level abstractions for the Near + blockchain. + #} +{% set schema = blockchain ~ "_" ~ network %} +- name: {{ schema -}}.tf_fact_blocks + signature: + - [block_height, INTEGER, The start block height to get the transfers from] + - [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not] + return_type: + - - name: {{ schema -}}.tf_fact_blocks + signature: + - [block_height, INTEGER, The start block height to get the transfers from] + - [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not] + return_type: + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_LTZ, modified_timestamp TIMESTAMP_LTZ)" + options: | + NOT NULL + RETURNS NULL ON NULL INPUT + VOLATILE + COMMENT = $$Returns the block data for a given block height. If to_latest + options: | + NOT NULL + RETURNS NULL ON NULL INPUT + VOLATILE + COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block height is reached.$$ + sql: | + {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} + +{%- endmacro -%} \ No newline at end of file diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql new file mode 100644 index 0000000..6cd60f0 --- /dev/null +++ b/macros/near/near_live_views.sql @@ -0,0 +1,55 @@ + +-- Get Near fact data +{% macro near_live_view_fact_blocks(schema, blockchain, network) %} + WITH blocks AS ( + + SELECT + * + FROM + NEAR_DEV.silver.streamline_blocks + ) + SELECT + block_id, + block_timestamp, + block_hash, + tx_count, -- TO DEPRECATE + block_author, + header, + header :challenges_result :: ARRAY AS block_challenges_result, + header :challenges_root :: STRING AS block_challenges_root, + header :chunk_headers_root :: STRING AS chunk_headers_root, + header :chunk_tx_root :: STRING AS chunk_tx_root, + header :chunk_mask :: ARRAY AS chunk_mask, + header :chunk_receipts_root :: STRING AS chunk_receipts_root, + chunks, + header :chunks_included :: NUMBER AS chunks_included, + epoch_id, + header :epoch_sync_data_hash :: STRING AS epoch_sync_data_hash, + events, -- TO DEPRECATE + gas_price, + header :last_ds_final_block :: STRING AS last_ds_final_block, + header :last_final_block :: STRING AS last_final_block, + latest_protocol_version, + header: next_bp_hash :: STRING AS next_bp_hash, + next_epoch_id, + header :outcome_root :: STRING AS outcome_root, + prev_hash, + header :prev_height :: NUMBER AS prev_height, + header :prev_state_root :: STRING AS prev_state_root, + header :random_value :: STRING AS random_value, + header :rent_paid :: FLOAT AS rent_paid, + header :signature :: STRING AS signature, + total_supply, + validator_proposals, + validator_reward, + COALESCE( + streamline_blocks_id, + + + md5(cast(coalesce(cast(block_id as TEXT), '_dbt_utils_surrogate_key_null_') as TEXT)) + ) AS fact_blocks_id, + COALESCE(inserted_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS inserted_timestamp, + COALESCE(modified_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS modified_timestamp + FROM + blocks +{% endmacro %} \ No newline at end of file diff --git a/macros/near/near_primitives.yaml.sql b/macros/near/near_primitives.yaml.sql new file mode 100644 index 0000000..66b0bca --- /dev/null +++ b/macros/near/near_primitives.yaml.sql @@ -0,0 +1,22 @@ +{%- macro config_near_rpc_primitives(blockchain, network) -%} +{#- + Generates udfs that call the Near JSON RPC API + + - rpc: Executes an RPC call on the {{ blockchain }} blockchain + + -#} +{% set schema = blockchain ~ "_" ~ network -%} + +- name: {{ schema -}}.udf_rpc + signature: + - [method, STRING, RPC method to call] + - [parameters, VARIANT, Parameters to pass to the RPC method] + return_type: [VARIANT, The return value of the RPC method] + options: | + NOT NULL + RETURNS NULL ON NULL INPUT + VOLATILE + COMMENT = $$Executes an RPC call on the {{ blockchain }} blockchain.$$ + sql: | + SELECT live.udf_rpc('{{ blockchain }}', '{{ network }}', method, parameters) +{%- endmacro -%} \ No newline at end of file diff --git a/models/deploy/near/near__mainnet.sql b/models/deploy/near/near__mainnet.sql new file mode 100644 index 0000000..31dc4c1 --- /dev/null +++ b/models/deploy/near/near__mainnet.sql @@ -0,0 +1,5 @@ +{%- set configs = [ + config_near_rpc_primitives, + config_near_high_level_abstractions + ] -%} +{{- ephemeral_deploy(configs) -}} From 9f9b904c21c305fe8895ae4aaba76aa2c55eaaac Mon Sep 17 00:00:00 2001 From: shah Date: Thu, 7 Nov 2024 22:30:31 -0800 Subject: [PATCH 02/18] STREAM-1093 add fact_blocks json rpc --- Makefile | 6 +- macros/near/near.yaml.sql | 12 +-- macros/near/near_live_views.sql | 132 ++++++++++++++++++++------------ 3 files changed, 89 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index f43759f..3f7da31 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ SHELL := /bin/bash rm_logs: - rm -r logs + @if [ -d logs ]; then \ + rm -r logs 2>/dev/null || echo "Warning: Could not remove logs directory"; \ + else \ + echo "Logs directory does not exist"; \ + fi deploy_near_mainnet_lv: rm_logs dbt run \ diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index b417149..219c7ea 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -5,21 +5,11 @@ #} {% set schema = blockchain ~ "_" ~ network %} - name: {{ schema -}}.tf_fact_blocks - signature: - - [block_height, INTEGER, The start block height to get the transfers from] - - [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not] - return_type: - - - name: {{ schema -}}.tf_fact_blocks signature: - [block_height, INTEGER, The start block height to get the transfers from] - [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not] return_type: - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_LTZ, modified_timestamp TIMESTAMP_LTZ)" - options: | - NOT NULL - RETURNS NULL ON NULL INPUT - VOLATILE - COMMENT = $$Returns the block data for a given block height. If to_latest options: | NOT NULL RETURNS NULL ON NULL INPUT @@ -27,5 +17,5 @@ COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block height is reached.$$ sql: | {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} +{%- endmacro -%} -{%- endmacro -%} \ No newline at end of file diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 6cd60f0..19403a0 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -1,55 +1,89 @@ -- Get Near fact data {% macro near_live_view_fact_blocks(schema, blockchain, network) %} - WITH blocks AS ( - - SELECT - * - FROM - NEAR_DEV.silver.streamline_blocks - ) +WITH heights AS ( + SELECT + livequery_dev.live.udf_api( + 'https://rpc.mainnet.near.org', + livequery_dev.utils.udf_json_rpc_call( + 'block', + {'finality': 'final'} + ) + ):data AS result, + result:result:header:height::integer as latest_block_height, + coalesce( + 132209591, + latest_block_height + ) as min_height, + iff( + coalesce(false, false), + latest_block_height, + min_height + ) as max_height +), +spine AS ( SELECT - block_id, - block_timestamp, - block_hash, - tx_count, -- TO DEPRECATE - block_author, - header, - header :challenges_result :: ARRAY AS block_challenges_result, - header :challenges_root :: STRING AS block_challenges_root, - header :chunk_headers_root :: STRING AS chunk_headers_root, - header :chunk_tx_root :: STRING AS chunk_tx_root, - header :chunk_mask :: ARRAY AS chunk_mask, - header :chunk_receipts_root :: STRING AS chunk_receipts_root, - chunks, - header :chunks_included :: NUMBER AS chunks_included, - epoch_id, - header :epoch_sync_data_hash :: STRING AS epoch_sync_data_hash, - events, -- TO DEPRECATE - gas_price, - header :last_ds_final_block :: STRING AS last_ds_final_block, - header :last_final_block :: STRING AS last_final_block, - latest_protocol_version, - header: next_bp_hash :: STRING AS next_bp_hash, - next_epoch_id, - header :outcome_root :: STRING AS outcome_root, - prev_hash, - header :prev_height :: NUMBER AS prev_height, - header :prev_state_root :: STRING AS prev_state_root, - header :random_value :: STRING AS random_value, - header :rent_paid :: FLOAT AS rent_paid, - header :signature :: STRING AS signature, - total_supply, - validator_proposals, - validator_reward, - COALESCE( - streamline_blocks_id, - - - md5(cast(coalesce(cast(block_id as TEXT), '_dbt_utils_surrogate_key_null_') as TEXT)) - ) AS fact_blocks_id, - COALESCE(inserted_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS inserted_timestamp, - COALESCE(modified_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS modified_timestamp + row_number() over (order by null) - 1 + COALESCE(132209591, 0)::integer as block_height, + min_height, + max_height, + latest_block_height FROM - blocks + table(generator(ROWCOUNT => 1000)), + heights + QUALIFY block_height BETWEEN min_height AND max_height +), +raw_blocks AS ( + + SELECT + block_height, + livequery_dev.live.udf_api( + 'https://rpc.mainnet.near.org', + livequery_Dev.utils.udf_json_rpc_call( + 'block', + {'block_id': block_height} + ) + ):data.result AS block_data + from + spine + +) +SELECT + block_data:header:height::string as block_id, + TO_TIMESTAMP_NTZ( + block_data :header :timestamp :: STRING + ) AS block_timestamp, + block_data:header:hash::STRING as block_hash, + ARRAY_SIZE(block_data:chunks)::NUMBER as tx_count, + block_data:header as header, + block_data:header:challenges_result::ARRAY as block_challenges_result, + block_data:header:challenges_root::STRING as block_challenges_root, + block_data:header:chunk_headers_root::STRING as chunk_headers_root, + block_data:header:chunk_tx_root::STRING as chunk_tx_root, + block_data:header:chunk_mask::ARRAY as chunk_mask, + block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, + block_data:chunks as chunks, + block_data:header:chunks_included::NUMBER as chunks_included, + block_data:header:epoch_id::STRING as epoch_id, + block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, + block_data:events as events, + block_data:header:gas_price::NUMBER as gas_price, + block_data:header:last_ds_final_block::STRING as last_ds_final_block, + block_data:header:last_final_block::STRING as last_final_block, + block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, + block_data:header:next_bp_hash::STRING as next_bp_hash, + block_data:header:next_epoch_id::STRING as next_epoch_id, + block_data:header:outcome_root::STRING as outcome_root, + block_data:header:prev_hash::STRING as prev_hash, + block_data:header:prev_height::NUMBER as prev_height, + block_data:header:prev_state_root::STRING as prev_state_root, + block_data:header:random_value::STRING as random_value, + block_data:header:rent_paid::FLOAT as rent_paid, + block_data:header:signature::STRING as signature, + block_data:header:total_supply::NUMBER as total_supply, + block_data:header:validator_proposals as validator_proposals, + block_data:header:validator_reward::NUMBER as validator_reward, + MD5(block_data:header:height::STRING) as fact_blocks_id, + SYSDATE() as inserted_timestamp, + SYSDATE() as modified_timestamp +FROM raw_blocks; {% endmacro %} \ No newline at end of file From 349813f4e008a3ce38f64779d25ab4ee41e0c4af Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 8 Nov 2024 18:47:38 -0800 Subject: [PATCH 03/18] test livequery for calls --- macros/near/near.yaml.sql | 6 +- macros/near/near_live_views.sql | 167 ++++++++++++++++---------------- 2 files changed, 87 insertions(+), 86 deletions(-) diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 219c7ea..1e5106a 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -6,10 +6,10 @@ {% set schema = blockchain ~ "_" ~ network %} - name: {{ schema -}}.tf_fact_blocks signature: - - [block_height, INTEGER, The start block height to get the transfers from] - - [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not] + - [block_height, INTEGER, The start block height to get the blocks from] + - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] return_type: - - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_LTZ, modified_timestamp TIMESTAMP_LTZ)" + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" options: | NOT NULL RETURNS NULL ON NULL INPUT diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 19403a0..d35b17d 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -1,89 +1,90 @@ -- Get Near fact data {% macro near_live_view_fact_blocks(schema, blockchain, network) %} -WITH heights AS ( - SELECT - livequery_dev.live.udf_api( - 'https://rpc.mainnet.near.org', - livequery_dev.utils.udf_json_rpc_call( - 'block', - {'finality': 'final'} - ) - ):data AS result, - result:result:header:height::integer as latest_block_height, - coalesce( - 132209591, + WITH heights AS ( + SELECT + livequery.live.udf_api( + 'https://rpc.mainnet.near.org', + livequery.utils.udf_json_rpc_call( + 'block', + {'finality': 'final'} + ) + ):data AS result, + result:result:header:height::integer as latest_block_height, + coalesce( + block_height, + latest_block_height + ) as min_height, + iff( + coalesce(to_latest, false), + latest_block_height, + min_height + ) as max_height + ), + spine AS ( + SELECT + row_number() over (order by null) - 1 + COALESCE(block_height, 0)::integer as block_height, + min_height, + max_height, latest_block_height - ) as min_height, - iff( - coalesce(false, false), - latest_block_height, - min_height - ) as max_height -), -spine AS ( - SELECT - row_number() over (order by null) - 1 + COALESCE(132209591, 0)::integer as block_height, - min_height, - max_height, - latest_block_height - FROM - table(generator(ROWCOUNT => 1000)), - heights - QUALIFY block_height BETWEEN min_height AND max_height -), -raw_blocks AS ( - - SELECT - block_height, - livequery_dev.live.udf_api( - 'https://rpc.mainnet.near.org', - livequery_Dev.utils.udf_json_rpc_call( - 'block', - {'block_id': block_height} - ) - ):data.result AS block_data - from - spine + FROM + table(generator(ROWCOUNT => 1000)), + heights + QUALIFY block_height BETWEEN min_height AND max_height + ), + raw_blocks AS ( + + SELECT + block_height, + livequery.live.udf_api( + 'https://rpc.mainnet.near.org', + livequery.utils.udf_json_rpc_call( + 'block', + {'block_id': block_height} + ) + ):data.result AS block_data + from + spine -) -SELECT - block_data:header:height::string as block_id, - TO_TIMESTAMP_NTZ( - block_data :header :timestamp :: STRING - ) AS block_timestamp, - block_data:header:hash::STRING as block_hash, - ARRAY_SIZE(block_data:chunks)::NUMBER as tx_count, - block_data:header as header, - block_data:header:challenges_result::ARRAY as block_challenges_result, - block_data:header:challenges_root::STRING as block_challenges_root, - block_data:header:chunk_headers_root::STRING as chunk_headers_root, - block_data:header:chunk_tx_root::STRING as chunk_tx_root, - block_data:header:chunk_mask::ARRAY as chunk_mask, - block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, - block_data:chunks as chunks, - block_data:header:chunks_included::NUMBER as chunks_included, - block_data:header:epoch_id::STRING as epoch_id, - block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, - block_data:events as events, - block_data:header:gas_price::NUMBER as gas_price, - block_data:header:last_ds_final_block::STRING as last_ds_final_block, - block_data:header:last_final_block::STRING as last_final_block, - block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, - block_data:header:next_bp_hash::STRING as next_bp_hash, - block_data:header:next_epoch_id::STRING as next_epoch_id, - block_data:header:outcome_root::STRING as outcome_root, - block_data:header:prev_hash::STRING as prev_hash, - block_data:header:prev_height::NUMBER as prev_height, - block_data:header:prev_state_root::STRING as prev_state_root, - block_data:header:random_value::STRING as random_value, - block_data:header:rent_paid::FLOAT as rent_paid, - block_data:header:signature::STRING as signature, - block_data:header:total_supply::NUMBER as total_supply, - block_data:header:validator_proposals as validator_proposals, - block_data:header:validator_reward::NUMBER as validator_reward, - MD5(block_data:header:height::STRING) as fact_blocks_id, - SYSDATE() as inserted_timestamp, - SYSDATE() as modified_timestamp -FROM raw_blocks; + ) + SELECT + block_data:header:height::number as block_id, + TO_TIMESTAMP_NTZ( + block_data :header :timestamp :: STRING + ) AS block_timestamp, + block_data:header:hash::STRING as block_hash, + null as tx_count, + block_data:author::STRING as author, + block_data:header::OBJECT as header, + block_data:header:challenges_result::ARRAY as block_challenges_result, + block_data:header:challenges_root::STRING as block_challenges_root, + block_data:header:chunk_headers_root::STRING as chunk_headers_root, + block_data:header:chunk_tx_root::STRING as chunk_tx_root, + block_data:header:chunk_mask::ARRAY as chunk_mask, + block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, + block_data:chunks::ARRAY as chunks, + block_data:header:chunks_included::NUMBER as chunks_included, + block_data:header:epoch_id::STRING as epoch_id, + block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, + []::ARRAY as events, + block_data:header:gas_price::NUMBER as gas_price, + block_data:header:last_ds_final_block::STRING as last_ds_final_block, + block_data:header:last_final_block::STRING as last_final_block, + block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, + block_data:header:next_bp_hash::STRING as next_bp_hash, + block_data:header:next_epoch_id::STRING as next_epoch_id, + block_data:header:outcome_root::STRING as outcome_root, + block_data:header:prev_hash::STRING as prev_hash, + block_data:header:prev_height::NUMBER as prev_height, + block_data:header:prev_state_root::STRING as prev_state_root, + block_data:header:random_value::STRING as random_value, + block_data:header:rent_paid::FLOAT as rent_paid, + block_data:header:signature::STRING as signature, + block_data:header:total_supply::NUMBER as total_supply, + block_data:header:validator_proposals::ARRAY as validator_proposals, + block_data:header:validator_reward::NUMBER as validator_reward, + MD5(block_data:header:height::STRING) as fact_blocks_id, + SYSDATE() as inserted_timestamp, + SYSDATE() as modified_timestamp + FROM raw_blocks {% endmacro %} \ No newline at end of file From 02e856a37ed1d32fb7f8385c8e0f9fcbc1772d7d Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 11 Nov 2024 08:59:19 -0800 Subject: [PATCH 04/18] fix qualify syntx indentation --- macros/near/near_live_views.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index d35b17d..7711575 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -3,9 +3,9 @@ {% macro near_live_view_fact_blocks(schema, blockchain, network) %} WITH heights AS ( SELECT - livequery.live.udf_api( + live.udf_api( 'https://rpc.mainnet.near.org', - livequery.utils.udf_json_rpc_call( + utils.udf_json_rpc_call( 'block', {'finality': 'final'} ) @@ -28,17 +28,17 @@ max_height, latest_block_height FROM - table(generator(ROWCOUNT => 1000)), + table(generator(ROWCOUNT => (max_height - min_height + 1))), heights - QUALIFY block_height BETWEEN min_height AND max_height + QUALIFY block_height BETWEEN min_height AND max_height ), raw_blocks AS ( SELECT block_height, - livequery.live.udf_api( + live.udf_api( 'https://rpc.mainnet.near.org', - livequery.utils.udf_json_rpc_call( + utils.udf_json_rpc_call( 'block', {'block_id': block_height} ) From 440bb7fafe4769ef06595d424051547d5759bf8f Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 11 Nov 2024 20:08:13 -0800 Subject: [PATCH 05/18] deploy tf_fact_blocks udtf success --- Makefile | 8 + macros/near/near.yaml.sql | 4 +- macros/near/near_live_views.sql | 184 ++++++++++--------- models/deploy/near/near__fact_blocks_poc.sql | 11 ++ models/deploy/near/near__mainnet.sql | 1 + 5 files changed, 121 insertions(+), 87 deletions(-) create mode 100644 models/deploy/near/near__fact_blocks_poc.sql diff --git a/Makefile b/Makefile index 3f7da31..bd090f1 100644 --- a/Makefile +++ b/Makefile @@ -21,3 +21,11 @@ compile_near_mainnet: rm_logs --profiles-dir ~/.dbt \ --profile livequery \ --target dev + +deploy_fact_blocks_poc: rm_logs + dbt run \ + -s livequery_models.deploy.near.near__fact_blocks_poc \ + --vars '{UPDATE_UDFS_AND_SPS: true}' \ + --profiles-dir ~/.dbt \ + --profile livequery \ + --target dev diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 1e5106a..6a5e8e5 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -6,7 +6,7 @@ {% set schema = blockchain ~ "_" ~ network %} - name: {{ schema -}}.tf_fact_blocks signature: - - [block_height, INTEGER, The start block height to get the blocks from] + - [block_id, INTEGER, The start block height to get the blocks from] - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] return_type: - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" @@ -14,7 +14,7 @@ NOT NULL RETURNS NULL ON NULL INPUT VOLATILE - COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block height is reached.$$ + COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block_id height is reached.$$ sql: | {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} {%- endmacro -%} diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 7711575..58a4d28 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -1,90 +1,104 @@ +-- Get Near Chain Head +{% macro near_live_view_latest_block_height(schema, blockchain, network) %} +SELECT + live.udf_api( + 'https://rpc.mainnet.near.org', + utils.udf_json_rpc_call( + 'block', + {'finality': 'final'} + ) + ):data AS result, + result:result:header:height::integer as latest_block_height, + coalesce( + block_id, + latest_block_height + ) as min_height, + iff( + coalesce(to_latest, false), + latest_block_height, + min_height + ) as max_height +{% endmacro %} + +{% macro near_live_view_get_spine(schema, blockchain, network) %} +SELECT + row_number() over (order by null) - 1 + COALESCE(block_id, 0)::integer as block_height, + min_height, + max_height, + latest_block_height +FROM + table(generator(ROWCOUNT => 1000)), + heights + QUALIFY block_height BETWEEN min_height AND max_height +{% endmacro %} + + +-- Get near blocks +{% macro near_live_view_get_raw_blocks(schema, blockchain, network, table_name) %} +SELECT + block_height, + live.udf_api( + 'https://rpc.mainnet.near.org', + utils.udf_json_rpc_call( + 'block', + {'block_id': block_height} + ) + ):data.result AS block_data +from + {{ table_name }} +{% endmacro %} -- Get Near fact data {% macro near_live_view_fact_blocks(schema, blockchain, network) %} - WITH heights AS ( - SELECT - live.udf_api( - 'https://rpc.mainnet.near.org', - utils.udf_json_rpc_call( - 'block', - {'finality': 'final'} - ) - ):data AS result, - result:result:header:height::integer as latest_block_height, - coalesce( - block_height, - latest_block_height - ) as min_height, - iff( - coalesce(to_latest, false), - latest_block_height, - min_height - ) as max_height - ), - spine AS ( - SELECT - row_number() over (order by null) - 1 + COALESCE(block_height, 0)::integer as block_height, - min_height, - max_height, - latest_block_height - FROM - table(generator(ROWCOUNT => (max_height - min_height + 1))), - heights - QUALIFY block_height BETWEEN min_height AND max_height - ), - raw_blocks AS ( - - SELECT - block_height, - live.udf_api( - 'https://rpc.mainnet.near.org', - utils.udf_json_rpc_call( - 'block', - {'block_id': block_height} - ) - ):data.result AS block_data - from - spine +WITH heights AS ( + {{ near_live_view_latest_block_height(schema, blockchain, network) }} +), +spine AS ( + {{ near_live_view_get_spine(schema, blockchain, network) }} +), +raw_blocks AS ( + + {{ near_live_view_get_raw_blocks(schema, blockchain, network, 'spine') }} - ) - SELECT - block_data:header:height::number as block_id, - TO_TIMESTAMP_NTZ( - block_data :header :timestamp :: STRING - ) AS block_timestamp, - block_data:header:hash::STRING as block_hash, - null as tx_count, - block_data:author::STRING as author, - block_data:header::OBJECT as header, - block_data:header:challenges_result::ARRAY as block_challenges_result, - block_data:header:challenges_root::STRING as block_challenges_root, - block_data:header:chunk_headers_root::STRING as chunk_headers_root, - block_data:header:chunk_tx_root::STRING as chunk_tx_root, - block_data:header:chunk_mask::ARRAY as chunk_mask, - block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, - block_data:chunks::ARRAY as chunks, - block_data:header:chunks_included::NUMBER as chunks_included, - block_data:header:epoch_id::STRING as epoch_id, - block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, - []::ARRAY as events, - block_data:header:gas_price::NUMBER as gas_price, - block_data:header:last_ds_final_block::STRING as last_ds_final_block, - block_data:header:last_final_block::STRING as last_final_block, - block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, - block_data:header:next_bp_hash::STRING as next_bp_hash, - block_data:header:next_epoch_id::STRING as next_epoch_id, - block_data:header:outcome_root::STRING as outcome_root, - block_data:header:prev_hash::STRING as prev_hash, - block_data:header:prev_height::NUMBER as prev_height, - block_data:header:prev_state_root::STRING as prev_state_root, - block_data:header:random_value::STRING as random_value, - block_data:header:rent_paid::FLOAT as rent_paid, - block_data:header:signature::STRING as signature, - block_data:header:total_supply::NUMBER as total_supply, - block_data:header:validator_proposals::ARRAY as validator_proposals, - block_data:header:validator_reward::NUMBER as validator_reward, - MD5(block_data:header:height::STRING) as fact_blocks_id, - SYSDATE() as inserted_timestamp, - SYSDATE() as modified_timestamp - FROM raw_blocks +) +SELECT + block_data:header:height::number as block_id, + TO_TIMESTAMP_NTZ( + block_data :header :timestamp :: STRING + ) AS block_timestamp, + block_data:header:hash::STRING as block_hash, + null as tx_count, + block_data:author::STRING as author, + block_data:header::OBJECT as header, + block_data:header:challenges_result::ARRAY as block_challenges_result, + block_data:header:challenges_root::STRING as block_challenges_root, + block_data:header:chunk_headers_root::STRING as chunk_headers_root, + block_data:header:chunk_tx_root::STRING as chunk_tx_root, + block_data:header:chunk_mask::ARRAY as chunk_mask, + block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, + block_data:chunks::ARRAY as chunks, + block_data:header:chunks_included::NUMBER as chunks_included, + block_data:header:epoch_id::STRING as epoch_id, + block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, + []::ARRAY as events, + block_data:header:gas_price::NUMBER as gas_price, + block_data:header:last_ds_final_block::STRING as last_ds_final_block, + block_data:header:last_final_block::STRING as last_final_block, + block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, + block_data:header:next_bp_hash::STRING as next_bp_hash, + block_data:header:next_epoch_id::STRING as next_epoch_id, + block_data:header:outcome_root::STRING as outcome_root, + block_data:header:prev_hash::STRING as prev_hash, + block_data:header:prev_height::NUMBER as prev_height, + block_data:header:prev_state_root::STRING as prev_state_root, + block_data:header:random_value::STRING as random_value, + block_data:header:rent_paid::FLOAT as rent_paid, + block_data:header:signature::STRING as signature, + block_data:header:total_supply::NUMBER as total_supply, + block_data:header:validator_proposals::ARRAY as validator_proposals, + block_data:header:validator_reward::NUMBER as validator_reward, + MD5(block_data:header:height::STRING) as fact_blocks_id, + SYSDATE() as inserted_timestamp, + SYSDATE() as modified_timestamp +FROM raw_blocks {% endmacro %} \ No newline at end of file diff --git a/models/deploy/near/near__fact_blocks_poc.sql b/models/deploy/near/near__fact_blocks_poc.sql new file mode 100644 index 0000000..9e1d6c0 --- /dev/null +++ b/models/deploy/near/near__fact_blocks_poc.sql @@ -0,0 +1,11 @@ +{{ config( + materialized = 'view', + secure = false +) }} + +SELECT * + +FROM + {# {{ ref("near-models","core__fact_blocks")}} #} + table(generator(rowcount => 10)) +LIMIT 10 \ No newline at end of file diff --git a/models/deploy/near/near__mainnet.sql b/models/deploy/near/near__mainnet.sql index 31dc4c1..3c4efeb 100644 --- a/models/deploy/near/near__mainnet.sql +++ b/models/deploy/near/near__mainnet.sql @@ -2,4 +2,5 @@ config_near_rpc_primitives, config_near_high_level_abstractions ] -%} + {{- ephemeral_deploy(configs) -}} From 11dfbb781016aa84b1a93f9ecdf013f8f6650e83 Mon Sep 17 00:00:00 2001 From: shah Date: Wed, 13 Nov 2024 15:18:05 -0800 Subject: [PATCH 06/18] STREAM-1094 S3 PY UDTF Success \0/ --- macros/near/near.yaml.sql | 19 +++- macros/near/near_live_views.sql | 129 +++++++++++++++++++++------ macros/near/near_primitives.yaml.sql | 22 ----- models/deploy/near/near__mainnet.sql | 1 - 4 files changed, 121 insertions(+), 50 deletions(-) delete mode 100644 macros/near/near_primitives.yaml.sql diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 6a5e8e5..94690c1 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -4,12 +4,28 @@ blockchain. #} {% set schema = blockchain ~ "_" ~ network %} +- name: {{ schema -}}.tf_get_block_data + signature: + - [url_block_pairs, ARRAY, The stage file to that contains the block data to retrieve] + return_type: + - "TABLE(block_data VARIANT)" + options: | + LANGUAGE PYTHON + RUNTIME_VERSION = '3.11' + PACKAGES = ('snowflake-snowpark-python') + HANDLER = 'GetBlockData' + COMMENT = $$A UDTF to retrieve NEAR block data from the Near Lake Snowflake External Stage. url_block_pairs (list): A list of objects, each containing: + - url (str): The stage file URL created using BUILD_SCOPED_FILE_URL + - block_height (int): The corresponding block height for the file$$ + sql: | + {{ near_live_view_get_block_data() | indent(4) -}} + - name: {{ schema -}}.tf_fact_blocks signature: - [block_id, INTEGER, The start block height to get the blocks from] - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] return_type: - - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header OBJECT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks ARRAY, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events ARRAY, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals ARRAY, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result VARIANT, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask VARIANT, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" options: | NOT NULL RETURNS NULL ON NULL INPUT @@ -17,5 +33,6 @@ COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block_id height is reached.$$ sql: | {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} + {%- endmacro -%} diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 58a4d28..4f7dfb8 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -20,6 +20,70 @@ SELECT ) as max_height {% endmacro %} +{% macro near_live_view_get_block_data() %} + import json + from typing import Iterator, Tuple + from snowflake.snowpark.files import SnowflakeFile + + class GetBlockData: + """ + A class to retrieve and process multiple NEAR blockchain block data files in bulk from Snowflake External Stage. + + This class serves as a handler for a Snowflake User-Defined Table Function (UDTF) + that reads JSON block data from multiple stage files and yields the block data as a + VARIANT column. The block height and other data can be extracted from the block_data directly. + + Attributes: + None + + Example: + To use this function in Snowflake: + ```sql + SELECT * + FROM TABLE(get_block_data_bulk(ARRAY_CONSTRUCT( + BUILD_SCOPED_FILE_URL(@stage_name, '000132121137/block.json'), + BUILD_SCOPED_FILE_URL(@stage_name, '000132121138/block.json') + ))); + ``` + """ + + def process(self, file_urls: list) -> Iterator[Tuple[dict]]: + """ + Process multiple block data files from specified stage file URLs. + + Args: + file_urls (list): A list of stage file URLs created using BUILD_SCOPED_FILE_URL + + Yields: + Iterator[Tuple[dict]]: A series of single-element tuples, each containing + the complete block data structure or an error object + + Note: + - Files must contain valid NEAR blockchain block data in JSON format + - If a file fails to process, an error object is returned instead of skipping + - The resulting block_data column can be queried using standard SQL JSON path notation + """ + for file_url in file_urls: + try: + with SnowflakeFile.open(file_url) as file: + block_data = json.load(file) + yield (block_data,) + except json.JSONDecodeError as e: + error_info = { + 'error': 'JSONDecodeError', + 'details': f'Invalid JSON data: {str(e)}', + 'url': file_url + } + yield (error_info,) + except Exception as e: + error_info = { + 'error': e.__class__.__name__, + 'details': str(e), + 'url': file_url + } + yield (error_info,) +{% endmacro %} + {% macro near_live_view_get_spine(schema, blockchain, network) %} SELECT row_number() over (order by null) - 1 + COALESCE(block_id, 0)::integer as block_height, @@ -57,48 +121,61 @@ spine AS ( {{ near_live_view_get_spine(schema, blockchain, network) }} ), raw_blocks AS ( - - {{ near_live_view_get_raw_blocks(schema, blockchain, network, 'spine') }} - + WITH block_urls AS ( + SELECT + s.block_height, + ARRAY_AGG( + BUILD_SCOPED_FILE_URL( + '@streamline.bronze.near_lake_data_mainnet', + CONCAT(LPAD(TO_VARCHAR(s.block_height), 12, '0'), '/block.json') + ) + ) OVER () as urls + FROM spine s + ) + SELECT + u.block_height, + b.block_data + FROM block_urls u, + TABLE({{ schema -}}.tf_get_block_data(u.urls)) b ) -SELECT - block_data:header:height::number as block_id, - TO_TIMESTAMP_NTZ( - block_data :header :timestamp :: STRING - ) AS block_timestamp, +SELECT + block_data:header:height::NUMBER(38,0) as block_id, + TO_TIMESTAMP_NTZ(block_data:header:timestamp::STRING) as block_timestamp, block_data:header:hash::STRING as block_hash, - null as tx_count, - block_data:author::STRING as author, - block_data:header::OBJECT as header, - block_data:header:challenges_result::ARRAY as block_challenges_result, + ARRAY_SIZE(block_data:chunks)::STRING as tx_count, + block_data:author::STRING as block_author, + block_data:header as header, + block_data:header:challenges_result as block_challenges_result, -- Removed ::ARRAY cast block_data:header:challenges_root::STRING as block_challenges_root, block_data:header:chunk_headers_root::STRING as chunk_headers_root, block_data:header:chunk_tx_root::STRING as chunk_tx_root, - block_data:header:chunk_mask::ARRAY as chunk_mask, + block_data:header:chunk_mask as chunk_mask, -- Removed ::ARRAY cast block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, - block_data:chunks::ARRAY as chunks, - block_data:header:chunks_included::NUMBER as chunks_included, + block_data:chunks as chunks, + block_data:header:chunks_included::NUMBER(38,0) as chunks_included, block_data:header:epoch_id::STRING as epoch_id, block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, - []::ARRAY as events, - block_data:header:gas_price::NUMBER as gas_price, + block_data:events as events, + block_data:header:gas_price::NUMBER(38,0) as gas_price, block_data:header:last_ds_final_block::STRING as last_ds_final_block, block_data:header:last_final_block::STRING as last_final_block, - block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, + block_data:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, block_data:header:next_bp_hash::STRING as next_bp_hash, block_data:header:next_epoch_id::STRING as next_epoch_id, block_data:header:outcome_root::STRING as outcome_root, block_data:header:prev_hash::STRING as prev_hash, - block_data:header:prev_height::NUMBER as prev_height, + block_data:header:prev_height::NUMBER(38,0) as prev_height, block_data:header:prev_state_root::STRING as prev_state_root, block_data:header:random_value::STRING as random_value, block_data:header:rent_paid::FLOAT as rent_paid, block_data:header:signature::STRING as signature, - block_data:header:total_supply::NUMBER as total_supply, - block_data:header:validator_proposals::ARRAY as validator_proposals, - block_data:header:validator_reward::NUMBER as validator_reward, - MD5(block_data:header:height::STRING) as fact_blocks_id, - SYSDATE() as inserted_timestamp, - SYSDATE() as modified_timestamp + block_data:header:total_supply::NUMBER(38,0) as total_supply, + block_data:header:validator_proposals as validator_proposals, + block_data:header:validator_reward::NUMBER(38,0) as validator_reward, + MD5(block_data:header:height::STRING)::VARCHAR(32) as fact_blocks_id, + SYSDATE()::TIMESTAMP_NTZ(9) as inserted_timestamp, + SYSDATE()::TIMESTAMP_NTZ(9) as modified_timestamp FROM raw_blocks -{% endmacro %} \ No newline at end of file +WHERE block_data IS NOT NULL + +{% endmacro %} diff --git a/macros/near/near_primitives.yaml.sql b/macros/near/near_primitives.yaml.sql deleted file mode 100644 index 66b0bca..0000000 --- a/macros/near/near_primitives.yaml.sql +++ /dev/null @@ -1,22 +0,0 @@ -{%- macro config_near_rpc_primitives(blockchain, network) -%} -{#- - Generates udfs that call the Near JSON RPC API - - - rpc: Executes an RPC call on the {{ blockchain }} blockchain - - -#} -{% set schema = blockchain ~ "_" ~ network -%} - -- name: {{ schema -}}.udf_rpc - signature: - - [method, STRING, RPC method to call] - - [parameters, VARIANT, Parameters to pass to the RPC method] - return_type: [VARIANT, The return value of the RPC method] - options: | - NOT NULL - RETURNS NULL ON NULL INPUT - VOLATILE - COMMENT = $$Executes an RPC call on the {{ blockchain }} blockchain.$$ - sql: | - SELECT live.udf_rpc('{{ blockchain }}', '{{ network }}', method, parameters) -{%- endmacro -%} \ No newline at end of file diff --git a/models/deploy/near/near__mainnet.sql b/models/deploy/near/near__mainnet.sql index 3c4efeb..78f035d 100644 --- a/models/deploy/near/near__mainnet.sql +++ b/models/deploy/near/near__mainnet.sql @@ -1,5 +1,4 @@ {%- set configs = [ - config_near_rpc_primitives, config_near_high_level_abstractions ] -%} From a5071a6124b2f8bb076e8a5b31075a2aa93d1751 Mon Sep 17 00:00:00 2001 From: shah Date: Wed, 13 Nov 2024 15:25:42 -0800 Subject: [PATCH 07/18] STREAM-1089 Remove poc models --- models/deploy/near/near__fact_blocks_poc.sql | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 models/deploy/near/near__fact_blocks_poc.sql diff --git a/models/deploy/near/near__fact_blocks_poc.sql b/models/deploy/near/near__fact_blocks_poc.sql deleted file mode 100644 index 9e1d6c0..0000000 --- a/models/deploy/near/near__fact_blocks_poc.sql +++ /dev/null @@ -1,11 +0,0 @@ -{{ config( - materialized = 'view', - secure = false -) }} - -SELECT * - -FROM - {# {{ ref("near-models","core__fact_blocks")}} #} - table(generator(rowcount => 10)) -LIMIT 10 \ No newline at end of file From ec074cb9c737d5d3caea74491a0fce64ebcb8186 Mon Sep 17 00:00:00 2001 From: shah Date: Wed, 13 Nov 2024 22:04:50 -0800 Subject: [PATCH 08/18] add docstrings to macros and fix UDTF comments --- macros/near/near.yaml.sql | 6 +- macros/near/near_live_views.sql | 144 +++++++++++++++++++++----------- 2 files changed, 96 insertions(+), 54 deletions(-) diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 94690c1..742a295 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -6,7 +6,7 @@ {% set schema = blockchain ~ "_" ~ network %} - name: {{ schema -}}.tf_get_block_data signature: - - [url_block_pairs, ARRAY, The stage file to that contains the block data to retrieve] + - [file_urls, ARRAY, List of stage file URLs created using BUILD_SCOPED_FILE_URL() snowflake internal function] return_type: - "TABLE(block_data VARIANT)" options: | @@ -14,9 +14,7 @@ RUNTIME_VERSION = '3.11' PACKAGES = ('snowflake-snowpark-python') HANDLER = 'GetBlockData' - COMMENT = $$A UDTF to retrieve NEAR block data from the Near Lake Snowflake External Stage. url_block_pairs (list): A list of objects, each containing: - - url (str): The stage file URL created using BUILD_SCOPED_FILE_URL - - block_height (int): The corresponding block height for the file$$ + COMMENT = $$A UDTF to retrieve NEAR block data stored in files from the Near Lake Snowflake External Stage.$$ sql: | {{ near_live_view_get_block_data() | indent(4) -}} diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 4f7dfb8..198ce79 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -1,5 +1,16 @@ -- Get Near Chain Head -{% macro near_live_view_latest_block_height(schema, blockchain, network) %} +{% macro near_live_view_latest_block_height() %} +{# + This macro retrieves the latest block height from the NEAR blockchain. + + Args: + schema (str): The schema name. + blockchain (str): The blockchain name. + network (str): The network name. + + Returns: + SQL query: A query that selects the latest block +#} SELECT live.udf_api( 'https://rpc.mainnet.near.org', @@ -27,20 +38,16 @@ SELECT class GetBlockData: """ - A class to retrieve and process multiple NEAR blockchain block data files in bulk from Snowflake External Stage. - - This class serves as a handler for a Snowflake User-Defined Table Function (UDTF) - that reads JSON block data from multiple stage files and yields the block data as a - VARIANT column. The block height and other data can be extracted from the block_data directly. + A class to retrieve NEAR block data in bulk from files stored in the Near Lake Snowflake External Stage. - Attributes: - None + The `process()` method is the handler for a Snowflake User-Defined Table Function (UDTF) + that reads JSON Near block data and yields the block data. Example: - To use this function in Snowflake: + To use this function in Snowflake, query the UDTF as follows: ```sql SELECT * - FROM TABLE(get_block_data_bulk(ARRAY_CONSTRUCT( + FROM TABLE(get_block_data(ARRAY_CONSTRUCT( BUILD_SCOPED_FILE_URL(@stage_name, '000132121137/block.json'), BUILD_SCOPED_FILE_URL(@stage_name, '000132121138/block.json') ))); @@ -53,15 +60,15 @@ SELECT Args: file_urls (list): A list of stage file URLs created using BUILD_SCOPED_FILE_URL + https://docs.snowflake.com/en/sql-reference/functions/build_scoped_file_url Yields: Iterator[Tuple[dict]]: A series of single-element tuples, each containing the complete block data structure or an error object Note: - - Files must contain valid NEAR blockchain block data in JSON format - - If a file fails to process, an error object is returned instead of skipping - - The resulting block_data column can be queried using standard SQL JSON path notation + - Files must contain valid JSON + - If a file fails to process, an error object is returned instead of the file contents """ for file_url in file_urls: try: @@ -70,21 +77,33 @@ SELECT yield (block_data,) except json.JSONDecodeError as e: error_info = { - 'error': 'JSONDecodeError', + '_error': 'JSONDecodeError', 'details': f'Invalid JSON data: {str(e)}', 'url': file_url } yield (error_info,) except Exception as e: error_info = { - 'error': e.__class__.__name__, + '_error': e.__class__.__name__, 'details': str(e), 'url': file_url } yield (error_info,) {% endmacro %} -{% macro near_live_view_get_spine(schema, blockchain, network) %} +{% macro near_live_view_get_spine(table_name) %} +{# + This macro generates a spine table for block height ranges, it creates a sequence of block heights between `min_height` and `max_height`using + Snowflake's generator function. + + Args: + table_name (str): Reference to a CTE or table that contains: + - block_id: Starting block height + - min_height: Minimum block height to generate + - max_height: Maximum block height to generate + - latest_block_height: Current chain head block height + +#} SELECT row_number() over (order by null) - 1 + COALESCE(block_id, 0)::integer as block_height, min_height, @@ -92,51 +111,76 @@ SELECT latest_block_height FROM table(generator(ROWCOUNT => 1000)), - heights + {{ table_name }} QUALIFY block_height BETWEEN min_height AND max_height {% endmacro %} --- Get near blocks -{% macro near_live_view_get_raw_blocks(schema, blockchain, network, table_name) %} -SELECT - block_height, - live.udf_api( - 'https://rpc.mainnet.near.org', - utils.udf_json_rpc_call( - 'block', - {'block_id': block_height} - ) - ):data.result AS block_data -from - {{ table_name }} +{% macro near_live_view_get_raw_block_data(spine_table, schema) %} + {# + This macro generates SQL that retrieves raw block data from the Near Lake data stored in Snowflake external stage. + + It constructs URLs for block data files and uses a table function to fetch and parse the JSON data. + + The macro performs two main operations: + + 1. Generates scoped file URLs for each block height using the Near Lake file naming convention + 2. Calls the tf_get_block_data function to fetch and parse the block JSON data + + Args: + spine_table (str): Reference to a CTE or table containing: + - block_height (INTEGER): The block heights to fetch data for + + Returns: + str: A SQL query that returns a table with columns: + - block_height (INTEGER): The height of the block + - block_data (VARIANT): The parsed JSON data for the block + + Note: + - Requires access to '@streamline.bronze.near_lake_data_mainnet' stage + - Block files must follow the format: XXXXXXXXXXXX/block.json where X is the zero-padded block height + - Uses the tf_get_block_data table function to parse JSON data +#} + +WITH block_urls AS ( + SELECT + s.block_height, + ARRAY_AGG( + BUILD_SCOPED_FILE_URL( + '@streamline.bronze.near_lake_data_mainnet', + CONCAT(LPAD(TO_VARCHAR(s.block_height), 12, '0'), '/block.json') + ) + ) OVER () as urls + FROM {{ spine_table }} s +) +SELECT + u.block_height, + b.block_data +FROM block_urls u, + TABLE({{ schema }}.tf_get_block_data(u.urls)) b {% endmacro %} -- Get Near fact data {% macro near_live_view_fact_blocks(schema, blockchain, network) %} +{# + This macro generates a SQL query to fetch and transform NEAR blockchain block data. + + The macro creates a series of CTEs to: + 1. Get the latest block height using near_live_view_latest_block_height + 2. Generate a spine table for block range using near_live_view_get_spine + 3. Fetch block data from Near Lake using tf_get_block_data + 4. Transform the raw block data into a structured format reflecting the near.core.fact_blocks table + +#} + WITH heights AS ( - {{ near_live_view_latest_block_height(schema, blockchain, network) }} + {{ near_live_view_latest_block_height() | indent(4) }} ), spine AS ( - {{ near_live_view_get_spine(schema, blockchain, network) }} + {{ near_live_view_get_spine('heights') | indent(4) }} ), raw_blocks AS ( - WITH block_urls AS ( - SELECT - s.block_height, - ARRAY_AGG( - BUILD_SCOPED_FILE_URL( - '@streamline.bronze.near_lake_data_mainnet', - CONCAT(LPAD(TO_VARCHAR(s.block_height), 12, '0'), '/block.json') - ) - ) OVER () as urls - FROM spine s - ) - SELECT - u.block_height, - b.block_data - FROM block_urls u, - TABLE({{ schema -}}.tf_get_block_data(u.urls)) b + {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} ) SELECT block_data:header:height::NUMBER(38,0) as block_id, @@ -145,11 +189,11 @@ SELECT ARRAY_SIZE(block_data:chunks)::STRING as tx_count, block_data:author::STRING as block_author, block_data:header as header, - block_data:header:challenges_result as block_challenges_result, -- Removed ::ARRAY cast + block_data:header:challenges_result as block_challenges_result, block_data:header:challenges_root::STRING as block_challenges_root, block_data:header:chunk_headers_root::STRING as chunk_headers_root, block_data:header:chunk_tx_root::STRING as chunk_tx_root, - block_data:header:chunk_mask as chunk_mask, -- Removed ::ARRAY cast + block_data:header:chunk_mask as chunk_mask, block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, block_data:chunks as chunks, block_data:header:chunks_included::NUMBER(38,0) as chunks_included, From a66e574ab44d2b7717393eebafc4925e0c43de8e Mon Sep 17 00:00:00 2001 From: shah Date: Thu, 14 Nov 2024 15:49:15 -0800 Subject: [PATCH 09/18] add multi threading to get_block_data --- macros/near/near.yaml.sql | 1 + macros/near/near_live_views.sql | 119 ++++++++++++++++++++------------ 2 files changed, 76 insertions(+), 44 deletions(-) diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 742a295..f4cab34 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -4,6 +4,7 @@ blockchain. #} {% set schema = blockchain ~ "_" ~ network %} + - name: {{ schema -}}.tf_get_block_data signature: - [file_urls, ARRAY, List of stage file URLs created using BUILD_SCOPED_FILE_URL() snowflake internal function] diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 198ce79..4fbd008 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -35,60 +35,91 @@ SELECT import json from typing import Iterator, Tuple from snowflake.snowpark.files import SnowflakeFile + import multiprocessing as mp + from queue import Queue + from threading import Thread class GetBlockData: """ - A class to retrieve NEAR block data in bulk from files stored in the Near Lake Snowflake External Stage. - - The `process()` method is the handler for a Snowflake User-Defined Table Function (UDTF) - that reads JSON Near block data and yields the block data. - - Example: - To use this function in Snowflake, query the UDTF as follows: - ```sql - SELECT * - FROM TABLE(get_block_data(ARRAY_CONSTRUCT( - BUILD_SCOPED_FILE_URL(@stage_name, '000132121137/block.json'), - BUILD_SCOPED_FILE_URL(@stage_name, '000132121138/block.json') - ))); - ``` + A class to retrieve and process multiple NEAR blockchain block data files from Snowflake External Stage. + Uses threading from standard library for concurrent processing. + + The implementation uses a thread pool pattern with a work queue for better resource management + and controlled concurrency. """ + + def __init__(self): + self.num_workers = min(10, mp.cpu_count() * 2) # Number of worker threads + self.chunk_size = 50 # Process files in chunks + + def _process_file(self, file_url: str) -> Tuple[dict]: + """Process a single file from the stage.""" + try: + with SnowflakeFile.open(file_url) as file: + block_data = json.load(file) + return (block_data,) + except json.JSONDecodeError as e: + return ({ + 'error': 'JSONDecodeError', + 'details': f'Invalid JSON data: {str(e)}', + 'url': file_url + },) + except Exception as e: + return ({ + 'error': e.__class__.__name__, + 'details': str(e), + 'url': file_url + },) + + def _worker(self, queue: Queue, results: list): + """Worker thread to process files from the queue.""" + while True: + file_url = queue.get() + if file_url is None: # Poison pill + break + result = self._process_file(file_url) + results.append(result) + queue.task_done() def process(self, file_urls: list) -> Iterator[Tuple[dict]]: """ - Process multiple block data files from specified stage file URLs. - + Process multiple block data files using a thread pool. + Args: - file_urls (list): A list of stage file URLs created using BUILD_SCOPED_FILE_URL - https://docs.snowflake.com/en/sql-reference/functions/build_scoped_file_url - + file_urls (list): List of stage file URLs to process + Yields: - Iterator[Tuple[dict]]: A series of single-element tuples, each containing - the complete block data structure or an error object - - Note: - - Files must contain valid JSON - - If a file fails to process, an error object is returned instead of the file contents + Iterator[Tuple[dict]]: Processed block data or error information """ - for file_url in file_urls: - try: - with SnowflakeFile.open(file_url) as file: - block_data = json.load(file) - yield (block_data,) - except json.JSONDecodeError as e: - error_info = { - '_error': 'JSONDecodeError', - 'details': f'Invalid JSON data: {str(e)}', - 'url': file_url - } - yield (error_info,) - except Exception as e: - error_info = { - '_error': e.__class__.__name__, - 'details': str(e), - 'url': file_url - } - yield (error_info,) + # Process files in chunks to manage memory + for i in range(0, len(file_urls), self.chunk_size): + chunk = file_urls[i:i + self.chunk_size] + + # Set up the thread pool + queue = Queue() + results = [] + threads = [] + + # Start worker threads + for _ in range(self.num_workers): + t = Thread(target=self._worker, args=(queue, results)) + t.start() + threads.append(t) + + # Add work to the queue + for url in chunk: + queue.put(url) + + # Add poison pills to stop workers + for _ in range(self.num_workers): + queue.put(None) + + # Wait for all work to complete + for t in threads: + t.join() + + # Yield results + yield from results {% endmacro %} {% macro near_live_view_get_spine(table_name) %} From 566e948c055eaef2998b80de70c9549ac46e2297 Mon Sep 17 00:00:00 2001 From: shah Date: Thu, 14 Nov 2024 16:26:13 -0800 Subject: [PATCH 10/18] remmove row() from arrayagg in raw_blocks --- macros/near/near_live_views.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 4fbd008..9466e6a 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -41,7 +41,7 @@ SELECT class GetBlockData: """ - A class to retrieve and process multiple NEAR blockchain block data files from Snowflake External Stage. + A class to retrieve and process multiple NEAR block data files from a Snowflake External Stage. Uses threading from standard library for concurrent processing. The implementation uses a thread pool pattern with a work queue for better resource management @@ -181,8 +181,9 @@ WITH block_urls AS ( '@streamline.bronze.near_lake_data_mainnet', CONCAT(LPAD(TO_VARCHAR(s.block_height), 12, '0'), '/block.json') ) - ) OVER () as urls + ) as urls FROM {{ spine_table }} s + GROUP BY s.block_height ) SELECT u.block_height, From 22766fd559bd602dc1fbf643c131a8dc286dadac Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 18 Nov 2024 16:10:45 -0800 Subject: [PATCH 11/18] STREAM-1094/add_udf_get_block_data --- macros/near/near.yaml.sql | 14 +++++++++++++ macros/near/near_live_views.sql | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index f4cab34..76c990b 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -5,6 +5,20 @@ #} {% set schema = blockchain ~ "_" ~ network %} +- name: {{ schema -}}.udf_get_block_data + signature: + - [file_url, STRING, File URL created using BUILD_SCOPED_FILE_URL() snowflake internal function] + return_type: + - VARIANT + options: | + LANGUAGE PYTHON + RUNTIME_VERSION = '3.11' + PACKAGES = ('snowflake-snowpark-python') + HANDLER = 'process_file' + COMMENT = $$A UDF to retrieve NEAR block data stored in files from the Near Lake Snowflake External Stage.$$ + sql: | + {{ near_live_view_udf_get_block_data() | indent(4) -}} + - name: {{ schema -}}.tf_get_block_data signature: - [file_urls, ARRAY, List of stage file URLs created using BUILD_SCOPED_FILE_URL() snowflake internal function] diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index 9466e6a..e23c3dc 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -122,6 +122,41 @@ SELECT yield from results {% endmacro %} +{% macro near_live_view_udf_get_block_data() %} + import json + from snowflake.snowpark.files import SnowflakeFile + + def process_file(file_url: str) -> dict: + """ + Process a single block data file from specified stage file URL. + + Args: + file_url (str): The stage file URL created using BUILD_SCOPED_FILE_URL + + Returns: + dict: The block data or error information + + Note: + - File must contain valid NEAR blockchain block data in JSON format + - If file fails to process, an error object is returned + """ + try: + with SnowflakeFile.open(file_url) as file: + return json.load(file) + except json.JSONDecodeError as e: + return { + 'error': 'JSONDecodeError', + 'details': f'Invalid JSON data: {str(e)}', + 'url': file_url + } + except Exception as e: + return { + 'error': e.__class__.__name__, + 'details': str(e), + 'url': file_url + } +{% endmacro %} + {% macro near_live_view_get_spine(table_name) %} {# This macro generates a spine table for block height ranges, it creates a sequence of block heights between `min_height` and `max_height`using From 8fd3547aacb390a29aecb99cb28d532b7f18c1b1 Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 18 Nov 2024 18:38:00 -0800 Subject: [PATCH 12/18] STREAM-1108 near-models import and compile success | Update -> dbt v1.7.0 to compile near-models | Remove fsc_utils deps from upstream near-models --- dbt_project.yml | 4 ++++ packages.yml | 2 ++ requirements.txt | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dbt_project.yml b/dbt_project.yml index 2946a8f..15255bc 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -36,6 +36,10 @@ models: +tags: evm marketplace: +tags: marketplace + near_models: + gold: + core: + +materialized: ephemeral tests: +store_failures: true # all tests diff --git a/packages.yml b/packages.yml index ee9544f..630d263 100644 --- a/packages.yml +++ b/packages.yml @@ -3,3 +3,5 @@ packages: version: [">=0.8.0", "<0.9.0"] - package: dbt-labs/dbt_utils version: [">=1.0.0", "<1.1.0"] + - git: "https://github.com/FlipsideCrypto/near-models-nlq.git" + revision: STREAM-1108/strip-lq-deps \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ff8e7ca..964ac6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -dbt-snowflake~=1.5.0 \ No newline at end of file +dbt-snowflake~=1.7.0 \ No newline at end of file From 6c819a968806a330b635d0a78d3315f35aa8685e Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 22 Nov 2024 01:43:25 -0800 Subject: [PATCH 13/18] STREAM-1089: add near_models.core_fact_blocks view | reuse near_models.core.fact_blocks in UDTF | fix UPDATE_UDF_AND_SPS issue --- Makefile | 8 +- README.md | 8 +- dbt_project.yml | 24 +- docs/manifest.json | 14345 +++++++++++++++- macros/create_sps.sql | 2 +- macros/livequery/manage_udfs.sql | 6 +- macros/near/near.yaml.sql | 16 +- macros/near/near_live_views.sql | 158 +- models/deploy/near/near__mainnet.sql | 1 + .../near_mainnet__fact_blocks_poc.sql | 6 + .../integration/__overview__.md | 4 +- models/sources.yml | 7 +- package-lock.yml | 12 + 13 files changed, 14539 insertions(+), 58 deletions(-) create mode 100644 models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql create mode 100644 package-lock.yml diff --git a/Makefile b/Makefile index bd090f1..59bcc73 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ rm_logs: deploy_near_mainnet_lv: rm_logs dbt run \ -s livequery_models.deploy.near.near__mainnet \ - --vars '{UPDATE_UDFS_AND_SPS: true}' \ + --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ --target dev @@ -24,8 +24,8 @@ compile_near_mainnet: rm_logs deploy_fact_blocks_poc: rm_logs dbt run \ - -s livequery_models.deploy.near.near__fact_blocks_poc \ - --vars '{UPDATE_UDFS_AND_SPS: true}' \ + -s livequery_models.deploy.near.silver.streamline.near_mainnet__fact_blocks_poc \ + --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ - --target dev + --target dev \ No newline at end of file diff --git a/README.md b/README.md index 4e64cd9..6306ed4 100644 --- a/README.md +++ b/README.md @@ -462,20 +462,20 @@ livequery: To control the creation of UDF or SP macros with dbt run: -* UPDATE_UDFS_AND_SPS +* LQ_UPDATE_UDFS_AND_SPS When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal When False, none of the on-run-start macros are executed on model run Default values are False * Usage: -`dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...` +`dbt run --var '{"LQ_UPDATE_UDFS_AND_SPS":True}' -m ...` Dropping and creating udfs can also be done without running a model: ```sh -dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' -dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' +dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' +dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' ``` ## Resources diff --git a/dbt_project.yml b/dbt_project.yml index 15255bc..12541e7 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -36,10 +36,22 @@ models: +tags: evm marketplace: +tags: marketplace + near: + silver: + streamline: + +schema: near_mainnet + +enabled: true near_models: - gold: - core: - +materialized: ephemeral + +schema: streamline + +database: near_dev + gold: + core: + +schema: core + +materialized: ephemeral + silver: + streamline: + silver__streamline_blocks: + +enabled: true # set to false if you need to override the models tests: +store_failures: true # all tests @@ -64,8 +76,12 @@ on-run-end: # using the `{{ config(...) }}` macro. vars: + + near_models: + UPDATE_UDFS_AND_SPS: false + "dbt_date:time_zone": GMT - UPDATE_UDFS_AND_SPS: false + LQ_UPDATE_UDFS_AND_SPS: false DROP_UDFS_AND_SPS: false UPDATE_SNOWFLAKE_TAGS: true STREAMLINE_INVOKE_STREAMS: False diff --git a/docs/manifest.json b/docs/manifest.json index b2fe7f3..346af5b 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1 +1,14344 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v7.json", "dbt_version": "1.3.2", "generated_at": "2023-02-09T14:53:51.874744Z", "invocation_id": "6aac413a-cd1e-4019-821c-a9938f6c1fc3", "env": {}, "project_id": "77aec67e40364978dc5eae24f2b474a3", "user_id": null, "send_anonymous_usage_stats": false, "adapter_type": "snowflake"}, "nodes": {"operation.livequery_models.livequery_models-on-run-start-0": {"compiled": true, "resource_type": "operation", "depends_on": {"macros": ["macro.livequery_models.create_sps"], "nodes": []}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "post-hook": [], "pre-hook": []}, "database": "LIVEQUERY_DEV", "schema": "livequery_models-on-run-start-0", "fqn": ["livequery_models", "hooks", "livequery_models-on-run-start-0"], "unique_id": "operation.livequery_models.livequery_models-on-run-start-0", "raw_code": "{{ create_sps() }}", "language": "sql", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "hooks/livequery_models-on-run-start-0.sql", "original_file_path": "./dbt_project.yml", "name": "livequery_models-on-run-start-0", "alias": "", "checksum": {"name": "sha256", "checksum": "db3ddf0272fd42cc1729433ba48aeef486b0bd492a03df34f2d269afa12a1e94"}, "tags": ["on-run-start"], "refs": [], "sources": [], "metrics": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "compiled_path": "target/compiled/livequery_models/./dbt_project.yml/hooks/livequery_models-on-run-start-0.sql", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1675954222.8728378, "compiled_code": "\n \n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "index": 0}, "operation.livequery_models.livequery_models-on-run-end-0": {"compiled": true, "resource_type": "operation", "depends_on": {"macros": ["macro.livequery_models.apply_meta_as_tags"], "nodes": []}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "post-hook": [], "pre-hook": []}, "database": "LIVEQUERY_DEV", "schema": "livequery_models-on-run-end-0", "fqn": ["livequery_models", "hooks", "livequery_models-on-run-end-0"], "unique_id": "operation.livequery_models.livequery_models-on-run-end-0", "raw_code": "{{ apply_meta_as_tags(results) }}", "language": "sql", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "hooks/livequery_models-on-run-end-0.sql", "original_file_path": "./dbt_project.yml", "name": "livequery_models-on-run-end-0", "alias": "", "checksum": {"name": "sha256", "checksum": "db3ddf0272fd42cc1729433ba48aeef486b0bd492a03df34f2d269afa12a1e94"}, "tags": ["on-run-end"], "refs": [], "sources": [], "metrics": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "compiled_path": "target/compiled/livequery_models/./dbt_project.yml/hooks/livequery_models-on-run-end-0.sql", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1675954222.8786502, "compiled_code": "\n \n \n \n \n \n \n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "index": 0}}, "sources": {"source.livequery_models.crosschain.dim_date_hours": {"fqn": ["livequery_models", "crosschain", "dim_date_hours"], "database": "crosschain_dev", "schema": "core", "unique_id": "source.livequery_models.crosschain.dim_date_hours", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "models/sources.yml", "original_file_path": "models/sources.yml", "name": "dim_date_hours", "source_name": "crosschain", "source_description": "", "loader": "", "identifier": "dim_date_hours", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "", "columns": {}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "crosschain_dev.core.dim_date_hours", "created_at": 1675954222.9114618}}, "macros": {"macro.livequery_models.create_sps": {"unique_id": "macro.livequery_models.create_sps", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/create_sps.sql", "original_file_path": "macros/create_sps.sql", "name": "create_sps", "macro_sql": "{% macro create_sps() %}\n {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.livequery_models.sp_create_prod_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.18193, "supported_languages": null}, "macro.livequery_models.generate_schema_name": {"unique_id": "macro.livequery_models.generate_schema_name", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/custom_naming_macros.sql", "original_file_path": "macros/custom_naming_macros.sql", "name": "generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {% set node_name = node.name %}\n {% set split_name = node_name.split('__') %}\n {{ split_name[0] | trim }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.1824331, "supported_languages": null}, "macro.livequery_models.generate_alias_name": {"unique_id": "macro.livequery_models.generate_alias_name", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/custom_naming_macros.sql", "original_file_path": "macros/custom_naming_macros.sql", "name": "generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% set node_name = node.name %}\n {% set split_name = node_name.split('__') %}\n {{ split_name[1] | trim }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.1826959, "supported_languages": null}, "macro.livequery_models.run_sp_create_prod_clone": {"unique_id": "macro.livequery_models.run_sp_create_prod_clone", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/run_sp_create_prod_clone.sql", "original_file_path": "macros/run_sp_create_prod_clone.sql", "name": "run_sp_create_prod_clone", "macro_sql": "{% macro run_sp_create_prod_clone() %}\n {% set clone_query %}\n call livequery._internal.create_prod_clone(\n 'livequery',\n 'livequery_dev',\n 'livequery_dev_owner'\n );\n{% endset %}\n {% do run_query(clone_query) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.1829991, "supported_languages": null}, "macro.livequery_models.create_udfs": {"unique_id": "macro.livequery_models.create_udfs", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/create_udfs.sql", "original_file_path": "macros/create_udfs.sql", "name": "create_udfs", "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.1833768, "supported_languages": null}, "macro.livequery_models.set_query_tag": {"unique_id": "macro.livequery_models.set_query_tag", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/custom_query_tag.sql", "original_file_path": "macros/custom_query_tag.sql", "name": "set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {% set new_json = {\"repo\":project_name, \"object\":this.table, \"profile\":target.profile_name, \"env\":target.name, \"existing_tag\":get_current_query_tag() } %}\n{% set new_query_tag = tojson(new_json) | as_text %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.184247, "supported_languages": null}, "macro.livequery_models.sp_create_prod_clone": {"unique_id": "macro.livequery_models.sp_create_prod_clone", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/sp_create_prod_clone.sql", "original_file_path": "macros/sp_create_prod_clone.sql", "name": "sp_create_prod_clone", "macro_sql": "{% macro sp_create_prod_clone(target_schema) -%}\n\ncreate or replace procedure {{ target_schema }}.create_prod_clone(source_db_name string, destination_db_name string, role_name string)\nreturns boolean \nlanguage javascript\nexecute as caller\nas\n$$\n snowflake.execute({sqlText: `BEGIN TRANSACTION;`});\n try {\n snowflake.execute({sqlText: `CREATE OR REPLACE DATABASE ${DESTINATION_DB_NAME} CLONE ${SOURCE_DB_NAME}`});\n snowflake.execute({sqlText: `DROP SCHEMA IF EXISTS ${DESTINATION_DB_NAME}._INTERNAL`}); /* this only needs to be in prod */\n\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL SCHEMAS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`})\n\n var existing_tags = snowflake.execute({sqlText: `SHOW TAGS IN DATABASE ${DESTINATION_DB_NAME};`});\n while (existing_tags.next()) {\n var schema = existing_tags.getColumnValue(4);\n var tag_name = existing_tags.getColumnValue(2)\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON TAG ${DESTINATION_DB_NAME}.${schema}.${tag_name} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});\n }\n\n snowflake.execute({sqlText: `COMMIT;`});\n } catch (err) {\n snowflake.execute({sqlText: `ROLLBACK;`});\n throw(err);\n }\n\n return true\n$$\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.184911, "supported_languages": null}, "macro.livequery_models.add_database_or_schema_tags": {"unique_id": "macro.livequery_models.add_database_or_schema_tags", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/add_database_or_schema_tags.sql", "original_file_path": "macros/tags/add_database_or_schema_tags.sql", "name": "add_database_or_schema_tags", "macro_sql": "{% macro add_database_or_schema_tags() %}\n {{ set_database_tag_value('BLOCKCHAIN_NAME','LIVEQUERY') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.livequery_models.set_database_tag_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.18513, "supported_languages": null}, "macro.livequery_models.apply_meta_as_tags": {"unique_id": "macro.livequery_models.apply_meta_as_tags", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "apply_meta_as_tags", "macro_sql": "{% macro apply_meta_as_tags(results) %}\n {% if var(\"UPDATE_SNOWFLAKE_TAGS\") %}\n {{ log('apply_meta_as_tags', info=False) }}\n {{ log(results, info=False) }}\n {% if execute %}\n\n {%- set tags_by_schema = {} -%}\n {% for res in results -%}\n {% if res.node.meta.database_tags %}\n\n {%- set model_database = res.node.database -%}\n {%- set model_schema = res.node.schema -%}\n {%- set model_schema_full = model_database+'.'+model_schema -%}\n {%- set model_alias = res.node.alias -%}\n\n {% if model_schema_full not in tags_by_schema.keys() %}\n {{ log('need to fetch tags for schema '+model_schema_full, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n show tags in {{model_database}}.{{model_schema}}\n {%- endcall -%}\n {%- set _ = tags_by_schema.update({model_schema_full: load_result('main')['table'].columns.get('name').values()|list}) -%}\n {{ log('Added tags to cache', info=False) }}\n {% else %}\n {{ log('already have tag info for schema', info=False) }}\n {% endif %}\n\n {%- set current_tags_in_schema = tags_by_schema[model_schema_full] -%}\n {{ log('current_tags_in_schema:', info=False) }}\n {{ log(current_tags_in_schema, info=False) }}\n {{ log(\"========== Processing tags for \"+model_schema_full+\".\"+model_alias+\" ==========\", info=False) }}\n\n {% set line -%}\n node: {{ res.node.unique_id }}; status: {{ res.status }} (message: {{ res.message }})\n node full: {{ res.node}}\n meta: {{ res.node.meta}}\n materialized: {{ res.node.config.materialized }}\n {%- endset %}\n {{ log(line, info=False) }}\n\n {%- call statement('main', fetch_result=True) -%}\n select LEVEL,UPPER(TAG_NAME) as TAG_NAME,TAG_VALUE from table(information_schema.tag_references_all_columns('{{model_schema}}.{{model_alias}}', 'table'))\n {%- endcall -%}\n {%- set existing_tags_for_table = load_result('main')['data'] -%}\n {{ log('Existing tags for table:', info=False) }}\n {{ log(existing_tags_for_table, info=False) }}\n\n {{ log('--', info=False) }}\n {% for table_tag in res.node.meta.database_tags.table %}\n\n {{ create_tag_if_missing(current_tags_in_schema,table_tag|upper) }}\n {% set desired_tag_value = res.node.meta.database_tags.table[table_tag] %}\n\n {{set_table_tag_value_if_different(model_schema,model_alias,table_tag,desired_tag_value,existing_tags_for_table)}}\n {% endfor %}\n {{ log(\"========== Finished processing tags for \"+model_alias+\" ==========\", info=False) }}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.livequery_models.create_tag_if_missing", "macro.livequery_models.set_table_tag_value_if_different"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.196293, "supported_languages": null}, "macro.livequery_models.create_tag_if_missing": {"unique_id": "macro.livequery_models.create_tag_if_missing", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "create_tag_if_missing", "macro_sql": "{% macro create_tag_if_missing(all_tag_names,table_tag) %}\n\t{% if table_tag not in all_tag_names %}\n\t\t{{ log('Creating missing tag '+table_tag, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n create tag if not exists silver.{{table_tag}}\n {%- endcall -%}\n\t\t{{ log(load_result('main').data, info=False) }}\n\t{% else %}\n\t\t{{ log('Tag already exists: '+table_tag, info=False) }}\n\t{% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.196773, "supported_languages": null}, "macro.livequery_models.set_table_tag_value_if_different": {"unique_id": "macro.livequery_models.set_table_tag_value_if_different", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "set_table_tag_value_if_different", "macro_sql": "{% macro set_table_tag_value_if_different(model_schema,table_name,tag_name,desired_tag_value,existing_tags) %}\n {{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at table level', info=False) }}\n {%- set existing_tag_for_table = existing_tags|selectattr('0','equalto','TABLE')|selectattr('1','equalto',tag_name|upper)|list -%}\n {{ log('Filtered tags for table:', info=False) }}\n {{ log(existing_tag_for_table[0], info=False) }}\n {% if existing_tag_for_table|length > 0 and existing_tag_for_table[0][2]==desired_tag_value %}\n {{ log('Correct tag value already exists', info=False) }}\n {% else %}\n {{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n alter table {{model_schema}}.{{table_name}} set tag {{tag_name}} = '{{desired_tag_value}}'\n {%- endcall -%}\n {{ log(load_result('main').data, info=False) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.1977339, "supported_languages": null}, "macro.livequery_models.set_column_tag_value_if_different": {"unique_id": "macro.livequery_models.set_column_tag_value_if_different", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "set_column_tag_value_if_different", "macro_sql": "{% macro set_column_tag_value_if_different(table_name,column_name,tag_name,desired_tag_value,existing_tags) %}\n {{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at column level', info=False) }}\n {%- set existing_tag_for_column = existing_tags|selectattr('0','equalto','COLUMN')|selectattr('1','equalto',tag_name|upper)|list -%}\n {{ log('Filtered tags for column:', info=False) }}\n {{ log(existing_tag_for_column[0], info=False) }}\n {% if existing_tag_for_column|length > 0 and existing_tag_for_column[0][2]==desired_tag_value %}\n {{ log('Correct tag value already exists', info=False) }}\n {% else %}\n {{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n alter table {{table_name}} modify column {{column_name}} set tag {{tag_name}} = '{{desired_tag_value}}'\n {%- endcall -%}\n {{ log(load_result('main').data, info=False) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.198677, "supported_languages": null}, "macro.livequery_models.set_database_tag_value": {"unique_id": "macro.livequery_models.set_database_tag_value", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "set_database_tag_value", "macro_sql": "{% macro set_database_tag_value(tag_name,tag_value) %}\n {% set query %}\n create tag if not exists silver.{{tag_name}}\n {% endset %}\n {% do run_query(query) %}\n {% set query %}\n alter database {{target.database}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'\n {% endset %}\n {% do run_query(query) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.199031, "supported_languages": null}, "macro.livequery_models.set_schema_tag_value": {"unique_id": "macro.livequery_models.set_schema_tag_value", "package_name": "livequery_models", "root_path": "/Users/ericlaurello/git/livequery-models", "path": "macros/tags/snowflake_tagging.sql", "original_file_path": "macros/tags/snowflake_tagging.sql", "name": "set_schema_tag_value", "macro_sql": "{% macro set_schema_tag_value(target_schema,tag_name,tag_value) %}\n {% set query %}\n create tag if not exists silver.{{tag_name}}\n {% endset %}\n {% do run_query(query) %}\n {% set query %}\n alter schema {{target.database}}.{{target_schema}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'\n {% endset %}\n {% do run_query(query) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.199394, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog": {"unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "name": "snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n {% set query %}\n with tables as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n table_type as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n\n from {{ information_schema }}.tables\n\n ),\n\n columns as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n\n from {{ information_schema }}.columns\n )\n\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n where (\n {%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by \"column_index\"\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.200282, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_table_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- if language == 'sql' -%}\n {%- set transient = config.get('transient', default=true) -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {% if temporary -%}\n temporary\n {%- elif transient -%}\n transient\n {%- endif %} table {{ relation }} {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from(\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, temporary=temporary) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.py_write_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2121012, "supported_languages": null}, "macro.dbt_snowflake.get_column_comment_sql": {"unique_id": "macro.dbt_snowflake.get_column_comment_sql", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_column_comment_sql", "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.212733, "supported_languages": null}, "macro.dbt_snowflake.get_persist_docs_column_list": {"unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_persist_docs_column_list", "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2129862, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt_snowflake.get_persist_docs_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.213637, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.214319, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_schemas": {"unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2148092, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation) %}\n {%- set sql -%}\n show terse objects in {{ schema_relation }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in schema {{ schema_relation }}! dbt can only get\n information about schemas with fewer than {{ maximum }} objects.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {%- do return(result) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2152488, "supported_languages": null}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.215531, "supported_languages": null}, "macro.dbt_snowflake.snowflake__rename_relation": {"unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.215701, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_type": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.215924, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n comment on {{ relation.type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2161112, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n alter {{ relation.type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.216565, "supported_languages": null}, "macro.dbt_snowflake.get_current_query_tag": {"unique_id": "macro.dbt_snowflake.get_current_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.21673, "supported_languages": null}, "macro.dbt_snowflake.set_query_tag": {"unique_id": "macro.dbt_snowflake.set_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__set_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.216872, "supported_languages": null}, "macro.dbt_snowflake.snowflake__set_query_tag": {"unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__set_query_tag", "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.217592, "supported_languages": null}, "macro.dbt_snowflake.unset_query_tag": {"unique_id": "macro.dbt_snowflake.unset_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.217758, "supported_languages": null}, "macro.dbt_snowflake.snowflake__unset_query_tag": {"unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__unset_query_tag", "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.218187, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": {"unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_relation_add_remove_columns", "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.218845, "supported_languages": null}, "macro.dbt_snowflake.snowflake_dml_explicit_transaction": {"unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake_dml_explicit_transaction", "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2190359, "supported_languages": null}, "macro.dbt_snowflake.snowflake__truncate_relation": {"unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__truncate_relation", "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.219248, "supported_languages": null}, "macro.dbt_snowflake.snowflake__copy_grants": {"unique_id": "macro.dbt_snowflake.snowflake__copy_grants", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "name": "snowflake__copy_grants", "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.219574, "supported_languages": null}, "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "name": "snowflake__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.219674, "supported_languages": null}, "macro.dbt_snowflake.materialization_test_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_test_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/test.sql", "original_file_path": "macros/materializations/test.sql", "name": "materialization_test_snowflake", "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_test_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.220047, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.default__get_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.221177, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__get_delete_insert_merge_sql", "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.221427, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__snapshot_merge_sql", "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.221656, "supported_languages": null}, "macro.dbt_snowflake.snowflake__load_csv_rows": {"unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "name": "snowflake__load_csv_rows", "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.223575, "supported_languages": null}, "macro.dbt_snowflake.materialization_seed_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "name": "materialization_seed_snowflake", "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_seed_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.223907, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_view_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "name": "materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do return(to_return) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.create_or_replace_view", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2244601, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_table_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.22664, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.py_write_table": {"unique_id": "macro.dbt_snowflake.py_write_table", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "py_write_table", "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False) %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n df.write.mode(\"overwrite\").save_as_table(\"{{ target_relation }}\", create_temp_table={{temporary}})\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.226835, "supported_languages": null}, "macro.dbt_snowflake.py_script_comment": {"unique_id": "macro.dbt_snowflake.py_script_comment", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.22693, "supported_languages": null}, "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": {"unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "dbt_snowflake_get_tmp_relation_type", "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n\n /* {#\n If we are running multiple statements (DELETE + INSERT),\n we must first save the model query results as a temporary table\n in order to guarantee consistent inputs to both statements.\n\n If we are running a single statement (MERGE or INSERT alone),\n we can save the model query definition as a view instead,\n for faster overall incremental processing.\n #} */\n\n {% if language == 'sql' and (strategy in ('default', 'append', 'merge') or (unique_key is none)) %}\n {{ return('view') }}\n {% else %} {#-- play it safe -- #}\n {{ return('table') }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.228244, "supported_languages": null}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ create_view_as(tmp_relation, compiled_code) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.should_full_refresh", "macro.dbt.load_relation", "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro.dbt.make_temp_relation", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.create_view_as", "macro.dbt.process_schema_changes", "macro.dbt.drop_relation_if_exists", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.231225, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.snowflake__get_incremental_default_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "snowflake__get_incremental_default_sql", "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2313778, "supported_languages": null}, "macro.dbt_snowflake.materialization_snapshot_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "name": "materialization_snapshot_snowflake", "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_snapshot_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.231769, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__current_timestamp": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.232095, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2322528, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.232351, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2324429, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro.dbt_expectations.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2325609, "supported_languages": null}, "macro.dbt_snowflake.snowflake__escape_single_quotes": {"unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "snowflake__escape_single_quotes", "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2327921, "supported_languages": null}, "macro.dbt_snowflake.snowflake__right": {"unique_id": "macro.dbt_snowflake.snowflake__right", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.233056, "supported_languages": null}, "macro.dbt_snowflake.snowflake__safe_cast": {"unique_id": "macro.dbt_snowflake.snowflake__safe_cast", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.233263, "supported_languages": null}, "macro.dbt_snowflake.snowflake__bool_or": {"unique_id": "macro.dbt_snowflake.snowflake__bool_or", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "snowflake__bool_or", "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2334368, "supported_languages": null}, "macro.dbt_snowflake.snowflake__array_construct": {"unique_id": "macro.dbt_snowflake.snowflake__array_construct", "package_name": "dbt_snowflake", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "snowflake__array_construct", "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2336488, "supported_languages": null}, "macro.dbt.run_hooks": {"unique_id": "macro.dbt.run_hooks", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.234656, "supported_languages": null}, "macro.dbt.make_hook_config": {"unique_id": "macro.dbt.make_hook_config", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.234829, "supported_languages": null}, "macro.dbt.before_begin": {"unique_id": "macro.dbt.before_begin", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2349591, "supported_languages": null}, "macro.dbt.in_transaction": {"unique_id": "macro.dbt.in_transaction", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.235083, "supported_languages": null}, "macro.dbt.after_commit": {"unique_id": "macro.dbt.after_commit", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2352068, "supported_languages": null}, "macro.dbt.set_sql_header": {"unique_id": "macro.dbt.set_sql_header", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.235591, "supported_languages": null}, "macro.dbt.should_full_refresh": {"unique_id": "macro.dbt.should_full_refresh", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.23592, "supported_languages": null}, "macro.dbt.should_store_failures": {"unique_id": "macro.dbt.should_store_failures", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.236209, "supported_languages": null}, "macro.dbt.snapshot_merge_sql": {"unique_id": "macro.dbt.snapshot_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "name": "snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2366662, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"unique_id": "macro.dbt.default__snapshot_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "name": "default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2369049, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"unique_id": "macro.dbt.strategy_dispatch", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.239976, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"unique_id": "macro.dbt.snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.240125, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"unique_id": "macro.dbt.default__snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.240319, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"unique_id": "macro.dbt.snapshot_timestamp_strategy", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.240957, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"unique_id": "macro.dbt.snapshot_string_as_time", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2411032, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"unique_id": "macro.dbt.default__snapshot_string_as_time", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.241257, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n select {{ check_cols_config | join(', ') }} from ({{ node['compiled_code'] }}) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.242493, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"unique_id": "macro.dbt.snapshot_check_strategy", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2437189, "supported_languages": null}, "macro.dbt.create_columns": {"unique_id": "macro.dbt.create_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2471738, "supported_languages": null}, "macro.dbt.default__create_columns": {"unique_id": "macro.dbt.default__create_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2474282, "supported_languages": null}, "macro.dbt.post_snapshot": {"unique_id": "macro.dbt.post_snapshot", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2475789, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"unique_id": "macro.dbt.default__post_snapshot", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.247657, "supported_languages": null}, "macro.dbt.get_true_sql": {"unique_id": "macro.dbt.get_true_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.247787, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"unique_id": "macro.dbt.default__get_true_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2478862, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"unique_id": "macro.dbt.snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.248069, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"unique_id": "macro.dbt.default__snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.248846, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"unique_id": "macro.dbt.build_snapshot_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.249014, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"unique_id": "macro.dbt.default__build_snapshot_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.249233, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"unique_id": "macro.dbt.build_snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.249608, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"unique_id": "macro.dbt.materialization_snapshot_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "name": "materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.254879, "supported_languages": ["sql"]}, "macro.dbt.materialization_test_default": {"unique_id": "macro.dbt.materialization_test_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "name": "materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type='table') -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ create_table_as(False, target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2567658, "supported_languages": ["sql"]}, "macro.dbt.get_test_sql": {"unique_id": "macro.dbt.get_test_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "name": "get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.257233, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"unique_id": "macro.dbt.default__get_test_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "name": "default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.257504, "supported_languages": null}, "macro.dbt.get_where_subquery": {"unique_id": "macro.dbt.get_where_subquery", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "name": "get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2578912, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"unique_id": "macro.dbt.default__get_where_subquery", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "name": "default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.258224, "supported_languages": null}, "macro.dbt.get_quoted_csv": {"unique_id": "macro.dbt.get_quoted_csv", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.259655, "supported_languages": null}, "macro.dbt.diff_columns": {"unique_id": "macro.dbt.diff_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2601411, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"unique_id": "macro.dbt.diff_column_data_types", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.260737, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"unique_id": "macro.dbt.get_merge_update_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.260947, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"unique_id": "macro.dbt.default__get_merge_update_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.261577, "supported_languages": null}, "macro.dbt.get_merge_sql": {"unique_id": "macro.dbt.get_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.265389, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"unique_id": "macro.dbt.default__get_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, predicates) -%}\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{ predicates | join(' and ') }}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2668219, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"unique_id": "macro.dbt.get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2670321, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last }}\n {% endfor %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.26768, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.267919, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.268481, "supported_languages": null}, "macro.dbt.is_incremental": {"unique_id": "macro.dbt.is_incremental", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "name": "is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2690969, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"unique_id": "macro.dbt.get_incremental_append_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.26992, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"unique_id": "macro.dbt.default__get_incremental_append_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.270132, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"unique_id": "macro.dbt.get_incremental_delete_insert_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2702951, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2705312, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"unique_id": "macro.dbt.get_incremental_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.270696, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"unique_id": "macro.dbt.default__get_incremental_merge_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.270932, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2710972, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"predicates\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2713332, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"unique_id": "macro.dbt.get_incremental_default_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.271504, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"unique_id": "macro.dbt.default__get_incremental_default_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.271636, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"unique_id": "macro.dbt.get_insert_into_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.27188, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"unique_id": "macro.dbt.materialization_incremental_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "name": "materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.276313, "supported_languages": ["sql"]}, "macro.dbt.incremental_validate_on_schema_change": {"unique_id": "macro.dbt.incremental_validate_on_schema_change", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.281012, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"unique_id": "macro.dbt.check_for_schema_changes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.282086, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"unique_id": "macro.dbt.sync_column_schemas", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.283144, "supported_languages": null}, "macro.dbt.process_schema_changes": {"unique_id": "macro.dbt.process_schema_changes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.283888, "supported_languages": null}, "macro.dbt.materialization_table_default": {"unique_id": "macro.dbt.materialization_table_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/table.sql", "original_file_path": "macros/materializations/models/table/table.sql", "name": "materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2862191, "supported_languages": ["sql"]}, "macro.dbt.get_create_table_as_sql": {"unique_id": "macro.dbt.get_create_table_as_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.286738, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"unique_id": "macro.dbt.default__get_create_table_as_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2869031, "supported_languages": null}, "macro.dbt.create_table_as": {"unique_id": "macro.dbt.create_table_as", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.28728, "supported_languages": null}, "macro.dbt.default__create_table_as": {"unique_id": "macro.dbt.default__create_table_as", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.287642, "supported_languages": null}, "macro.dbt.materialization_view_default": {"unique_id": "macro.dbt.materialization_view_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/view.sql", "original_file_path": "macros/materializations/models/view/view.sql", "name": "materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2899609, "supported_languages": ["sql"]}, "macro.dbt.handle_existing_table": {"unique_id": "macro.dbt.handle_existing_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/helpers.sql", "original_file_path": "macros/materializations/models/view/helpers.sql", "name": "handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2902899, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"unique_id": "macro.dbt.default__handle_existing_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/helpers.sql", "original_file_path": "macros/materializations/models/view/helpers.sql", "name": "default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.290487, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"unique_id": "macro.dbt.create_or_replace_view", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_or_replace_view.sql", "original_file_path": "macros/materializations/models/view/create_or_replace_view.sql", "name": "create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=True) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2918642, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"unique_id": "macro.dbt.get_create_view_as_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2922502, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"unique_id": "macro.dbt.default__get_create_view_as_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.292392, "supported_languages": null}, "macro.dbt.create_view_as": {"unique_id": "macro.dbt.create_view_as", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.2925508, "supported_languages": null}, "macro.dbt.default__create_view_as": {"unique_id": "macro.dbt.default__create_view_as", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }} as (\n {{ sql }}\n );\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.292777, "supported_languages": null}, "macro.dbt.materialization_seed_default": {"unique_id": "macro.dbt.materialization_seed_default", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "name": "materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparision later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.295721, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"unique_id": "macro.dbt.create_csv_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.29993, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"unique_id": "macro.dbt.default__create_csv_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.300724, "supported_languages": null}, "macro.dbt.reset_csv_table": {"unique_id": "macro.dbt.reset_csv_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.300931, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"unique_id": "macro.dbt.default__reset_csv_table", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.301358, "supported_languages": null}, "macro.dbt.get_csv_sql": {"unique_id": "macro.dbt.get_csv_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3015301, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"unique_id": "macro.dbt.default__get_csv_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.301646, "supported_languages": null}, "macro.dbt.get_binding_char": {"unique_id": "macro.dbt.get_binding_char", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.301771, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"unique_id": "macro.dbt.default__get_binding_char", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.30187, "supported_languages": null}, "macro.dbt.get_batch_size": {"unique_id": "macro.dbt.get_batch_size", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.302015, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"unique_id": "macro.dbt.default__get_batch_size", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3021178, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"unique_id": "macro.dbt.get_seed_column_quoted_csv", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3025339, "supported_languages": null}, "macro.dbt.load_csv_rows": {"unique_id": "macro.dbt.load_csv_rows", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3026938, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"unique_id": "macro.dbt.default__load_csv_rows", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.303833, "supported_languages": null}, "macro.dbt.generate_alias_name": {"unique_id": "macro.dbt.generate_alias_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "name": "generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3042402, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"unique_id": "macro.dbt.default__generate_alias_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "name": "default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name is none -%}\n\n {{ node.name }}\n\n {%- else -%}\n\n {{ custom_alias_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3044422, "supported_languages": null}, "macro.dbt.generate_schema_name": {"unique_id": "macro.dbt.generate_schema_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.304976, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"unique_id": "macro.dbt.default__generate_schema_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.305205, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"unique_id": "macro.dbt.generate_schema_name_for_env", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.305465, "supported_languages": null}, "macro.dbt.generate_database_name": {"unique_id": "macro.dbt.generate_database_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "name": "generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.305872, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"unique_id": "macro.dbt.default__generate_database_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "name": "default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3060942, "supported_languages": null}, "macro.dbt.default__test_relationships": {"unique_id": "macro.dbt.default__test_relationships", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "name": "default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.306464, "supported_languages": null}, "macro.dbt.default__test_not_null": {"unique_id": "macro.dbt.default__test_not_null", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "name": "default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3067882, "supported_languages": null}, "macro.dbt.default__test_unique": {"unique_id": "macro.dbt.default__test_unique", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "name": "default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.307063, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"unique_id": "macro.dbt.default__test_accepted_values", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "name": "default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.307619, "supported_languages": null}, "macro.dbt.statement": {"unique_id": "macro.dbt.statement", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.308962, "supported_languages": null}, "macro.dbt.noop_statement": {"unique_id": "macro.dbt.noop_statement", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.309532, "supported_languages": null}, "macro.dbt.run_query": {"unique_id": "macro.dbt.run_query", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3097951, "supported_languages": null}, "macro.dbt.convert_datetime": {"unique_id": "macro.dbt.convert_datetime", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.311424, "supported_languages": null}, "macro.dbt.dates_in_range": {"unique_id": "macro.dbt.dates_in_range", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partiton start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3124712, "supported_languages": null}, "macro.dbt.partition_range": {"unique_id": "macro.dbt.partition_range", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.313131, "supported_languages": null}, "macro.dbt.py_current_timestring": {"unique_id": "macro.dbt.py_current_timestring", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.313341, "supported_languages": null}, "macro.dbt.except": {"unique_id": "macro.dbt.except", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "name": "except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.313611, "supported_languages": null}, "macro.dbt.default__except": {"unique_id": "macro.dbt.default__except", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "name": "default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.313676, "supported_languages": null}, "macro.dbt.replace": {"unique_id": "macro.dbt.replace", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "name": "replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3140259, "supported_languages": null}, "macro.dbt.default__replace": {"unique_id": "macro.dbt.default__replace", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "name": "default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.314168, "supported_languages": null}, "macro.dbt.concat": {"unique_id": "macro.dbt.concat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "name": "concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3144681, "supported_languages": null}, "macro.dbt.default__concat": {"unique_id": "macro.dbt.default__concat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "name": "default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3145878, "supported_languages": null}, "macro.dbt.length": {"unique_id": "macro.dbt.length", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "name": "length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.314872, "supported_languages": null}, "macro.dbt.default__length": {"unique_id": "macro.dbt.default__length", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "name": "default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.314971, "supported_languages": null}, "macro.dbt.dateadd": {"unique_id": "macro.dbt.dateadd", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "name": "dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.315331, "supported_languages": null}, "macro.dbt.default__dateadd": {"unique_id": "macro.dbt.default__dateadd", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "name": "default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.315477, "supported_languages": null}, "macro.dbt.intersect": {"unique_id": "macro.dbt.intersect", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "name": "intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.315735, "supported_languages": null}, "macro.dbt.default__intersect": {"unique_id": "macro.dbt.default__intersect", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "name": "default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.315805, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"unique_id": "macro.dbt.escape_single_quotes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.316094, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"unique_id": "macro.dbt.default__escape_single_quotes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.316221, "supported_languages": null}, "macro.dbt.right": {"unique_id": "macro.dbt.right", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.316531, "supported_languages": null}, "macro.dbt.default__right": {"unique_id": "macro.dbt.default__right", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3167129, "supported_languages": null}, "macro.dbt.listagg": {"unique_id": "macro.dbt.listagg", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "name": "listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.317313, "supported_languages": null}, "macro.dbt.default__listagg": {"unique_id": "macro.dbt.default__listagg", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "name": "default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3176708, "supported_languages": null}, "macro.dbt.datediff": {"unique_id": "macro.dbt.datediff", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "name": "datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3180218, "supported_languages": null}, "macro.dbt.default__datediff": {"unique_id": "macro.dbt.default__datediff", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "name": "default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3181682, "supported_languages": null}, "macro.dbt.safe_cast": {"unique_id": "macro.dbt.safe_cast", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.318481, "supported_languages": null}, "macro.dbt.default__safe_cast": {"unique_id": "macro.dbt.default__safe_cast", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.318604, "supported_languages": null}, "macro.dbt.hash": {"unique_id": "macro.dbt.hash", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "name": "hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.318888, "supported_languages": null}, "macro.dbt.default__hash": {"unique_id": "macro.dbt.default__hash", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "name": "default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.319027, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"unique_id": "macro.dbt.cast_bool_to_text", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "name": "cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3193002, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"unique_id": "macro.dbt.default__cast_bool_to_text", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "name": "default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.319437, "supported_languages": null}, "macro.dbt.any_value": {"unique_id": "macro.dbt.any_value", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "name": "any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.319712, "supported_languages": null}, "macro.dbt.default__any_value": {"unique_id": "macro.dbt.default__any_value", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "name": "default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.319805, "supported_languages": null}, "macro.dbt.position": {"unique_id": "macro.dbt.position", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "name": "position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.320113, "supported_languages": null}, "macro.dbt.default__position": {"unique_id": "macro.dbt.default__position", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "name": "default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.320232, "supported_languages": null}, "macro.dbt.string_literal": {"unique_id": "macro.dbt.string_literal", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "name": "string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.320504, "supported_languages": null}, "macro.dbt.default__string_literal": {"unique_id": "macro.dbt.default__string_literal", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "name": "default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3205929, "supported_languages": null}, "macro.dbt.type_string": {"unique_id": "macro.dbt.type_string", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3214772, "supported_languages": null}, "macro.dbt.default__type_string": {"unique_id": "macro.dbt.default__type_string", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.321621, "supported_languages": null}, "macro.dbt.type_timestamp": {"unique_id": "macro.dbt.type_timestamp", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3219469, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"unique_id": "macro.dbt.default__type_timestamp", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3220859, "supported_languages": null}, "macro.dbt.type_float": {"unique_id": "macro.dbt.type_float", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.32223, "supported_languages": null}, "macro.dbt.default__type_float": {"unique_id": "macro.dbt.default__type_float", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.322361, "supported_languages": null}, "macro.dbt.type_numeric": {"unique_id": "macro.dbt.type_numeric", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3225012, "supported_languages": null}, "macro.dbt.default__type_numeric": {"unique_id": "macro.dbt.default__type_numeric", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.322656, "supported_languages": null}, "macro.dbt.type_bigint": {"unique_id": "macro.dbt.type_bigint", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.322795, "supported_languages": null}, "macro.dbt.default__type_bigint": {"unique_id": "macro.dbt.default__type_bigint", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.322929, "supported_languages": null}, "macro.dbt.type_int": {"unique_id": "macro.dbt.type_int", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.323072, "supported_languages": null}, "macro.dbt.default__type_int": {"unique_id": "macro.dbt.default__type_int", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.323201, "supported_languages": null}, "macro.dbt.type_boolean": {"unique_id": "macro.dbt.type_boolean", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3233411, "supported_languages": null}, "macro.dbt.default__type_boolean": {"unique_id": "macro.dbt.default__type_boolean", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.323467, "supported_languages": null}, "macro.dbt.array_concat": {"unique_id": "macro.dbt.array_concat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "name": "array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.323775, "supported_languages": null}, "macro.dbt.default__array_concat": {"unique_id": "macro.dbt.default__array_concat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "name": "default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.323894, "supported_languages": null}, "macro.dbt.bool_or": {"unique_id": "macro.dbt.bool_or", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.324169, "supported_languages": null}, "macro.dbt.default__bool_or": {"unique_id": "macro.dbt.default__bool_or", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.324259, "supported_languages": null}, "macro.dbt.last_day": {"unique_id": "macro.dbt.last_day", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3246138, "supported_languages": null}, "macro.dbt.default_last_day": {"unique_id": "macro.dbt.default_last_day", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3248482, "supported_languages": null}, "macro.dbt.default__last_day": {"unique_id": "macro.dbt.default__last_day", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3249779, "supported_languages": null}, "macro.dbt.split_part": {"unique_id": "macro.dbt.split_part", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3254988, "supported_languages": null}, "macro.dbt.default__split_part": {"unique_id": "macro.dbt.default__split_part", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.325707, "supported_languages": null}, "macro.dbt._split_part_negative": {"unique_id": "macro.dbt._split_part_negative", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "_split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 {{ part_number }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3259032, "supported_languages": null}, "macro.dbt.date_trunc": {"unique_id": "macro.dbt.date_trunc", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "name": "date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3262022, "supported_languages": null}, "macro.dbt.default__date_trunc": {"unique_id": "macro.dbt.default__date_trunc", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "name": "default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.326317, "supported_languages": null}, "macro.dbt.array_construct": {"unique_id": "macro.dbt.array_construct", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.326705, "supported_languages": null}, "macro.dbt.default__array_construct": {"unique_id": "macro.dbt.default__array_construct", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.32692, "supported_languages": null}, "macro.dbt.array_append": {"unique_id": "macro.dbt.array_append", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "name": "array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3272269, "supported_languages": null}, "macro.dbt.default__array_append": {"unique_id": "macro.dbt.default__array_append", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "name": "default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.327345, "supported_languages": null}, "macro.dbt.create_schema": {"unique_id": "macro.dbt.create_schema", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.327728, "supported_languages": null}, "macro.dbt.default__create_schema": {"unique_id": "macro.dbt.default__create_schema", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.327889, "supported_languages": null}, "macro.dbt.drop_schema": {"unique_id": "macro.dbt.drop_schema", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.328033, "supported_languages": null}, "macro.dbt.default__drop_schema": {"unique_id": "macro.dbt.default__drop_schema", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.328195, "supported_languages": null}, "macro.dbt.current_timestamp": {"unique_id": "macro.dbt.current_timestamp", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.32868, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"unique_id": "macro.dbt.default__current_timestamp", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.328811, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"unique_id": "macro.dbt.snapshot_get_time", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3289359, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"unique_id": "macro.dbt.default__snapshot_get_time", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.329029, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"unique_id": "macro.dbt.current_timestamp_backcompat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.329176, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"unique_id": "macro.dbt.default__current_timestamp_backcompat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3292422, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.329389, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.329537, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"unique_id": "macro.dbt.get_create_index_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.330055, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"unique_id": "macro.dbt.default__get_create_index_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.330178, "supported_languages": null}, "macro.dbt.create_indexes": {"unique_id": "macro.dbt.create_indexes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.330335, "supported_languages": null}, "macro.dbt.default__create_indexes": {"unique_id": "macro.dbt.default__create_indexes", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3307, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"unique_id": "macro.dbt.make_intermediate_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.333606, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"unique_id": "macro.dbt.default__make_intermediate_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.333757, "supported_languages": null}, "macro.dbt.make_temp_relation": {"unique_id": "macro.dbt.make_temp_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.333951, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"unique_id": "macro.dbt.default__make_temp_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.334209, "supported_languages": null}, "macro.dbt.make_backup_relation": {"unique_id": "macro.dbt.make_backup_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3344278, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"unique_id": "macro.dbt.default__make_backup_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.334712, "supported_languages": null}, "macro.dbt.drop_relation": {"unique_id": "macro.dbt.drop_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3348742, "supported_languages": null}, "macro.dbt.default__drop_relation": {"unique_id": "macro.dbt.default__drop_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3350642, "supported_languages": null}, "macro.dbt.truncate_relation": {"unique_id": "macro.dbt.truncate_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.335223, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"unique_id": "macro.dbt.default__truncate_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.335365, "supported_languages": null}, "macro.dbt.rename_relation": {"unique_id": "macro.dbt.rename_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.335542, "supported_languages": null}, "macro.dbt.default__rename_relation": {"unique_id": "macro.dbt.default__rename_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.335792, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"unique_id": "macro.dbt.get_or_create_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.336011, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"unique_id": "macro.dbt.default__get_or_create_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.336562, "supported_languages": null}, "macro.dbt.load_cached_relation": {"unique_id": "macro.dbt.load_cached_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3367648, "supported_languages": null}, "macro.dbt.load_relation": {"unique_id": "macro.dbt.load_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.336889, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"unique_id": "macro.dbt.drop_relation_if_exists", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.337059, "supported_languages": null}, "macro.dbt.collect_freshness": {"unique_id": "macro.dbt.collect_freshness", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "name": "collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.337497, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"unique_id": "macro.dbt.default__collect_freshness", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "name": "default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness').table) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3378649, "supported_languages": null}, "macro.dbt.copy_grants": {"unique_id": "macro.dbt.copy_grants", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.339423, "supported_languages": null}, "macro.dbt.default__copy_grants": {"unique_id": "macro.dbt.default__copy_grants", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.339523, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3396711, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.339766, "supported_languages": null}, "macro.dbt.should_revoke": {"unique_id": "macro.dbt.should_revoke", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.340068, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"unique_id": "macro.dbt.get_show_grant_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.340231, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"unique_id": "macro.dbt.default__get_show_grant_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.340322, "supported_languages": null}, "macro.dbt.get_grant_sql": {"unique_id": "macro.dbt.get_grant_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.34052, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"unique_id": "macro.dbt.default__get_grant_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.340683, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"unique_id": "macro.dbt.get_revoke_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.340886, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"unique_id": "macro.dbt.default__get_revoke_sql", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.341053, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"unique_id": "macro.dbt.get_dcl_statement_list", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.341252, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"unique_id": "macro.dbt.default__get_dcl_statement_list", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.341851, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"unique_id": "macro.dbt.call_dcl_statements", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3420851, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"unique_id": "macro.dbt.default__call_dcl_statements", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.34231, "supported_languages": null}, "macro.dbt.apply_grants": {"unique_id": "macro.dbt.apply_grants", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.342517, "supported_languages": null}, "macro.dbt.default__apply_grants": {"unique_id": "macro.dbt.default__apply_grants", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3436038, "supported_languages": null}, "macro.dbt.alter_column_comment": {"unique_id": "macro.dbt.alter_column_comment", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.34432, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"unique_id": "macro.dbt.default__alter_column_comment", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.344482, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"unique_id": "macro.dbt.alter_relation_comment", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3446841, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"unique_id": "macro.dbt.default__alter_relation_comment", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.344852, "supported_languages": null}, "macro.dbt.persist_docs": {"unique_id": "macro.dbt.persist_docs", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.345095, "supported_languages": null}, "macro.dbt.default__persist_docs": {"unique_id": "macro.dbt.default__persist_docs", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.345526, "supported_languages": null}, "macro.dbt.get_catalog": {"unique_id": "macro.dbt.get_catalog", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.346912, "supported_languages": null}, "macro.dbt.default__get_catalog": {"unique_id": "macro.dbt.default__get_catalog", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3471448, "supported_languages": null}, "macro.dbt.information_schema_name": {"unique_id": "macro.dbt.information_schema_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.347313, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"unique_id": "macro.dbt.default__information_schema_name", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.347449, "supported_languages": null}, "macro.dbt.list_schemas": {"unique_id": "macro.dbt.list_schemas", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.347611, "supported_languages": null}, "macro.dbt.default__list_schemas": {"unique_id": "macro.dbt.default__list_schemas", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.347832, "supported_languages": null}, "macro.dbt.check_schema_exists": {"unique_id": "macro.dbt.check_schema_exists", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.348022, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"unique_id": "macro.dbt.default__check_schema_exists", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.348295, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"unique_id": "macro.dbt.list_relations_without_caching", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.348462, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"unique_id": "macro.dbt.default__list_relations_without_caching", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.348605, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"unique_id": "macro.dbt.get_columns_in_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.350165, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"unique_id": "macro.dbt.default__get_columns_in_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.350376, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"unique_id": "macro.dbt.sql_convert_columns_in_relation", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.350655, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"unique_id": "macro.dbt.get_columns_in_query", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3508239, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"unique_id": "macro.dbt.default__get_columns_in_query", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.351125, "supported_languages": null}, "macro.dbt.alter_column_type": {"unique_id": "macro.dbt.alter_column_type", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.351331, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"unique_id": "macro.dbt.default__alter_column_type", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.351871, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"unique_id": "macro.dbt.alter_relation_add_remove_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.352103, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3528051, "supported_languages": null}, "macro.dbt.build_ref_function": {"unique_id": "macro.dbt.build_ref_function", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {%- set resolved = ref(*_ref) -%}\n {%- do ref_dict.update({_ref | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef ref(*args,dbt_load_df_function):\n refs = {{ ref_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.354187, "supported_languages": null}, "macro.dbt.build_source_function": {"unique_id": "macro.dbt.build_source_function", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.354607, "supported_languages": null}, "macro.dbt.build_config_dict": {"unique_id": "macro.dbt.build_config_dict", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {%- for key in model.config.config_keys_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == 'language' -%}\n {%- set value = 'python' -%}\n {%- endif -%}\n {%- set value = model.config[key] -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.355018, "supported_languages": null}, "macro.dbt.py_script_postfix": {"unique_id": "macro.dbt.py_script_postfix", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = '{{ this.database }}'\n schema = '{{ this.schema }}'\n identifier = '{{ this.identifier }}'\n def __repr__(self):\n return '{{ this }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args: ref(*args, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.355385, "supported_languages": null}, "macro.dbt.py_script_comment": {"unique_id": "macro.dbt.py_script_comment", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3554492, "supported_languages": null}, "macro.dbt.test_unique": {"unique_id": "macro.dbt.test_unique", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.355972, "supported_languages": null}, "macro.dbt.test_not_null": {"unique_id": "macro.dbt.test_not_null", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.356176, "supported_languages": null}, "macro.dbt.test_accepted_values": {"unique_id": "macro.dbt.test_accepted_values", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.35643, "supported_languages": null}, "macro.dbt.test_relationships": {"unique_id": "macro.dbt.test_relationships", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3566778, "supported_languages": null}, "macro.dbt_utils.get_url_host": {"unique_id": "macro.dbt_utils.get_url_host", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "name": "get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_url_host"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.357051, "supported_languages": null}, "macro.dbt_utils.default__get_url_host": {"unique_id": "macro.dbt_utils.default__get_url_host", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "name": "default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.split_part", "macro.dbt.replace", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.357544, "supported_languages": null}, "macro.dbt_utils.get_url_path": {"unique_id": "macro.dbt_utils.get_url_path", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "name": "get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_url_path"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.358022, "supported_languages": null}, "macro.dbt_utils.default__get_url_path": {"unique_id": "macro.dbt_utils.default__get_url_path", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "name": "default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.position", "macro.dbt.split_part", "macro.dbt.right", "macro.dbt.length", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.358612, "supported_languages": null}, "macro.dbt_utils.get_url_parameter": {"unique_id": "macro.dbt_utils.get_url_parameter", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "name": "get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_url_parameter"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.358957, "supported_languages": null}, "macro.dbt_utils.default__get_url_parameter": {"unique_id": "macro.dbt_utils.default__get_url_parameter", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "name": "default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3592489, "supported_languages": null}, "macro.dbt_utils.test_fewer_rows_than": {"unique_id": "macro.dbt_utils.test_fewer_rows_than", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "name": "test_fewer_rows_than", "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_fewer_rows_than"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3602629, "supported_languages": null}, "macro.dbt_utils.default__test_fewer_rows_than": {"unique_id": "macro.dbt_utils.default__test_fewer_rows_than", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "name": "default__test_fewer_rows_than", "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.361165, "supported_languages": null}, "macro.dbt_utils.test_equal_rowcount": {"unique_id": "macro.dbt_utils.test_equal_rowcount", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "name": "test_equal_rowcount", "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_equal_rowcount"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.361994, "supported_languages": null}, "macro.dbt_utils.default__test_equal_rowcount": {"unique_id": "macro.dbt_utils.default__test_equal_rowcount", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "name": "default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3629498, "supported_languages": null}, "macro.dbt_utils.test_relationships_where": {"unique_id": "macro.dbt_utils.test_relationships_where", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "name": "test_relationships_where", "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_relationships_where"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.363662, "supported_languages": null}, "macro.dbt_utils.default__test_relationships_where": {"unique_id": "macro.dbt_utils.default__test_relationships_where", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "name": "default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3639638, "supported_languages": null}, "macro.dbt_utils.test_recency": {"unique_id": "macro.dbt_utils.test_recency", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "name": "test_recency", "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_recency"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.364676, "supported_languages": null}, "macro.dbt_utils.default__test_recency": {"unique_id": "macro.dbt_utils.default__test_recency", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "name": "default__test_recency", "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.current_timestamp", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.36542, "supported_languages": null}, "macro.dbt_utils.test_not_constant": {"unique_id": "macro.dbt_utils.test_not_constant", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "name": "test_not_constant", "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_not_constant"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3658838, "supported_languages": null}, "macro.dbt_utils.default__test_not_constant": {"unique_id": "macro.dbt_utils.default__test_not_constant", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "name": "default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.366295, "supported_languages": null}, "macro.dbt_utils.test_accepted_range": {"unique_id": "macro.dbt_utils.test_accepted_range", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "name": "test_accepted_range", "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_accepted_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3669, "supported_languages": null}, "macro.dbt_utils.default__test_accepted_range": {"unique_id": "macro.dbt_utils.default__test_accepted_range", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "name": "default__test_accepted_range", "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3673222, "supported_languages": null}, "macro.dbt_utils.test_not_accepted_values": {"unique_id": "macro.dbt_utils.test_not_accepted_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "name": "test_not_accepted_values", "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_not_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.367862, "supported_languages": null}, "macro.dbt_utils.default__test_not_accepted_values": {"unique_id": "macro.dbt_utils.default__test_not_accepted_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "name": "default__test_not_accepted_values", "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.368268, "supported_languages": null}, "macro.dbt_utils.test_at_least_one": {"unique_id": "macro.dbt_utils.test_at_least_one", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "name": "test_at_least_one", "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_at_least_one"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.36875, "supported_languages": null}, "macro.dbt_utils.default__test_at_least_one": {"unique_id": "macro.dbt_utils.default__test_at_least_one", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "name": "default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nselect *\nfrom (\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from {{ model }}\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3691819, "supported_languages": null}, "macro.dbt_utils.test_unique_combination_of_columns": {"unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "name": "test_unique_combination_of_columns", "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_unique_combination_of_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.369783, "supported_languages": null}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "name": "default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.370355, "supported_languages": null}, "macro.dbt_utils.test_cardinality_equality": {"unique_id": "macro.dbt_utils.test_cardinality_equality", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "name": "test_cardinality_equality", "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_cardinality_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3709319, "supported_languages": null}, "macro.dbt_utils.default__test_cardinality_equality": {"unique_id": "macro.dbt_utils.default__test_cardinality_equality", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "name": "default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3712482, "supported_languages": null}, "macro.dbt_utils.test_expression_is_true": {"unique_id": "macro.dbt_utils.test_expression_is_true", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "name": "test_expression_is_true", "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.371661, "supported_languages": null}, "macro.dbt_utils.default__test_expression_is_true": {"unique_id": "macro.dbt_utils.default__test_expression_is_true", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "name": "default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3719811, "supported_languages": null}, "macro.dbt_utils.test_not_null_proportion": {"unique_id": "macro.dbt_utils.test_not_null_proportion", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "name": "test_not_null_proportion", "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_not_null_proportion"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3726258, "supported_languages": null}, "macro.dbt_utils.default__test_not_null_proportion": {"unique_id": "macro.dbt_utils.default__test_not_null_proportion", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "name": "default__test_not_null_proportion", "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.373369, "supported_languages": null}, "macro.dbt_utils.test_sequential_values": {"unique_id": "macro.dbt_utils.test_sequential_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "name": "test_sequential_values", "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_sequential_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.374219, "supported_languages": null}, "macro.dbt_utils.default__test_sequential_values": {"unique_id": "macro.dbt_utils.default__test_sequential_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "name": "default__test_sequential_values", "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.slugify", "macro.dbt.type_timestamp", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.375051, "supported_languages": null}, "macro.dbt_utils.test_equality": {"unique_id": "macro.dbt_utils.test_equality", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "name": "test_equality", "macro_sql": "{% test equality(model, compare_model, compare_columns=None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3757792, "supported_languages": null}, "macro.dbt_utils.default__test_equality": {"unique_id": "macro.dbt_utils.default__test_equality", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "name": "default__test_equality", "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None) %}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3765771, "supported_languages": null}, "macro.dbt_utils.test_not_empty_string": {"unique_id": "macro.dbt_utils.test_not_empty_string", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "name": "test_not_empty_string", "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_not_empty_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.377088, "supported_languages": null}, "macro.dbt_utils.default__test_not_empty_string": {"unique_id": "macro.dbt_utils.default__test_not_empty_string", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "name": "default__test_not_empty_string", "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.377356, "supported_languages": null}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "name": "test_mutually_exclusive_ranges", "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.380419, "supported_languages": null}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "name": "default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.381848, "supported_languages": null}, "macro.dbt_utils.pretty_log_format": {"unique_id": "macro.dbt_utils.pretty_log_format", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "name": "pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3821619, "supported_languages": null}, "macro.dbt_utils.default__pretty_log_format": {"unique_id": "macro.dbt_utils.default__pretty_log_format", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "name": "default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.382318, "supported_languages": null}, "macro.dbt_utils._is_relation": {"unique_id": "macro.dbt_utils._is_relation", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/_is_relation.sql", "original_file_path": "macros/jinja_helpers/_is_relation.sql", "name": "_is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3827689, "supported_languages": null}, "macro.dbt_utils.pretty_time": {"unique_id": "macro.dbt_utils.pretty_time", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "name": "pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.383074, "supported_languages": null}, "macro.dbt_utils.default__pretty_time": {"unique_id": "macro.dbt_utils.default__pretty_time", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "name": "default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.383252, "supported_languages": null}, "macro.dbt_utils.log_info": {"unique_id": "macro.dbt_utils.log_info", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "name": "log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__log_info"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3835342, "supported_languages": null}, "macro.dbt_utils.default__log_info": {"unique_id": "macro.dbt_utils.default__log_info", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "name": "default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3836899, "supported_languages": null}, "macro.dbt_utils.slugify": {"unique_id": "macro.dbt_utils.slugify", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/slugify.sql", "original_file_path": "macros/jinja_helpers/slugify.sql", "name": "slugify", "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.384299, "supported_languages": null}, "macro.dbt_utils._is_ephemeral": {"unique_id": "macro.dbt_utils._is_ephemeral", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/jinja_helpers/_is_ephemeral.sql", "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", "name": "_is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3850958, "supported_languages": null}, "macro.dbt_utils.get_intervals_between": {"unique_id": "macro.dbt_utils.get_intervals_between", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "name": "get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.385773, "supported_languages": null}, "macro.dbt_utils.default__get_intervals_between": {"unique_id": "macro.dbt_utils.default__get_intervals_between", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "name": "default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3863091, "supported_languages": null}, "macro.dbt_utils.date_spine": {"unique_id": "macro.dbt_utils.date_spine", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "name": "date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.386515, "supported_languages": null}, "macro.dbt_utils.default__date_spine": {"unique_id": "macro.dbt_utils.default__date_spine", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "name": "default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.generate_series", "macro.dbt_utils.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3868392, "supported_languages": null}, "macro.dbt_utils.nullcheck_table": {"unique_id": "macro.dbt_utils.nullcheck_table", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "name": "nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.387179, "supported_languages": null}, "macro.dbt_utils.default__nullcheck_table": {"unique_id": "macro.dbt_utils.default__nullcheck_table", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "name": "default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.387488, "supported_languages": null}, "macro.dbt_utils.get_relations_by_pattern": {"unique_id": "macro.dbt_utils.get_relations_by_pattern", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "name": "get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.388188, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_pattern": {"unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "name": "default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.389052, "supported_languages": null}, "macro.dbt_utils.get_powers_of_two": {"unique_id": "macro.dbt_utils.get_powers_of_two", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.389877, "supported_languages": null}, "macro.dbt_utils.default__get_powers_of_two": {"unique_id": "macro.dbt_utils.default__get_powers_of_two", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3902452, "supported_languages": null}, "macro.dbt_utils.generate_series": {"unique_id": "macro.dbt_utils.generate_series", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.390409, "supported_languages": null}, "macro.dbt_utils.default__generate_series": {"unique_id": "macro.dbt_utils.default__generate_series", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.390869, "supported_languages": null}, "macro.dbt_utils.get_relations_by_prefix": {"unique_id": "macro.dbt_utils.get_relations_by_prefix", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "name": "get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_prefix"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.391517, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_prefix": {"unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "name": "default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3922718, "supported_languages": null}, "macro.dbt_utils.get_tables_by_prefix_sql": {"unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "name": "get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3927062, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "name": "default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3929589, "supported_languages": null}, "macro.dbt_utils.star": {"unique_id": "macro.dbt_utils.star", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "name": "star", "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__star"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3940768, "supported_languages": null}, "macro.dbt_utils.default__star": {"unique_id": "macro.dbt_utils.default__star", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "name": "default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.395324, "supported_languages": null}, "macro.dbt_utils.unpivot": {"unique_id": "macro.dbt_utils.unpivot", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "name": "unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__unpivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3965352, "supported_languages": null}, "macro.dbt_utils.default__unpivot": {"unique_id": "macro.dbt_utils.default__unpivot", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "name": "default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_string", "macro.dbt.cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.398005, "supported_languages": null}, "macro.dbt_utils.safe_divide": {"unique_id": "macro.dbt_utils.safe_divide", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "name": "safe_divide", "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__safe_divide"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.3983328, "supported_languages": null}, "macro.dbt_utils.default__safe_divide": {"unique_id": "macro.dbt_utils.default__safe_divide", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "name": "default__safe_divide", "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.398452, "supported_languages": null}, "macro.dbt_utils.union_relations": {"unique_id": "macro.dbt_utils.union_relations", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "name": "union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__union_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.401163, "supported_languages": null}, "macro.dbt_utils.default__union_relations": {"unique_id": "macro.dbt_utils.default__union_relations", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "name": "default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.string_literal", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4042728, "supported_languages": null}, "macro.dbt_utils.group_by": {"unique_id": "macro.dbt_utils.group_by", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "name": "group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.404688, "supported_languages": null}, "macro.dbt_utils.default__group_by": {"unique_id": "macro.dbt_utils.default__group_by", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "name": "default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.404921, "supported_languages": null}, "macro.dbt_utils.deduplicate": {"unique_id": "macro.dbt_utils.deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "deduplicate", "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.snowflake__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4057012, "supported_languages": null}, "macro.dbt_utils.default__deduplicate": {"unique_id": "macro.dbt_utils.default__deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "default__deduplicate", "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.405914, "supported_languages": null}, "macro.dbt_utils.redshift__deduplicate": {"unique_id": "macro.dbt_utils.redshift__deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "redshift__deduplicate", "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n {{ return(dbt_utils.default__deduplicate(relation, partition_by, order_by=order_by)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.406091, "supported_languages": null}, "macro.dbt_utils.postgres__deduplicate": {"unique_id": "macro.dbt_utils.postgres__deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "postgres__deduplicate", "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.406261, "supported_languages": null}, "macro.dbt_utils.snowflake__deduplicate": {"unique_id": "macro.dbt_utils.snowflake__deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "snowflake__deduplicate", "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4064052, "supported_languages": null}, "macro.dbt_utils.bigquery__deduplicate": {"unique_id": "macro.dbt_utils.bigquery__deduplicate", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "name": "bigquery__deduplicate", "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4065611, "supported_languages": null}, "macro.dbt_utils.surrogate_key": {"unique_id": "macro.dbt_utils.surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "name": "surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.406983, "supported_languages": null}, "macro.dbt_utils.default__surrogate_key": {"unique_id": "macro.dbt_utils.default__surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "name": "default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4072099, "supported_languages": null}, "macro.dbt_utils.safe_add": {"unique_id": "macro.dbt_utils.safe_add", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "name": "safe_add", "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__safe_add"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4076219, "supported_languages": null}, "macro.dbt_utils.default__safe_add": {"unique_id": "macro.dbt_utils.default__safe_add", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "name": "default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4081101, "supported_languages": null}, "macro.dbt_utils.nullcheck": {"unique_id": "macro.dbt_utils.nullcheck", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "name": "nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4084759, "supported_languages": null}, "macro.dbt_utils.default__nullcheck": {"unique_id": "macro.dbt_utils.default__nullcheck", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "name": "default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.408771, "supported_languages": null}, "macro.dbt_utils.get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4102662, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.410592, "supported_languages": null}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._bigquery__get_matching_schemata", "macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.411437, "supported_languages": null}, "macro.dbt_utils._bigquery__get_matching_schemata": {"unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "_bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4118888, "supported_languages": null}, "macro.dbt_utils.get_column_values": {"unique_id": "macro.dbt_utils.get_column_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "name": "get_column_values", "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_column_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4129212, "supported_languages": null}, "macro.dbt_utils.default__get_column_values": {"unique_id": "macro.dbt_utils.default__get_column_values", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "name": "default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_ephemeral", "macro.dbt.load_relation", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.414268, "supported_languages": null}, "macro.dbt_utils.pivot": {"unique_id": "macro.dbt_utils.pivot", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "name": "pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__pivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.415263, "supported_languages": null}, "macro.dbt_utils.default__pivot": {"unique_id": "macro.dbt_utils.default__pivot", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "name": "default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.416003, "supported_languages": null}, "macro.dbt_utils.get_filtered_columns_in_relation": {"unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "name": "get_filtered_columns_in_relation", "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.416487, "supported_languages": null}, "macro.dbt_utils.default__get_filtered_columns_in_relation": {"unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "name": "default__get_filtered_columns_in_relation", "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.417129, "supported_languages": null}, "macro.dbt_utils.width_bucket": {"unique_id": "macro.dbt_utils.width_bucket", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "name": "width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.snowflake__width_bucket"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.418448, "supported_languages": null}, "macro.dbt_utils.default__width_bucket": {"unique_id": "macro.dbt_utils.default__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "name": "default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.418854, "supported_languages": null}, "macro.dbt_utils.redshift__width_bucket": {"unique_id": "macro.dbt_utils.redshift__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "name": "redshift__width_bucket", "macro_sql": "{% macro redshift__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is exactly at the bucket edge\n case\n when\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }} %\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.419262, "supported_languages": null}, "macro.dbt_utils.snowflake__width_bucket": {"unique_id": "macro.dbt_utils.snowflake__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "name": "snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.419429, "supported_languages": null}, "macro.dbt_utils.get_query_results_as_dict": {"unique_id": "macro.dbt_utils.get_query_results_as_dict", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "name": "get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_query_results_as_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.419848, "supported_languages": null}, "macro.dbt_utils.default__get_query_results_as_dict": {"unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "name": "default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.420377, "supported_languages": null}, "macro.dbt_utils.generate_surrogate_key": {"unique_id": "macro.dbt_utils.generate_surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "name": "generate_surrogate_key", "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__generate_surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.420844, "supported_languages": null}, "macro.dbt_utils.default__generate_surrogate_key": {"unique_id": "macro.dbt_utils.default__generate_surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "name": "default__generate_surrogate_key", "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{% if var('surrogate_key_treat_nulls_as_empty_strings', False) %}\n {% set default_null_value = \"\" %}\n{% else %}\n {% set default_null_value = '_dbt_utils_surrogate_key_null_'%}\n{% endif %}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.hash", "macro.dbt.concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4214232, "supported_languages": null}, "macro.dbt_utils.get_table_types_sql": {"unique_id": "macro.dbt_utils.get_table_types_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "name": "get_table_types_sql", "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4218292, "supported_languages": null}, "macro.dbt_utils.default__get_table_types_sql": {"unique_id": "macro.dbt_utils.default__get_table_types_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "name": "default__get_table_types_sql", "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.421955, "supported_languages": null}, "macro.dbt_utils.postgres__get_table_types_sql": {"unique_id": "macro.dbt_utils.postgres__get_table_types_sql", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "name": "postgres__get_table_types_sql", "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.422082, "supported_languages": null}, "macro.dbt_utils.get_single_value": {"unique_id": "macro.dbt_utils.get_single_value", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "name": "get_single_value", "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__get_single_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.422582, "supported_languages": null}, "macro.dbt_utils.default__get_single_value": {"unique_id": "macro.dbt_utils.default__get_single_value", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "name": "default__get_single_value", "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.447829, "supported_languages": null}, "macro.dbt_utils.degrees_to_radians": {"unique_id": "macro.dbt_utils.degrees_to_radians", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "name": "degrees_to_radians", "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4489868, "supported_languages": null}, "macro.dbt_utils.haversine_distance": {"unique_id": "macro.dbt_utils.haversine_distance", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "name": "haversine_distance", "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.default__haversine_distance"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.449245, "supported_languages": null}, "macro.dbt_utils.default__haversine_distance": {"unique_id": "macro.dbt_utils.default__haversine_distance", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "name": "default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4497669, "supported_languages": null}, "macro.dbt_utils.bigquery__haversine_distance": {"unique_id": "macro.dbt_utils.bigquery__haversine_distance", "package_name": "dbt_utils", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "name": "bigquery__haversine_distance", "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_utils.degrees_to_radians"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.450482, "supported_languages": null}, "macro.dbt_date.get_date_dimension": {"unique_id": "macro.dbt_date.get_date_dimension", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_date_dimension.sql", "original_file_path": "macros/get_date_dimension.sql", "name": "get_date_dimension", "macro_sql": "{% macro get_date_dimension(start_date, end_date) %}\n {{ adapter.dispatch('get_date_dimension', 'dbt_date') (start_date, end_date) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__get_date_dimension"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4585989, "supported_languages": null}, "macro.dbt_date.default__get_date_dimension": {"unique_id": "macro.dbt_date.default__get_date_dimension", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_date_dimension.sql", "original_file_path": "macros/get_date_dimension.sql", "name": "default__get_date_dimension", "macro_sql": "{% macro default__get_date_dimension(start_date, end_date) %}\nwith base_dates as (\n {{ dbt_date.get_base_dates(start_date, end_date) }}\n),\ndates_with_prior_year_dates as (\n\n select\n cast(d.date_day as date) as date_day,\n cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day,\n cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day\n from\n \tbase_dates d\n\n)\nselect\n d.date_day,\n {{ dbt_date.yesterday('d.date_day') }} as prior_date_day,\n {{ dbt_date.tomorrow('d.date_day') }} as next_date_day,\n d.prior_year_date_day as prior_year_date_day,\n d.prior_year_over_year_date_day,\n {{ dbt_date.day_of_week('d.date_day', isoweek=false) }} as day_of_week,\n {{ dbt_date.day_of_week('d.date_day', isoweek=true) }} as day_of_week_iso,\n {{ dbt_date.day_name('d.date_day', short=false) }} as day_of_week_name,\n {{ dbt_date.day_name('d.date_day', short=true) }} as day_of_week_name_short,\n {{ dbt_date.day_of_month('d.date_day') }} as day_of_month,\n {{ dbt_date.day_of_year('d.date_day') }} as day_of_year,\n\n {{ dbt_date.week_start('d.date_day') }} as week_start_date,\n {{ dbt_date.week_end('d.date_day') }} as week_end_date,\n {{ dbt_date.week_start('d.prior_year_over_year_date_day') }} as prior_year_week_start_date,\n {{ dbt_date.week_end('d.prior_year_over_year_date_day') }} as prior_year_week_end_date,\n {{ dbt_date.week_of_year('d.date_day') }} as week_of_year,\n\n {{ dbt_date.iso_week_start('d.date_day') }} as iso_week_start_date,\n {{ dbt_date.iso_week_end('d.date_day') }} as iso_week_end_date,\n {{ dbt_date.iso_week_start('d.prior_year_over_year_date_day') }} as prior_year_iso_week_start_date,\n {{ dbt_date.iso_week_end('d.prior_year_over_year_date_day') }} as prior_year_iso_week_end_date,\n {{ dbt_date.iso_week_of_year('d.date_day') }} as iso_week_of_year,\n\n {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year,\n {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year,\n\n cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year,\n {{ dbt_date.month_name('d.date_day', short=false) }} as month_name,\n {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short,\n\n cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date,\n cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date,\n\n cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date,\n cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date,\n\n cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year,\n cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date,\n cast({{ last_day('d.date_day', 'quarter') }} as date) as quarter_end_date,\n\n cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number,\n cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date,\n cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date\nfrom\n dates_with_prior_year_dates d\norder by 1\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.get_base_dates", "macro.dbt.dateadd", "macro.dbt_date.yesterday", "macro.dbt_date.tomorrow", "macro.dbt_date.day_of_week", "macro.dbt_date.day_name", "macro.dbt_date.day_of_month", "macro.dbt_date.day_of_year", "macro.dbt_date.week_start", "macro.dbt_date.week_end", "macro.dbt_date.week_of_year", "macro.dbt_date.iso_week_start", "macro.dbt_date.iso_week_end", "macro.dbt_date.iso_week_of_year", "macro.dbt_date.date_part", "macro.dbt.type_int", "macro.dbt_date.month_name", "macro.dbt.date_trunc", "macro.dbt.last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.460624, "supported_languages": null}, "macro.dbt_date.postgres__get_date_dimension": {"unique_id": "macro.dbt_date.postgres__get_date_dimension", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_date_dimension.sql", "original_file_path": "macros/get_date_dimension.sql", "name": "postgres__get_date_dimension", "macro_sql": "{% macro postgres__get_date_dimension(start_date, end_date) %}\nwith base_dates as (\n {{ dbt_date.get_base_dates(start_date, end_date) }}\n),\ndates_with_prior_year_dates as (\n\n select\n cast(d.date_day as date) as date_day,\n cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day,\n cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day\n from\n \tbase_dates d\n\n)\nselect\n d.date_day,\n {{ dbt_date.yesterday('d.date_day') }} as prior_date_day,\n {{ dbt_date.tomorrow('d.date_day') }} as next_date_day,\n d.prior_year_date_day as prior_year_date_day,\n d.prior_year_over_year_date_day,\n {{ dbt_date.day_of_week('d.date_day', isoweek=true) }} as day_of_week,\n\n {{ dbt_date.day_name('d.date_day', short=false) }} as day_of_week_name,\n {{ dbt_date.day_name('d.date_day', short=true) }} as day_of_week_name_short,\n {{ dbt_date.day_of_month('d.date_day') }} as day_of_month,\n {{ dbt_date.day_of_year('d.date_day') }} as day_of_year,\n\n {{ dbt_date.week_start('d.date_day') }} as week_start_date,\n {{ dbt_date.week_end('d.date_day') }} as week_end_date,\n {{ dbt_date.week_start('d.prior_year_over_year_date_day') }} as prior_year_week_start_date,\n {{ dbt_date.week_end('d.prior_year_over_year_date_day') }} as prior_year_week_end_date,\n {{ dbt_date.week_of_year('d.date_day') }} as week_of_year,\n\n {{ dbt_date.iso_week_start('d.date_day') }} as iso_week_start_date,\n {{ dbt_date.iso_week_end('d.date_day') }} as iso_week_end_date,\n {{ dbt_date.iso_week_start('d.prior_year_over_year_date_day') }} as prior_year_iso_week_start_date,\n {{ dbt_date.iso_week_end('d.prior_year_over_year_date_day') }} as prior_year_iso_week_end_date,\n {{ dbt_date.iso_week_of_year('d.date_day') }} as iso_week_of_year,\n\n {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year,\n {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year,\n\n cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year,\n {{ dbt_date.month_name('d.date_day', short=false) }} as month_name,\n {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short,\n\n cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date,\n cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date,\n\n cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date,\n cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date,\n\n cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year,\n cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date,\n {# last_day does not support quarter because postgresql does not support quarter interval. #}\n cast({{dbt.dateadd('day', '-1', dbt.dateadd('month', '3', dbt.date_trunc('quarter', 'd.date_day')))}} as date) as quarter_end_date,\n\n cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number,\n cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date,\n cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date\nfrom\n dates_with_prior_year_dates d\norder by 1\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.get_base_dates", "macro.dbt.dateadd", "macro.dbt_date.yesterday", "macro.dbt_date.tomorrow", "macro.dbt_date.day_of_week", "macro.dbt_date.day_name", "macro.dbt_date.day_of_month", "macro.dbt_date.day_of_year", "macro.dbt_date.week_start", "macro.dbt_date.week_end", "macro.dbt_date.week_of_year", "macro.dbt_date.iso_week_start", "macro.dbt_date.iso_week_end", "macro.dbt_date.iso_week_of_year", "macro.dbt_date.date_part", "macro.dbt.type_int", "macro.dbt_date.month_name", "macro.dbt.date_trunc", "macro.dbt.last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4626582, "supported_languages": null}, "macro.dbt_date.get_base_dates": {"unique_id": "macro.dbt_date.get_base_dates", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_base_dates.sql", "original_file_path": "macros/get_base_dates.sql", "name": "get_base_dates", "macro_sql": "{% macro get_base_dates(start_date=None, end_date=None, n_dateparts=None, datepart=\"day\") %}\n {{ adapter.dispatch('get_base_dates', 'dbt_date') (start_date, end_date, n_dateparts, datepart) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__get_base_dates"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4636312, "supported_languages": null}, "macro.dbt_date.default__get_base_dates": {"unique_id": "macro.dbt_date.default__get_base_dates", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_base_dates.sql", "original_file_path": "macros/get_base_dates.sql", "name": "default__get_base_dates", "macro_sql": "{% macro default__get_base_dates(start_date, end_date, n_dateparts, datepart) %}\n\n{%- if start_date and end_date -%}\n{%- set start_date=\"cast('\" ~ start_date ~ \"' as \" ~ dbt.type_timestamp() ~ \")\" -%}\n{%- set end_date=\"cast('\" ~ end_date ~ \"' as \" ~ dbt.type_timestamp() ~ \")\" -%}\n\n{%- elif n_dateparts and datepart -%}\n\n{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%}\n{%- set end_date = dbt_date.tomorrow() -%}\n{%- endif -%}\n\nwith date_spine as\n(\n\n {{ dbt_date.date_spine(\n datepart=datepart,\n start_date=start_date,\n end_date=end_date,\n )\n }}\n\n)\nselect\n cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }}\nfrom\n date_spine d\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_timestamp", "macro.dbt.dateadd", "macro.dbt_date.today", "macro.dbt_date.tomorrow", "macro.dbt_date.date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.464303, "supported_languages": null}, "macro.dbt_date.bigquery__get_base_dates": {"unique_id": "macro.dbt_date.bigquery__get_base_dates", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/get_base_dates.sql", "original_file_path": "macros/get_base_dates.sql", "name": "bigquery__get_base_dates", "macro_sql": "{% macro bigquery__get_base_dates(start_date, end_date, n_dateparts, datepart) %}\n\n{%- if start_date and end_date -%}\n{%- set start_date=\"cast('\" ~ start_date ~ \"' as date )\" -%}\n{%- set end_date=\"cast('\" ~ end_date ~ \"' as date )\" -%}\n\n{%- elif n_dateparts and datepart -%}\n\n{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%}\n{%- set end_date = dbt_date.tomorrow() -%}\n{%- endif -%}\n\nwith date_spine as\n(\n\n {{ dbt_date.date_spine(\n datepart=datepart,\n start_date=start_date,\n end_date=end_date,\n )\n }}\n\n)\nselect\n cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }}\nfrom\n date_spine d\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt_date.today", "macro.dbt_date.tomorrow", "macro.dbt_date.date_spine", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.464916, "supported_languages": null}, "macro.dbt_date.get_intervals_between": {"unique_id": "macro.dbt_date.get_intervals_between", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/date_spine.sql", "original_file_path": "macros/_utils/date_spine.sql", "name": "get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_date')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.465622, "supported_languages": null}, "macro.dbt_date.default__get_intervals_between": {"unique_id": "macro.dbt_date.default__get_intervals_between", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/date_spine.sql", "original_file_path": "macros/_utils/date_spine.sql", "name": "default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.466151, "supported_languages": null}, "macro.dbt_date.date_spine": {"unique_id": "macro.dbt_date.date_spine", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/date_spine.sql", "original_file_path": "macros/_utils/date_spine.sql", "name": "date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_date')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.466361, "supported_languages": null}, "macro.dbt_date.default__date_spine": {"unique_id": "macro.dbt_date.default__date_spine", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/date_spine.sql", "original_file_path": "macros/_utils/date_spine.sql", "name": "default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{\n dbt_date.generate_series(\n dbt_date.get_intervals_between(start_date, end_date, datepart)\n )\n }}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.generate_series", "macro.dbt_date.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.46669, "supported_languages": null}, "macro.dbt_date.get_powers_of_two": {"unique_id": "macro.dbt_date.get_powers_of_two", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/generate_series.sql", "original_file_path": "macros/_utils/generate_series.sql", "name": "get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_date')(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.46749, "supported_languages": null}, "macro.dbt_date.default__get_powers_of_two": {"unique_id": "macro.dbt_date.default__get_powers_of_two", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/generate_series.sql", "original_file_path": "macros/_utils/generate_series.sql", "name": "default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.467856, "supported_languages": null}, "macro.dbt_date.generate_series": {"unique_id": "macro.dbt_date.generate_series", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/generate_series.sql", "original_file_path": "macros/_utils/generate_series.sql", "name": "generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_date')(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.468025, "supported_languages": null}, "macro.dbt_date.default__generate_series": {"unique_id": "macro.dbt_date.default__generate_series", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/_utils/generate_series.sql", "original_file_path": "macros/_utils/generate_series.sql", "name": "default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_date.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.468481, "supported_languages": null}, "macro.dbt_date.get_fiscal_year_dates": {"unique_id": "macro.dbt_date.get_fiscal_year_dates", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/fiscal_date/get_fiscal_year_dates.sql", "original_file_path": "macros/fiscal_date/get_fiscal_year_dates.sql", "name": "get_fiscal_year_dates", "macro_sql": "{% macro get_fiscal_year_dates(dates, year_end_month=12, week_start_day=1, shift_year=1) %}\n{{ adapter.dispatch('get_fiscal_year_dates', 'dbt_date') (dates, year_end_month, week_start_day, shift_year) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__get_fiscal_year_dates"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4700959, "supported_languages": null}, "macro.dbt_date.default__get_fiscal_year_dates": {"unique_id": "macro.dbt_date.default__get_fiscal_year_dates", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/fiscal_date/get_fiscal_year_dates.sql", "original_file_path": "macros/fiscal_date/get_fiscal_year_dates.sql", "name": "default__get_fiscal_year_dates", "macro_sql": "{% macro default__get_fiscal_year_dates(dates, year_end_month, week_start_day, shift_year) %}\n-- this gets all the dates within a fiscal year\n-- determined by the given year-end-month\n-- ending on the saturday closest to that month's end date\nwith date_dimension as (\n select * from {{ dates }}\n),\nyear_month_end as (\n\n select\n d.year_number - {{ shift_year }} as fiscal_year_number,\n d.month_end_date\n from\n date_dimension d\n where\n d.month_of_year = {{ year_end_month }}\n group by 1,2\n\n),\nweeks as (\n\n select\n d.year_number,\n d.month_of_year,\n d.date_day as week_start_date,\n cast({{ dbt.dateadd('day', 6, 'd.date_day') }} as date) as week_end_date\n from\n date_dimension d\n where\n d.day_of_week = {{ week_start_day }}\n\n),\n-- get all the weeks that start in the month the year ends\nyear_week_ends as (\n\n select\n d.year_number - {{ shift_year }} as fiscal_year_number,\n d.week_end_date\n from\n weeks d\n where\n d.month_of_year = {{ year_end_month }}\n group by\n 1,2\n\n),\n-- then calculate which Saturday is closest to month end\nweeks_at_month_end as (\n\n select\n d.fiscal_year_number,\n d.week_end_date,\n m.month_end_date,\n rank() over\n (partition by d.fiscal_year_number\n order by\n abs({{ dbt.datediff('d.week_end_date', 'm.month_end_date', 'day') }})\n\n ) as closest_to_month_end\n from\n year_week_ends d\n join\n year_month_end m on d.fiscal_year_number = m.fiscal_year_number\n),\nfiscal_year_range as (\n\n select\n w.fiscal_year_number,\n cast(\n {{ dbt.dateadd('day', 1,\n 'lag(w.week_end_date) over(order by w.week_end_date)') }}\n as date) as fiscal_year_start_date,\n w.week_end_date as fiscal_year_end_date\n from\n weeks_at_month_end w\n where\n w.closest_to_month_end = 1\n\n),\nfiscal_year_dates as (\n\n select\n d.date_day,\n m.fiscal_year_number,\n m.fiscal_year_start_date,\n m.fiscal_year_end_date,\n w.week_start_date,\n w.week_end_date,\n -- we reset the weeks of the year starting with the merch year start date\n dense_rank()\n over(\n partition by m.fiscal_year_number\n order by w.week_start_date\n ) as fiscal_week_of_year\n from\n date_dimension d\n join\n fiscal_year_range m on d.date_day between m.fiscal_year_start_date and m.fiscal_year_end_date\n join\n weeks w on d.date_day between w.week_start_date and w.week_end_date\n\n)\nselect * from fiscal_year_dates order by 1\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.470626, "supported_languages": null}, "macro.dbt_date.get_fiscal_periods": {"unique_id": "macro.dbt_date.get_fiscal_periods", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/fiscal_date/get_fiscal_periods.sql", "original_file_path": "macros/fiscal_date/get_fiscal_periods.sql", "name": "get_fiscal_periods", "macro_sql": "{% macro get_fiscal_periods(dates, year_end_month, week_start_day, shift_year=1) %}\n{#\nThis macro requires you to pass in a ref to a date dimension, created via\ndbt_date.get_date_dimension()s\n#}\nwith fscl_year_dates_for_periods as (\n {{ dbt_date.get_fiscal_year_dates(dates, year_end_month, week_start_day, shift_year) }}\n),\nfscl_year_w13 as (\n\n select\n f.*,\n -- We count the weeks in a 13 week period\n -- and separate the 4-5-4 week sequences\n mod(cast(\n (f.fiscal_week_of_year-1) as {{ dbt.type_int() }}\n ), 13) as w13_number,\n -- Chop weeks into 13 week merch quarters\n cast(\n least(\n floor((f.fiscal_week_of_year-1)/13.0)\n , 3)\n as {{ dbt.type_int() }}) as quarter_number\n from\n fscl_year_dates_for_periods f\n\n),\nfscl_periods as (\n\n select\n f.date_day,\n f.fiscal_year_number,\n f.week_start_date,\n f.week_end_date,\n f.fiscal_week_of_year,\n case\n -- we move week 53 into the 3rd period of the quarter\n when f.fiscal_week_of_year = 53 then 3\n when f.w13_number between 0 and 3 then 1\n when f.w13_number between 4 and 8 then 2\n when f.w13_number between 9 and 12 then 3\n end as period_of_quarter,\n f.quarter_number\n from\n fscl_year_w13 f\n\n),\nfscl_periods_quarters as (\n\n select\n f.*,\n cast((\n (f.quarter_number * 3) + f.period_of_quarter\n ) as {{ dbt.type_int() }}) as fiscal_period_number\n from\n fscl_periods f\n\n)\nselect\n date_day,\n fiscal_year_number,\n week_start_date,\n week_end_date,\n fiscal_week_of_year,\n dense_rank() over(partition by fiscal_period_number order by fiscal_week_of_year) as fiscal_week_of_period,\n fiscal_period_number,\n quarter_number+1 as fiscal_quarter_number,\n period_of_quarter as fiscal_period_of_quarter\nfrom\n fscl_periods_quarters\norder by 1,2\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.get_fiscal_year_dates", "macro.dbt.type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.471539, "supported_languages": null}, "macro.dbt_date.tomorrow": {"unique_id": "macro.dbt_date.tomorrow", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/tomorrow.sql", "original_file_path": "macros/calendar_date/tomorrow.sql", "name": "tomorrow", "macro_sql": "{%- macro tomorrow(date=None, tz=None) -%}\n{{ dbt_date.n_days_away(1, date, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_days_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.471798, "supported_languages": null}, "macro.dbt_date.next_week": {"unique_id": "macro.dbt_date.next_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/next_week.sql", "original_file_path": "macros/calendar_date/next_week.sql", "name": "next_week", "macro_sql": "{%- macro next_week(tz=None) -%}\n{{ dbt_date.n_weeks_away(1, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_weeks_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.47202, "supported_languages": null}, "macro.dbt_date.next_month_name": {"unique_id": "macro.dbt_date.next_month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/next_month_name.sql", "original_file_path": "macros/calendar_date/next_month_name.sql", "name": "next_month_name", "macro_sql": "{%- macro next_month_name(short=True, tz=None) -%}\n{{ dbt_date.month_name(dbt_date.next_month(tz), short=short) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.month_name", "macro.dbt_date.next_month"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.47229, "supported_languages": null}, "macro.dbt_date.next_month": {"unique_id": "macro.dbt_date.next_month", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/next_month.sql", "original_file_path": "macros/calendar_date/next_month.sql", "name": "next_month", "macro_sql": "{%- macro next_month(tz=None) -%}\n{{ dbt_date.n_months_away(1, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_months_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.472516, "supported_languages": null}, "macro.dbt_date.day_name": {"unique_id": "macro.dbt_date.day_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_name.sql", "original_file_path": "macros/calendar_date/day_name.sql", "name": "day_name", "macro_sql": "{%- macro day_name(date, short=True) -%}\n {{ adapter.dispatch('day_name', 'dbt_date') (date, short) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.snowflake__day_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.47312, "supported_languages": null}, "macro.dbt_date.default__day_name": {"unique_id": "macro.dbt_date.default__day_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_name.sql", "original_file_path": "macros/calendar_date/day_name.sql", "name": "default__day_name", "macro_sql": "\n\n{%- macro default__day_name(date, short) -%}\n{%- set f = 'Dy' if short else 'Day' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.473362, "supported_languages": null}, "macro.dbt_date.snowflake__day_name": {"unique_id": "macro.dbt_date.snowflake__day_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_name.sql", "original_file_path": "macros/calendar_date/day_name.sql", "name": "snowflake__day_name", "macro_sql": "\n\n{%- macro snowflake__day_name(date, short) -%}\n {%- if short -%}\n dayname({{ date }})\n {%- else -%}\n -- long version not implemented on Snowflake so we're doing it manually :/\n case dayname({{ date }})\n when 'Mon' then 'Monday'\n when 'Tue' then 'Tuesday'\n when 'Wed' then 'Wednesday'\n when 'Thu' then 'Thursday'\n when 'Fri' then 'Friday'\n when 'Sat' then 'Saturday'\n when 'Sun' then 'Sunday'\n end\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.473547, "supported_languages": null}, "macro.dbt_date.bigquery__day_name": {"unique_id": "macro.dbt_date.bigquery__day_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_name.sql", "original_file_path": "macros/calendar_date/day_name.sql", "name": "bigquery__day_name", "macro_sql": "\n\n{%- macro bigquery__day_name(date, short) -%}\n{%- set f = '%a' if short else '%A' -%}\n format_date('{{ f }}', cast({{ date }} as date))\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.473726, "supported_languages": null}, "macro.dbt_date.postgres__day_name": {"unique_id": "macro.dbt_date.postgres__day_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_name.sql", "original_file_path": "macros/calendar_date/day_name.sql", "name": "postgres__day_name", "macro_sql": "\n\n{%- macro postgres__day_name(date, short) -%}\n{# FM = Fill mode, which suppresses padding blanks #}\n{%- set f = 'FMDy' if short else 'FMDay' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4739048, "supported_languages": null}, "macro.dbt_date.to_unixtimestamp": {"unique_id": "macro.dbt_date.to_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/to_unixtimestamp.sql", "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", "name": "to_unixtimestamp", "macro_sql": "{%- macro to_unixtimestamp(timestamp) -%}\n {{ adapter.dispatch('to_unixtimestamp', 'dbt_date') (timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.snowflake__to_unixtimestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4742432, "supported_languages": null}, "macro.dbt_date.default__to_unixtimestamp": {"unique_id": "macro.dbt_date.default__to_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/to_unixtimestamp.sql", "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", "name": "default__to_unixtimestamp", "macro_sql": "\n\n{%- macro default__to_unixtimestamp(timestamp) -%}\n {{ dbt_date.date_part('epoch', timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.474366, "supported_languages": null}, "macro.dbt_date.snowflake__to_unixtimestamp": {"unique_id": "macro.dbt_date.snowflake__to_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/to_unixtimestamp.sql", "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", "name": "snowflake__to_unixtimestamp", "macro_sql": "\n\n{%- macro snowflake__to_unixtimestamp(timestamp) -%}\n {{ dbt_date.date_part('epoch_seconds', timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.474489, "supported_languages": null}, "macro.dbt_date.bigquery__to_unixtimestamp": {"unique_id": "macro.dbt_date.bigquery__to_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/to_unixtimestamp.sql", "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", "name": "bigquery__to_unixtimestamp", "macro_sql": "\n\n{%- macro bigquery__to_unixtimestamp(timestamp) -%}\n unix_seconds({{ timestamp }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.474578, "supported_languages": null}, "macro.dbt_date.n_days_away": {"unique_id": "macro.dbt_date.n_days_away", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_days_away.sql", "original_file_path": "macros/calendar_date/n_days_away.sql", "name": "n_days_away", "macro_sql": "{%- macro n_days_away(n, date=None, tz=None) -%}\n{{ dbt_date.n_days_ago(-1 * n, date, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_days_ago"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4748569, "supported_languages": null}, "macro.dbt_date.week_start": {"unique_id": "macro.dbt_date.week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_start.sql", "original_file_path": "macros/calendar_date/week_start.sql", "name": "week_start", "macro_sql": "{%- macro week_start(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_start', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__week_start"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4753358, "supported_languages": null}, "macro.dbt_date.default__week_start": {"unique_id": "macro.dbt_date.default__week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_start.sql", "original_file_path": "macros/calendar_date/week_start.sql", "name": "default__week_start", "macro_sql": "{%- macro default__week_start(date) -%}\ncast({{ dbt.date_trunc('week', date) }} as date)\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.475467, "supported_languages": null}, "macro.dbt_date.snowflake__week_start": {"unique_id": "macro.dbt_date.snowflake__week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_start.sql", "original_file_path": "macros/calendar_date/week_start.sql", "name": "snowflake__week_start", "macro_sql": "\n\n{%- macro snowflake__week_start(date) -%}\n {#\n Get the day of week offset: e.g. if the date is a Sunday,\n dbt_date.day_of_week returns 1, so we subtract 1 to get a 0 offset\n #}\n {% set off_set = dbt_date.day_of_week(date, isoweek=False) ~ \" - 1\" %}\n cast({{ dbt.dateadd(\"day\", \"-1 * (\" ~ off_set ~ \")\", date) }} as date)\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.day_of_week", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.475729, "supported_languages": null}, "macro.dbt_date.postgres__week_start": {"unique_id": "macro.dbt_date.postgres__week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_start.sql", "original_file_path": "macros/calendar_date/week_start.sql", "name": "postgres__week_start", "macro_sql": "\n\n{%- macro postgres__week_start(date) -%}\n-- Sunday as week start date\ncast({{ dbt.dateadd('day', -1, dbt.date_trunc('week', dbt.dateadd('day', 1, date))) }} as date)\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.47596, "supported_languages": null}, "macro.dbt_date.iso_week_start": {"unique_id": "macro.dbt_date.iso_week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_start.sql", "original_file_path": "macros/calendar_date/iso_week_start.sql", "name": "iso_week_start", "macro_sql": "{%- macro iso_week_start(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_start', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__iso_week_start"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.476455, "supported_languages": null}, "macro.dbt_date._iso_week_start": {"unique_id": "macro.dbt_date._iso_week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_start.sql", "original_file_path": "macros/calendar_date/iso_week_start.sql", "name": "_iso_week_start", "macro_sql": "{%- macro _iso_week_start(date, week_type) -%}\ncast({{ dbt.date_trunc(week_type, date) }} as date)\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.476594, "supported_languages": null}, "macro.dbt_date.default__iso_week_start": {"unique_id": "macro.dbt_date.default__iso_week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_start.sql", "original_file_path": "macros/calendar_date/iso_week_start.sql", "name": "default__iso_week_start", "macro_sql": "\n\n{%- macro default__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'isoweek') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_start"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.476717, "supported_languages": null}, "macro.dbt_date.snowflake__iso_week_start": {"unique_id": "macro.dbt_date.snowflake__iso_week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_start.sql", "original_file_path": "macros/calendar_date/iso_week_start.sql", "name": "snowflake__iso_week_start", "macro_sql": "\n\n{%- macro snowflake__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'week') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_start"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4768388, "supported_languages": null}, "macro.dbt_date.postgres__iso_week_start": {"unique_id": "macro.dbt_date.postgres__iso_week_start", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_start.sql", "original_file_path": "macros/calendar_date/iso_week_start.sql", "name": "postgres__iso_week_start", "macro_sql": "\n\n{%- macro postgres__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'week') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_start"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4769568, "supported_languages": null}, "macro.dbt_date.n_days_ago": {"unique_id": "macro.dbt_date.n_days_ago", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_days_ago.sql", "original_file_path": "macros/calendar_date/n_days_ago.sql", "name": "n_days_ago", "macro_sql": "{%- macro n_days_ago(n, date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{%- set n = n|int -%}\ncast({{ dbt.dateadd('day', -1 * n, dt) }} as date)\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.477376, "supported_languages": null}, "macro.dbt_date.last_week": {"unique_id": "macro.dbt_date.last_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/last_week.sql", "original_file_path": "macros/calendar_date/last_week.sql", "name": "last_week", "macro_sql": "{%- macro last_week(tz=None) -%}\n{{ dbt_date.n_weeks_ago(1, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_weeks_ago"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4775949, "supported_languages": null}, "macro.dbt_date.now": {"unique_id": "macro.dbt_date.now", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/now.sql", "original_file_path": "macros/calendar_date/now.sql", "name": "now", "macro_sql": "{%- macro now(tz=None) -%}\n{{ dbt_date.convert_timezone(dbt.current_timestamp(), tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.convert_timezone", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.477835, "supported_languages": null}, "macro.dbt_date.periods_since": {"unique_id": "macro.dbt_date.periods_since", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/periods_since.sql", "original_file_path": "macros/calendar_date/periods_since.sql", "name": "periods_since", "macro_sql": "{%- macro periods_since(date_col, period_name='day', tz=None) -%}\n{{ dbt.datediff(date_col, dbt_date.now(tz), period_name) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt_date.now"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4781928, "supported_languages": null}, "macro.dbt_date.today": {"unique_id": "macro.dbt_date.today", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/today.sql", "original_file_path": "macros/calendar_date/today.sql", "name": "today", "macro_sql": "{%- macro today(tz=None) -%}\ncast({{ dbt_date.now(tz) }} as date)\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.now"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.478407, "supported_languages": null}, "macro.dbt_date.last_month": {"unique_id": "macro.dbt_date.last_month", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/last_month.sql", "original_file_path": "macros/calendar_date/last_month.sql", "name": "last_month", "macro_sql": "{%- macro last_month(tz=None) -%}\n{{ dbt_date.n_months_ago(1, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_months_ago"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.478626, "supported_languages": null}, "macro.dbt_date.day_of_year": {"unique_id": "macro.dbt_date.day_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_year.sql", "original_file_path": "macros/calendar_date/day_of_year.sql", "name": "day_of_year", "macro_sql": "{%- macro day_of_year(date) -%}\n{{ adapter.dispatch('day_of_year', 'dbt_date') (date) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__day_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.478961, "supported_languages": null}, "macro.dbt_date.default__day_of_year": {"unique_id": "macro.dbt_date.default__day_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_year.sql", "original_file_path": "macros/calendar_date/day_of_year.sql", "name": "default__day_of_year", "macro_sql": "\n\n{%- macro default__day_of_year(date) -%}\n {{ dbt_date.date_part('dayofyear', date) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4790819, "supported_languages": null}, "macro.dbt_date.postgres__day_of_year": {"unique_id": "macro.dbt_date.postgres__day_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_year.sql", "original_file_path": "macros/calendar_date/day_of_year.sql", "name": "postgres__day_of_year", "macro_sql": "\n\n{%- macro postgres__day_of_year(date) -%}\n {{ dbt_date.date_part('doy', date) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4792051, "supported_languages": null}, "macro.dbt_date.redshift__day_of_year": {"unique_id": "macro.dbt_date.redshift__day_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_year.sql", "original_file_path": "macros/calendar_date/day_of_year.sql", "name": "redshift__day_of_year", "macro_sql": "\n\n{%- macro redshift__day_of_year(date) -%}\n cast({{ dbt_date.date_part('dayofyear', date) }} as {{ dbt.type_bigint() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4793658, "supported_languages": null}, "macro.dbt_date.round_timestamp": {"unique_id": "macro.dbt_date.round_timestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/round_timestamp.sql", "original_file_path": "macros/calendar_date/round_timestamp.sql", "name": "round_timestamp", "macro_sql": "{% macro round_timestamp(timestamp) %}\n {{ dbt.date_trunc(\"day\", dbt.dateadd(\"hour\", 12, timestamp)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.479635, "supported_languages": null}, "macro.dbt_date.from_unixtimestamp": {"unique_id": "macro.dbt_date.from_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/from_unixtimestamp.sql", "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", "name": "from_unixtimestamp", "macro_sql": "{%- macro from_unixtimestamp(epochs, format=\"seconds\") -%}\n {{ adapter.dispatch('from_unixtimestamp', 'dbt_date') (epochs, format) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.snowflake__from_unixtimestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.480735, "supported_languages": null}, "macro.dbt_date.default__from_unixtimestamp": {"unique_id": "macro.dbt_date.default__from_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/from_unixtimestamp.sql", "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", "name": "default__from_unixtimestamp", "macro_sql": "\n\n{%- macro default__from_unixtimestamp(epochs, format=\"seconds\") -%}\n {%- if format != \"seconds\" -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n to_timestamp({{ epochs }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.480972, "supported_languages": null}, "macro.dbt_date.postgres__from_unixtimestamp": {"unique_id": "macro.dbt_date.postgres__from_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/from_unixtimestamp.sql", "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", "name": "postgres__from_unixtimestamp", "macro_sql": "\n\n{%- macro postgres__from_unixtimestamp(epochs, format=\"seconds\") -%}\n {%- if format != \"seconds\" -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n cast(to_timestamp({{ epochs }}) at time zone 'UTC' as timestamp)\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.481205, "supported_languages": null}, "macro.dbt_date.snowflake__from_unixtimestamp": {"unique_id": "macro.dbt_date.snowflake__from_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/from_unixtimestamp.sql", "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", "name": "snowflake__from_unixtimestamp", "macro_sql": "\n\n{%- macro snowflake__from_unixtimestamp(epochs, format) -%}\n {%- if format == \"seconds\" -%}\n {%- set scale = 0 -%}\n {%- elif format == \"milliseconds\" -%}\n {%- set scale = 3 -%}\n {%- elif format == \"microseconds\" -%}\n {%- set scale = 6 -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n to_timestamp_ntz({{ epochs }}, {{ scale }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.481615, "supported_languages": null}, "macro.dbt_date.bigquery__from_unixtimestamp": {"unique_id": "macro.dbt_date.bigquery__from_unixtimestamp", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/from_unixtimestamp.sql", "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", "name": "bigquery__from_unixtimestamp", "macro_sql": "\n\n{%- macro bigquery__from_unixtimestamp(epochs, format) -%}\n {%- if format == \"seconds\" -%}\n timestamp_seconds({{ epochs }})\n {%- elif format == \"milliseconds\" -%}\n timestamp_millis({{ epochs }})\n {%- elif format == \"microseconds\" -%}\n timestamp_micros({{ epochs }})\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4819598, "supported_languages": null}, "macro.dbt_date.n_months_ago": {"unique_id": "macro.dbt_date.n_months_ago", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_months_ago.sql", "original_file_path": "macros/calendar_date/n_months_ago.sql", "name": "n_months_ago", "macro_sql": "{%- macro n_months_ago(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('month',\n dbt.dateadd('month', -1 * n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd", "macro.dbt_date.today"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.48235, "supported_languages": null}, "macro.dbt_date.date_part": {"unique_id": "macro.dbt_date.date_part", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/date_part.sql", "original_file_path": "macros/calendar_date/date_part.sql", "name": "date_part", "macro_sql": "{% macro date_part(datepart, date) -%}\n {{ adapter.dispatch('date_part', 'dbt_date') (datepart, date) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.482671, "supported_languages": null}, "macro.dbt_date.default__date_part": {"unique_id": "macro.dbt_date.default__date_part", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/date_part.sql", "original_file_path": "macros/calendar_date/date_part.sql", "name": "default__date_part", "macro_sql": "{% macro default__date_part(datepart, date) -%}\n date_part('{{ datepart }}', {{ date }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4827871, "supported_languages": null}, "macro.dbt_date.bigquery__date_part": {"unique_id": "macro.dbt_date.bigquery__date_part", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/date_part.sql", "original_file_path": "macros/calendar_date/date_part.sql", "name": "bigquery__date_part", "macro_sql": "{% macro bigquery__date_part(datepart, date) -%}\n extract({{ datepart }} from {{ date }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.482903, "supported_languages": null}, "macro.dbt_date.n_weeks_away": {"unique_id": "macro.dbt_date.n_weeks_away", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_weeks_away.sql", "original_file_path": "macros/calendar_date/n_weeks_away.sql", "name": "n_weeks_away", "macro_sql": "{%- macro n_weeks_away(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('week',\n dbt.dateadd('week', n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd", "macro.dbt_date.today"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.48327, "supported_languages": null}, "macro.dbt_date.day_of_month": {"unique_id": "macro.dbt_date.day_of_month", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_month.sql", "original_file_path": "macros/calendar_date/day_of_month.sql", "name": "day_of_month", "macro_sql": "{%- macro day_of_month(date) -%}\n{{ dbt_date.date_part('day', date) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.483518, "supported_languages": null}, "macro.dbt_date.redshift__day_of_month": {"unique_id": "macro.dbt_date.redshift__day_of_month", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_month.sql", "original_file_path": "macros/calendar_date/day_of_month.sql", "name": "redshift__day_of_month", "macro_sql": "\n\n{%- macro redshift__day_of_month(date) -%}\ncast({{ dbt_date.date_part('day', date) }} as {{ dbt.type_bigint() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.483743, "supported_languages": null}, "macro.dbt_date.yesterday": {"unique_id": "macro.dbt_date.yesterday", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/yesterday.sql", "original_file_path": "macros/calendar_date/yesterday.sql", "name": "yesterday", "macro_sql": "{%- macro yesterday(date=None, tz=None) -%}\n{{ dbt_date.n_days_ago(1, date, tz) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.n_days_ago"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.484002, "supported_languages": null}, "macro.dbt_date.day_of_week": {"unique_id": "macro.dbt_date.day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "day_of_week", "macro_sql": "{%- macro day_of_week(date, isoweek=true) -%}\n{{ adapter.dispatch('day_of_week', 'dbt_date') (date, isoweek) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.snowflake__day_of_week"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.485564, "supported_languages": null}, "macro.dbt_date.default__day_of_week": {"unique_id": "macro.dbt_date.default__day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "default__day_of_week", "macro_sql": "\n\n{%- macro default__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (0) to Monday (1)\n when {{ dow }} = 0 then 7\n else {{ dow }}\n end\n {%- else -%}\n {{ dow }} + 1\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.485824, "supported_languages": null}, "macro.dbt_date.snowflake__day_of_week": {"unique_id": "macro.dbt_date.snowflake__day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "snowflake__day_of_week", "macro_sql": "\n\n{%- macro snowflake__day_of_week(date, isoweek) -%}\n\n {%- if isoweek -%}\n {%- set dow_part = 'dayofweekiso' -%}\n {{ dbt_date.date_part(dow_part, date) }}\n {%- else -%}\n {%- set dow_part = 'dayofweek' -%}\n case\n when {{ dbt_date.date_part(dow_part, date) }} = 7 then 1\n else {{ dbt_date.date_part(dow_part, date) }} + 1\n end\n {%- endif -%}\n\n\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.486185, "supported_languages": null}, "macro.dbt_date.bigquery__day_of_week": {"unique_id": "macro.dbt_date.bigquery__day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "bigquery__day_of_week", "macro_sql": "\n\n{%- macro bigquery__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (1) to Monday (2)\n when {{ dow }} = 1 then 7\n else {{ dow }} - 1\n end\n {%- else -%}\n {{ dow }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.486441, "supported_languages": null}, "macro.dbt_date.postgres__day_of_week": {"unique_id": "macro.dbt_date.postgres__day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "postgres__day_of_week", "macro_sql": "\n\n\n{%- macro postgres__day_of_week(date, isoweek) -%}\n\n {%- if isoweek -%}\n {%- set dow_part = 'isodow' -%}\n -- Monday(1) to Sunday (7)\n cast({{ dbt_date.date_part(dow_part, date) }} as {{ dbt.type_int() }})\n {%- else -%}\n {%- set dow_part = 'dow' -%}\n -- Sunday(1) to Saturday (7)\n cast({{ dbt_date.date_part(dow_part, date) }} + 1 as {{ dbt.type_int() }})\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.486822, "supported_languages": null}, "macro.dbt_date.redshift__day_of_week": {"unique_id": "macro.dbt_date.redshift__day_of_week", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/day_of_week.sql", "original_file_path": "macros/calendar_date/day_of_week.sql", "name": "redshift__day_of_week", "macro_sql": "\n\n\n{%- macro redshift__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (0) to Monday (1)\n when {{ dow }} = 0 then 7\n else cast({{ dow }} as {{ dbt.type_bigint() }})\n end\n {%- else -%}\n cast({{ dow }} + 1 as {{ dbt.type_bigint() }})\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.487146, "supported_languages": null}, "macro.dbt_date.iso_week_end": {"unique_id": "macro.dbt_date.iso_week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_end.sql", "original_file_path": "macros/calendar_date/iso_week_end.sql", "name": "iso_week_end", "macro_sql": "{%- macro iso_week_end(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_end', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__iso_week_end"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.487617, "supported_languages": null}, "macro.dbt_date._iso_week_end": {"unique_id": "macro.dbt_date._iso_week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_end.sql", "original_file_path": "macros/calendar_date/iso_week_end.sql", "name": "_iso_week_end", "macro_sql": "{%- macro _iso_week_end(date, week_type) -%}\n{%- set dt = dbt_date.iso_week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.iso_week_start", "macro.dbt_date.n_days_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.487803, "supported_languages": null}, "macro.dbt_date.default__iso_week_end": {"unique_id": "macro.dbt_date.default__iso_week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_end.sql", "original_file_path": "macros/calendar_date/iso_week_end.sql", "name": "default__iso_week_end", "macro_sql": "\n\n{%- macro default__iso_week_end(date) -%}\n{{ dbt_date._iso_week_end(date, 'isoweek') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_end"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.487923, "supported_languages": null}, "macro.dbt_date.snowflake__iso_week_end": {"unique_id": "macro.dbt_date.snowflake__iso_week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_end.sql", "original_file_path": "macros/calendar_date/iso_week_end.sql", "name": "snowflake__iso_week_end", "macro_sql": "\n\n{%- macro snowflake__iso_week_end(date) -%}\n{{ dbt_date._iso_week_end(date, 'weekiso') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_end"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4880419, "supported_languages": null}, "macro.dbt_date.n_weeks_ago": {"unique_id": "macro.dbt_date.n_weeks_ago", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_weeks_ago.sql", "original_file_path": "macros/calendar_date/n_weeks_ago.sql", "name": "n_weeks_ago", "macro_sql": "{%- macro n_weeks_ago(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('week',\n dbt.dateadd('week', -1 * n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd", "macro.dbt_date.today"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.488433, "supported_languages": null}, "macro.dbt_date.month_name": {"unique_id": "macro.dbt_date.month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/month_name.sql", "original_file_path": "macros/calendar_date/month_name.sql", "name": "month_name", "macro_sql": "{%- macro month_name(date, short=True) -%}\n {{ adapter.dispatch('month_name', 'dbt_date') (date, short) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.snowflake__month_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4889128, "supported_languages": null}, "macro.dbt_date.default__month_name": {"unique_id": "macro.dbt_date.default__month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/month_name.sql", "original_file_path": "macros/calendar_date/month_name.sql", "name": "default__month_name", "macro_sql": "\n\n{%- macro default__month_name(date, short) -%}\n{%- set f = 'MON' if short else 'MONTH' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.489092, "supported_languages": null}, "macro.dbt_date.bigquery__month_name": {"unique_id": "macro.dbt_date.bigquery__month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/month_name.sql", "original_file_path": "macros/calendar_date/month_name.sql", "name": "bigquery__month_name", "macro_sql": "\n\n{%- macro bigquery__month_name(date, short) -%}\n{%- set f = '%b' if short else '%B' -%}\n format_date('{{ f }}', cast({{ date }} as date))\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.489274, "supported_languages": null}, "macro.dbt_date.snowflake__month_name": {"unique_id": "macro.dbt_date.snowflake__month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/month_name.sql", "original_file_path": "macros/calendar_date/month_name.sql", "name": "snowflake__month_name", "macro_sql": "\n\n{%- macro snowflake__month_name(date, short) -%}\n{%- set f = 'MON' if short else 'MMMM' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4894469, "supported_languages": null}, "macro.dbt_date.postgres__month_name": {"unique_id": "macro.dbt_date.postgres__month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/month_name.sql", "original_file_path": "macros/calendar_date/month_name.sql", "name": "postgres__month_name", "macro_sql": "\n\n{%- macro postgres__month_name(date, short) -%}\n{# FM = Fill mode, which suppresses padding blanks #}\n{%- set f = 'FMMon' if short else 'FMMonth' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.489629, "supported_languages": null}, "macro.dbt_date.last_month_name": {"unique_id": "macro.dbt_date.last_month_name", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/last_month_name.sql", "original_file_path": "macros/calendar_date/last_month_name.sql", "name": "last_month_name", "macro_sql": "{%- macro last_month_name(short=True, tz=None) -%}\n{{ dbt_date.month_name(dbt_date.last_month(tz), short=short) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.month_name", "macro.dbt_date.last_month"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.489913, "supported_languages": null}, "macro.dbt_date.week_of_year": {"unique_id": "macro.dbt_date.week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_of_year.sql", "original_file_path": "macros/calendar_date/week_of_year.sql", "name": "week_of_year", "macro_sql": "{%- macro week_of_year(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_of_year', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.default__week_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.490412, "supported_languages": null}, "macro.dbt_date.default__week_of_year": {"unique_id": "macro.dbt_date.default__week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_of_year.sql", "original_file_path": "macros/calendar_date/week_of_year.sql", "name": "default__week_of_year", "macro_sql": "{%- macro default__week_of_year(date) -%}\ncast({{ dbt_date.date_part('week', date) }} as {{ dbt.type_int() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.49058, "supported_languages": null}, "macro.dbt_date.postgres__week_of_year": {"unique_id": "macro.dbt_date.postgres__week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_of_year.sql", "original_file_path": "macros/calendar_date/week_of_year.sql", "name": "postgres__week_of_year", "macro_sql": "\n\n{%- macro postgres__week_of_year(date) -%}\n{# postgresql 'week' returns isoweek. Use to_char instead.\n WW = the first week starts on the first day of the year #}\ncast(to_char({{ date }}, 'WW') as {{ dbt.type_int() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.490711, "supported_languages": null}, "macro.dbt_date.convert_timezone": {"unique_id": "macro.dbt_date.convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "convert_timezone", "macro_sql": "{%- macro convert_timezone(column, target_tz=None, source_tz=None) -%}\n{%- set source_tz = \"UTC\" if not source_tz else source_tz -%}\n{%- set target_tz = var(\"dbt_date:time_zone\") if not target_tz else target_tz -%}\n{{ adapter.dispatch('convert_timezone', 'dbt_date') (column, target_tz, source_tz) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__convert_timezone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.491602, "supported_languages": null}, "macro.dbt_date.default__convert_timezone": {"unique_id": "macro.dbt_date.default__convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "default__convert_timezone", "macro_sql": "{% macro default__convert_timezone(column, target_tz, source_tz) -%}\nconvert_timezone('{{ source_tz }}', '{{ target_tz }}',\n cast({{ column }} as {{ dbt.type_timestamp() }})\n)\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.491783, "supported_languages": null}, "macro.dbt_date.bigquery__convert_timezone": {"unique_id": "macro.dbt_date.bigquery__convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "bigquery__convert_timezone", "macro_sql": "{%- macro bigquery__convert_timezone(column, target_tz, source_tz=None) -%}\ntimestamp(datetime({{ column }}, '{{ target_tz}}'))\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.491916, "supported_languages": null}, "macro.dbt_date.spark__convert_timezone": {"unique_id": "macro.dbt_date.spark__convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "spark__convert_timezone", "macro_sql": "{%- macro spark__convert_timezone(column, target_tz, source_tz) -%}\nfrom_utc_timestamp(\n to_utc_timestamp({{ column }}, '{{ source_tz }}'),\n '{{ target_tz }}'\n )\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.492057, "supported_languages": null}, "macro.dbt_date.postgres__convert_timezone": {"unique_id": "macro.dbt_date.postgres__convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "postgres__convert_timezone", "macro_sql": "{% macro postgres__convert_timezone(column, target_tz, source_tz) -%}\ncast(\n cast({{ column }} as {{ dbt.type_timestamp() }})\n at time zone '{{ source_tz }}' at time zone '{{ target_tz }}' as {{ dbt.type_timestamp() }}\n)\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.492269, "supported_languages": null}, "macro.dbt_date.redshift__convert_timezone": {"unique_id": "macro.dbt_date.redshift__convert_timezone", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/convert_timezone.sql", "original_file_path": "macros/calendar_date/convert_timezone.sql", "name": "redshift__convert_timezone", "macro_sql": "{%- macro redshift__convert_timezone(column, target_tz, source_tz) -%}\n{{ return(dbt_date.default__convert_timezone(column, target_tz, source_tz)) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.default__convert_timezone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4924428, "supported_languages": null}, "macro.dbt_date.n_months_away": {"unique_id": "macro.dbt_date.n_months_away", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/n_months_away.sql", "original_file_path": "macros/calendar_date/n_months_away.sql", "name": "n_months_away", "macro_sql": "{%- macro n_months_away(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('month',\n dbt.dateadd('month', n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd", "macro.dbt_date.today"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4928231, "supported_languages": null}, "macro.dbt_date.iso_week_of_year": {"unique_id": "macro.dbt_date.iso_week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_of_year.sql", "original_file_path": "macros/calendar_date/iso_week_of_year.sql", "name": "iso_week_of_year", "macro_sql": "{%- macro iso_week_of_year(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_of_year', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__iso_week_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.493365, "supported_languages": null}, "macro.dbt_date._iso_week_of_year": {"unique_id": "macro.dbt_date._iso_week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_of_year.sql", "original_file_path": "macros/calendar_date/iso_week_of_year.sql", "name": "_iso_week_of_year", "macro_sql": "{%- macro _iso_week_of_year(date, week_type) -%}\ncast({{ dbt_date.date_part(week_type, date) }} as {{ dbt.type_int() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.493539, "supported_languages": null}, "macro.dbt_date.default__iso_week_of_year": {"unique_id": "macro.dbt_date.default__iso_week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_of_year.sql", "original_file_path": "macros/calendar_date/iso_week_of_year.sql", "name": "default__iso_week_of_year", "macro_sql": "\n\n{%- macro default__iso_week_of_year(date) -%}\n{{ dbt_date._iso_week_of_year(date, 'isoweek') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.493663, "supported_languages": null}, "macro.dbt_date.snowflake__iso_week_of_year": {"unique_id": "macro.dbt_date.snowflake__iso_week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_of_year.sql", "original_file_path": "macros/calendar_date/iso_week_of_year.sql", "name": "snowflake__iso_week_of_year", "macro_sql": "\n\n{%- macro snowflake__iso_week_of_year(date) -%}\n{{ dbt_date._iso_week_of_year(date, 'weekiso') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4937851, "supported_languages": null}, "macro.dbt_date.postgres__iso_week_of_year": {"unique_id": "macro.dbt_date.postgres__iso_week_of_year", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/iso_week_of_year.sql", "original_file_path": "macros/calendar_date/iso_week_of_year.sql", "name": "postgres__iso_week_of_year", "macro_sql": "\n\n{%- macro postgres__iso_week_of_year(date) -%}\n-- postgresql week is isoweek, the first week of a year containing January 4 of that year.\n{{ dbt_date._iso_week_of_year(date, 'week') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date._iso_week_of_year"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4939141, "supported_languages": null}, "macro.dbt_date.week_end": {"unique_id": "macro.dbt_date.week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_end.sql", "original_file_path": "macros/calendar_date/week_end.sql", "name": "week_end", "macro_sql": "{%- macro week_end(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_end', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__week_end"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.49439, "supported_languages": null}, "macro.dbt_date.default__week_end": {"unique_id": "macro.dbt_date.default__week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_end.sql", "original_file_path": "macros/calendar_date/week_end.sql", "name": "default__week_end", "macro_sql": "{%- macro default__week_end(date) -%}\n{{ last_day(date, 'week') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.494515, "supported_languages": null}, "macro.dbt_date.snowflake__week_end": {"unique_id": "macro.dbt_date.snowflake__week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_end.sql", "original_file_path": "macros/calendar_date/week_end.sql", "name": "snowflake__week_end", "macro_sql": "\n\n{%- macro snowflake__week_end(date) -%}\n{%- set dt = dbt_date.week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.week_start", "macro.dbt_date.n_days_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.49469, "supported_languages": null}, "macro.dbt_date.postgres__week_end": {"unique_id": "macro.dbt_date.postgres__week_end", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/week_end.sql", "original_file_path": "macros/calendar_date/week_end.sql", "name": "postgres__week_end", "macro_sql": "\n\n{%- macro postgres__week_end(date) -%}\n{%- set dt = dbt_date.week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.week_start", "macro.dbt_date.n_days_away"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.49487, "supported_languages": null}, "macro.dbt_date.next_month_number": {"unique_id": "macro.dbt_date.next_month_number", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/next_month_number.sql", "original_file_path": "macros/calendar_date/next_month_number.sql", "name": "next_month_number", "macro_sql": "{%- macro next_month_number(tz=None) -%}\n{{ dbt_date.date_part('month', dbt_date.next_month(tz)) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt_date.next_month"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.4951239, "supported_languages": null}, "macro.dbt_date.last_month_number": {"unique_id": "macro.dbt_date.last_month_number", "package_name": "dbt_date", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", "path": "macros/calendar_date/last_month_number.sql", "original_file_path": "macros/calendar_date/last_month_number.sql", "name": "last_month_number", "macro_sql": "{%- macro last_month_number(tz=None) -%}\n{{ dbt_date.date_part('month', dbt_date.last_month(tz)) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_date.date_part", "macro.dbt_date.last_month"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.495372, "supported_languages": null}, "macro.dbt_external_tables.bigquery__create_external_table": {"unique_id": "macro.dbt_external_tables.bigquery__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/bigquery/create_external_table.sql", "original_file_path": "macros/plugins/bigquery/create_external_table.sql", "name": "bigquery__create_external_table", "macro_sql": "{% macro bigquery__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n {%- set options = external.options -%}\n \n {%- set uris = [] -%}\n {%- if options is mapping and options.get('uris', none) -%}\n {%- set uris = external.options.get('uris') -%}\n {%- else -%}\n {%- set uris = [external.location] -%}\n {%- endif -%}\n\n create or replace external table {{source(source_node.source_name, source_node.name)}}\n {%- if columns -%}(\n {% for column in columns %}\n {%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %}\n {{column_quoted}} {{column.data_type}} {{- ',' if not loop.last -}}\n {%- endfor -%}\n )\n {% endif %}\n {% if options and options.get('hive_partition_uri_prefix', none) %}\n with partition columns {%- if partitions %} (\n {%- for partition in partitions %}\n {{partition.name}} {{partition.data_type}}{{',' if not loop.last}}\n {%- endfor -%}\n ) {% endif -%}\n {% endif %}\n options (\n uris = [{%- for uri in uris -%} '{{uri}}' {{- \",\" if not loop.last}} {%- endfor -%}]\n {%- if options is mapping -%}\n {%- for key, value in options.items() if key != 'uris' %}\n {%- if value is string -%}\n , {{key}} = '{{value}}'\n {%- else -%}\n , {{key}} = {{value}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.498086, "supported_languages": null}, "macro.dbt_external_tables.bigquery__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.bigquery__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/bigquery/get_external_build_plan.sql", "original_file_path": "macros/plugins/bigquery/get_external_build_plan.sql", "name": "bigquery__get_external_build_plan", "macro_sql": "{% macro bigquery__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n \n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [dbt_external_tables.create_external_table(source_node)] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.create_external_table", "macro.dbt_external_tables.refresh_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.498924, "supported_languages": null}, "macro.dbt_external_tables.snowflake__create_external_table": {"unique_id": "macro.dbt_external_tables.snowflake__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/create_external_table.sql", "original_file_path": "macros/plugins/snowflake/create_external_table.sql", "name": "snowflake__create_external_table", "macro_sql": "{% macro snowflake__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n\n {%- set is_csv = dbt_external_tables.is_csv(external.file_format) -%}\n\n{# https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html #}\n{# This assumes you have already created an external stage #}\n create or replace external table {{source(source_node.source_name, source_node.name)}}\n {%- if columns or partitions -%}\n (\n {%- if partitions -%}{%- for partition in partitions %}\n {{partition.name}} {{partition.data_type}} as {{partition.expression}}{{- ',' if not loop.last or columns|length > 0 -}}\n {%- endfor -%}{%- endif -%}\n {%- for column in columns %}\n {%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %}\n {%- set col_expression -%}\n {%- set col_id = 'value:c' ~ loop.index if is_csv else 'value:' ~ column_quoted -%}\n (case when is_null_value({{col_id}}) or lower({{col_id}}) = 'null' then null else {{col_id}} end)\n {%- endset %}\n {{column_quoted}} {{column.data_type}} as ({{col_expression}}::{{column.data_type}})\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n {%- endif -%}\n {% if partitions %} partition by ({{partitions|map(attribute='name')|join(', ')}}) {% endif %}\n location = {{external.location}} {# stage #}\n {% if external.auto_refresh in (true, false) -%}\n auto_refresh = {{external.auto_refresh}}\n {%- endif %}\n {% if external.pattern -%} pattern = '{{external.pattern}}' {%- endif %}\n {% if external.integration -%} integration = '{{external.integration}}' {%- endif %}\n file_format = {{external.file_format}}\n {% if external.table_format -%} table_format = '{{external.table_format}}' {%- endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.is_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.501194, "supported_languages": null}, "macro.dbt_external_tables.snowflake__refresh_external_table": {"unique_id": "macro.dbt_external_tables.snowflake__refresh_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/refresh_external_table.sql", "original_file_path": "macros/plugins/snowflake/refresh_external_table.sql", "name": "snowflake__refresh_external_table", "macro_sql": "{% macro snowflake__refresh_external_table(source_node) %}\n\n {% set external = source_node.external %}\n {% set snowpipe = source_node.external.get('snowpipe', none) %}\n \n {% set auto_refresh = external.get('auto_refresh', false) %}\n {% set partitions = external.get('partitions', none) %}\n \n {% set manual_refresh = (partitions and not auto_refresh) %}\n \n {% if manual_refresh %}\n\n {% set ddl %}\n begin;\n alter external table {{source(source_node.source_name, source_node.name)}} refresh;\n commit;\n {% endset %}\n \n {% do return([ddl]) %}\n \n {% else %}\n \n {% do return([]) %}\n \n {% endif %}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.502136, "supported_languages": null}, "macro.dbt_external_tables.snowflake__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.snowflake__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/get_external_build_plan.sql", "original_file_path": "macros/plugins/snowflake/get_external_build_plan.sql", "name": "snowflake__get_external_build_plan", "macro_sql": "{% macro snowflake__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n \n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if source_node.external.get('snowpipe', none) is not none %}\n \n {% if create_or_replace %}\n {% set build_plan = build_plan + [\n dbt_external_tables.snowflake_create_empty_table(source_node),\n dbt_external_tables.snowflake_get_copy_sql(source_node, explicit_transaction=true),\n dbt_external_tables.snowflake_create_snowpipe(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.snowflake_refresh_snowpipe(source_node) %}\n {% endif %}\n \n {% else %}\n \n {% if create_or_replace %}\n {% set build_plan = build_plan + [dbt_external_tables.create_external_table(source_node)] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n \n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.snowflake_create_empty_table", "macro.dbt_external_tables.snowflake_get_copy_sql", "macro.dbt_external_tables.snowflake_create_snowpipe", "macro.dbt_external_tables.snowflake_refresh_snowpipe", "macro.dbt_external_tables.create_external_table", "macro.dbt_external_tables.refresh_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.503582, "supported_languages": null}, "macro.dbt_external_tables.snowflake_create_snowpipe": {"unique_id": "macro.dbt_external_tables.snowflake_create_snowpipe", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/snowpipe/create_snowpipe.sql", "original_file_path": "macros/plugins/snowflake/snowpipe/create_snowpipe.sql", "name": "snowflake_create_snowpipe", "macro_sql": "{% macro snowflake_create_snowpipe(source_node) %}\n\n {%- set external = source_node.external -%}\n {%- set snowpipe = external.snowpipe -%}\n\n{# https://docs.snowflake.com/en/sql-reference/sql/create-pipe.html #}\n create or replace pipe {{source(source_node.source_name, source_node.name)}}\n {% if snowpipe.auto_ingest -%} auto_ingest = {{snowpipe.auto_ingest}} {%- endif %}\n {% if snowpipe.aws_sns_topic -%} aws_sns_topic = '{{snowpipe.aws_sns_topic}}' {%- endif %}\n {% if snowpipe.integration -%} integration = '{{snowpipe.integration}}' {%- endif %}\n {% if snowpipe.error_integration -%} error_integration = '{{snowpipe.error_integration}}' {%- endif %}\n as {{ dbt_external_tables.snowflake_get_copy_sql(source_node) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.snowflake_get_copy_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5043871, "supported_languages": null}, "macro.dbt_external_tables.snowflake_create_empty_table": {"unique_id": "macro.dbt_external_tables.snowflake_create_empty_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/snowpipe/create_empty_table.sql", "original_file_path": "macros/plugins/snowflake/snowpipe/create_empty_table.sql", "name": "snowflake_create_empty_table", "macro_sql": "{% macro snowflake_create_empty_table(source_node) %}\n\n {%- set columns = source_node.columns.values() %}\n\n create or replace table {{source(source_node.source_name, source_node.name)}} (\n {% if columns|length == 0 %}\n value variant,\n {% else -%}\n {%- for column in columns -%}\n {{column.name}} {{column.data_type}},\n {% endfor -%}\n {% endif %}\n metadata_filename varchar,\n metadata_file_row_number bigint,\n _dbt_copied_at timestamp\n );\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.504964, "supported_languages": null}, "macro.dbt_external_tables.snowflake_refresh_snowpipe": {"unique_id": "macro.dbt_external_tables.snowflake_refresh_snowpipe", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/snowpipe/refresh_snowpipe.sql", "original_file_path": "macros/plugins/snowflake/snowpipe/refresh_snowpipe.sql", "name": "snowflake_refresh_snowpipe", "macro_sql": "{% macro snowflake_refresh_snowpipe(source_node) %}\n\n {% set snowpipe = source_node.external.snowpipe %}\n {% set auto_ingest = snowpipe.get('auto_ingest', false) if snowpipe is mapping %}\n \n {% if auto_ingest is true %}\n \n {% do return([]) %}\n \n {% else %}\n \n {% set ddl %}\n alter pipe {{source(source_node.source_name, source_node.name)}} refresh\n {% endset %}\n \n {{ return([ddl]) }}\n \n {% endif %}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5056498, "supported_languages": null}, "macro.dbt_external_tables.snowflake_get_copy_sql": {"unique_id": "macro.dbt_external_tables.snowflake_get_copy_sql", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/snowpipe/get_copy_sql.sql", "original_file_path": "macros/plugins/snowflake/snowpipe/get_copy_sql.sql", "name": "snowflake_get_copy_sql", "macro_sql": "{% macro snowflake_get_copy_sql(source_node, explicit_transaction=false) %}\n{# This assumes you have already created an external stage #}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set is_csv = dbt_external_tables.is_csv(external.file_format) %}\n {%- set copy_options = external.snowpipe.get('copy_options', none) -%}\n \n {%- if explicit_transaction -%} begin; {%- endif %}\n \n copy into {{source(source_node.source_name, source_node.name)}}\n from ( \n select\n {% if columns|length == 0 %}\n $1::variant as value,\n {% else -%}\n {%- for column in columns -%}\n {%- set col_expression -%}\n {%- if is_csv -%}nullif(${{loop.index}},''){# special case: get columns by ordinal position #}\n {%- else -%}nullif($1:{{column.name}},''){# standard behavior: get columns by name #}\n {%- endif -%}\n {%- endset -%}\n {{col_expression}}::{{column.data_type}} as {{column.name}},\n {% endfor -%}\n {% endif %}\n metadata$filename::varchar as metadata_filename,\n metadata$file_row_number::bigint as metadata_file_row_number,\n current_timestamp::timestamp as _dbt_copied_at\n from {{external.location}} {# stage #}\n )\n file_format = {{external.file_format}}\n {% if external.pattern -%} pattern = '{{external.pattern}}' {%- endif %}\n {% if copy_options %} {{copy_options}} {% endif %};\n \n {% if explicit_transaction -%} commit; {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.is_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.507071, "supported_languages": null}, "macro.dbt_external_tables.is_csv": {"unique_id": "macro.dbt_external_tables.is_csv", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/snowflake/helpers/is_csv.sql", "original_file_path": "macros/plugins/snowflake/helpers/is_csv.sql", "name": "is_csv", "macro_sql": "{% macro is_csv(file_format) %}\n\n{# From https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html:\n\nImportant: The external table does not inherit the file format, if any, in the \nstage definition. You must explicitly specify any file format options for the \nexternal table using the FILE_FORMAT parameter.\n\nNote: FORMAT_NAME and TYPE are mutually exclusive; to avoid unintended behavior, \nyou should only specify one or the other when creating an external table.\n\n#}\n\n {% set ff_ltrimmed = file_format|lower|replace(' ','') %}\n\n {% if 'type=' in ff_ltrimmed %}\n \n {% if 'type=csv' in ff_ltrimmed %}\n\n {{return(true)}}\n\n {% else %}\n\n {{return(false)}}\n \n {% endif %}\n \n {% else %}\n \n {% set ff_standardized = ff_ltrimmed\n | replace('(','') | replace(')','')\n | replace('format_name=','') %}\n {% set fqn = ff_standardized.split('.') %}\n \n {% if fqn | length == 3 %}\n {% set ff_database, ff_schema, ff_identifier = fqn[0], fqn[1], fqn[2] %}\n {% elif fqn | length == 2 %}\n {% set ff_database, ff_schema, ff_identifier = target.database, fqn[0], fqn[1] %}\n {% else %}\n {% set ff_database, ff_schema, ff_identifier = target.database, target.schema, fqn[0] %}\n {% endif %}\n \n {% call statement('get_file_format', fetch_result = True) %}\n show file formats in {{ff_database}}.{{ff_schema}}\n {% endcall %}\n \n {% set ffs = load_result('get_file_format').table %}\n \n {% for ff in ffs %}\n \n {% if ff['name']|lower == ff_identifier and ff['type']|lower == 'csv' %}\n \n {{return(true)}}\n \n {% endif %}\n \n {% endfor %}\n \n {{return(false)}} \n \n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.509557, "supported_languages": null}, "macro.dbt_external_tables.redshift__create_external_table": {"unique_id": "macro.dbt_external_tables.redshift__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/create_external_table.sql", "original_file_path": "macros/plugins/redshift/create_external_table.sql", "name": "redshift__create_external_table", "macro_sql": "{% macro redshift__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n\n{# https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_TABLE.html #}\n{# This assumes you have already created an external schema #}\n\n create external table {{source(source_node.source_name, source_node.name)}} (\n {% for column in columns %}\n {{adapter.quote(column.name)}} {{column.data_type}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n {% if partitions -%} partitioned by (\n {%- for partition in partitions -%}\n {{adapter.quote(partition.name)}} {{partition.data_type}}{{', ' if not loop.last}}\n {%- endfor -%}\n ) {%- endif %}\n {% if external.row_format -%} row format {{external.row_format}} {%- endif %}\n {% if external.file_format -%} stored as {{external.file_format}} {%- endif %}\n {% if external.location -%} location '{{external.location}}' {%- endif %}\n {% if external.table_properties -%} table properties {{external.table_properties}} {%- endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.510957, "supported_languages": null}, "macro.dbt_external_tables.redshift__refresh_external_table": {"unique_id": "macro.dbt_external_tables.redshift__refresh_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/refresh_external_table.sql", "original_file_path": "macros/plugins/redshift/refresh_external_table.sql", "name": "redshift__refresh_external_table", "macro_sql": "{% macro redshift__refresh_external_table(source_node) %}\n\n {%- set partitions = source_node.external.get('partitions',[]) -%}\n\n {%- if partitions -%}\n \n {%- set part_len = partitions|length -%}\n \n {%- set get_partitions_sql -%}\n \n select * from\n \n {%- for partition in partitions %} (\n \n {%- set part_num = loop.index -%}\n \n {%- if partition.vals.macro -%}\n {%- set vals = dbt_external_tables.render_from_context(partition.vals.macro, **partition.vals.args) -%}\n {%- elif partition.vals is string -%}\n {%- set vals = [partition.vals] -%}\n {%- else -%}\n {%- set vals = partition.vals -%}\n {%- endif -%}\n \n {%- for val in vals %}\n \n select\n '\"{{ partition.name }}\"' as name_{{ part_num }},\n '\"{{ val }}\"' as val_{{ part_num }},\n '\"{{ dbt_external_tables.render_from_context(partition.path_macro, partition.name, val) }}\"' as path_{{ part_num }}\n \n {{ 'union all' if not loop.last else ') ' }}\n \n {%- endfor -%}\n \n {{ 'cross join' if not loop.last }}\n \n {%- endfor -%}\n \n {%- endset -%}\n \n {%- set finals = [] -%}\n \n {%- if execute -%}\n {%- set results = run_query(get_partitions_sql) -%}\n {%- for row in results -%}\n \n {%- set partition_parts = [] -%}\n {%- set path_parts = [] -%}\n \n {%- for i in range(0, part_len) -%}\n {%- do partition_parts.append({\n 'name': row[i * 3][1:-1],\n 'value': row[i * 3 + 1][1:-1]\n }) -%}\n {%- do path_parts.append(row[i * 3 + 2][1:-1]) -%}\n {%- endfor -%}\n \n {%- set construct = {\n 'partition_by': partition_parts,\n 'path': path_parts | join('/')\n } -%}\n \n {% do finals.append(construct) %}\n {%- endfor -%}\n {%- endif -%}\n \n {%- set ddl = dbt_external_tables.redshift_alter_table_add_partitions(source_node, finals) -%}\n {{ return(ddl) }}\n \n {% else %}\n \n {% do return([]) %}\n \n {% endif %}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.render_from_context", "macro.dbt.run_query", "macro.dbt_external_tables.redshift_alter_table_add_partitions"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.515245, "supported_languages": null}, "macro.dbt_external_tables.redshift__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.redshift__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/get_external_build_plan.sql", "original_file_path": "macros/plugins/redshift/get_external_build_plan.sql", "name": "redshift__get_external_build_plan", "macro_sql": "{% macro redshift__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set create_or_replace = (var('ext_full_refresh', false) or not redshift_is_ext_tbl(source_node)) %}\n \n {% if create_or_replace %}\n\n {% set build_plan = [\n dbt_external_tables.dropif(source_node),\n dbt_external_tables.create_external_table(source_node)\n ] + dbt_external_tables.refresh_external_table(source_node) \n %}\n \n {% else %}\n \n {% set build_plan = dbt_external_tables.refresh_external_table(source_node) %}\n \n {% endif %}\n \n {% do return(build_plan) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.redshift_is_ext_tbl", "macro.dbt_external_tables.dropif", "macro.dbt_external_tables.create_external_table", "macro.dbt_external_tables.refresh_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5159948, "supported_languages": null}, "macro.dbt_external_tables.render_from_context": {"unique_id": "macro.dbt_external_tables.render_from_context", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/render_macro.sql", "original_file_path": "macros/plugins/redshift/helpers/render_macro.sql", "name": "render_from_context", "macro_sql": "{% macro render_from_context(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called by macro '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n \n {{ return(package_context[name](*varargs, **kwargs)) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.517011, "supported_languages": null}, "macro.dbt_external_tables.redshift__dropif": {"unique_id": "macro.dbt_external_tables.redshift__dropif", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/dropif.sql", "original_file_path": "macros/plugins/redshift/helpers/dropif.sql", "name": "redshift__dropif", "macro_sql": "{% macro redshift__dropif(node) %}\n \n {% set ddl %}\n drop table if exists {{source(node.source_name, node.name)}} cascade\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5173419, "supported_languages": null}, "macro.dbt_external_tables.redshift_alter_table_add_partitions": {"unique_id": "macro.dbt_external_tables.redshift_alter_table_add_partitions", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/add_partitions.sql", "original_file_path": "macros/plugins/redshift/helpers/add_partitions.sql", "name": "redshift_alter_table_add_partitions", "macro_sql": "{% macro redshift_alter_table_add_partitions(source_node, partitions) %}\n\n {{ log(\"Generating ADD PARTITION statement for partition set between \" \n ~ partitions[0]['path'] ~ \" and \" ~ (partitions|last)['path']) }}\n\n {% set ddl = [] %}\n \n {% if partitions|length > 0 %}\n \n {% set alter_table_add %}\n alter table {{source(source_node.source_name, source_node.name)}} add if not exists \n {% endset %}\n \n {%- set alters -%}\n\n {{ alter_table_add }}\n\n {%- for partition in partitions -%}\n\n {%- if loop.index0 != 0 and loop.index0 % 100 == 0 -%}\n\n ; {{ alter_table_add }}\n\n {%- endif -%}\n\n partition ({%- for part in partition.partition_by -%}{{ part.name }}='{{ part.value }}'{{', ' if not loop.last}}{%- endfor -%})\n location '{{ source_node.external.location }}/{{ partition.path }}/'\n\n {% endfor -%}\n \n {%- endset -%}\n \n {% set ddl = ddl + alters.split(';') %}\n\n {% else %}\n\n {{ log(\"No partitions to be added\") }}\n\n {% endif %}\n \n {% do return(ddl) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.518868, "supported_languages": null}, "macro.dbt_external_tables.redshift__exit_transaction": {"unique_id": "macro.dbt_external_tables.redshift__exit_transaction", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/transaction.sql", "original_file_path": "macros/plugins/redshift/helpers/transaction.sql", "name": "redshift__exit_transaction", "macro_sql": "{% macro redshift__exit_transaction() %}\n {{ return('begin; commit;') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.519074, "supported_languages": null}, "macro.dbt_external_tables.year_month_day": {"unique_id": "macro.dbt_external_tables.year_month_day", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/paths.sql", "original_file_path": "macros/plugins/redshift/helpers/paths.sql", "name": "year_month_day", "macro_sql": "{% macro year_month_day(name, value) %}\n {% set path = value.replace('-','/') %}\n {{return(path)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.519433, "supported_languages": null}, "macro.dbt_external_tables.key_value": {"unique_id": "macro.dbt_external_tables.key_value", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/paths.sql", "original_file_path": "macros/plugins/redshift/helpers/paths.sql", "name": "key_value", "macro_sql": "{% macro key_value(name, value) %}\n {% set path = name ~ '=' ~ value %}\n {{return(path)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.519607, "supported_languages": null}, "macro.dbt_external_tables.value_only": {"unique_id": "macro.dbt_external_tables.value_only", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/paths.sql", "original_file_path": "macros/plugins/redshift/helpers/paths.sql", "name": "value_only", "macro_sql": "{% macro value_only(name, value) %}\n {% set path = value %}\n {{return(path)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.519756, "supported_languages": null}, "macro.dbt_external_tables.redshift_is_ext_tbl": {"unique_id": "macro.dbt_external_tables.redshift_is_ext_tbl", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/redshift/helpers/is_ext_tbl.sql", "original_file_path": "macros/plugins/redshift/helpers/is_ext_tbl.sql", "name": "redshift_is_ext_tbl", "macro_sql": "{% macro redshift_is_ext_tbl(node) %}\n\n {% set existing_relation = load_relation(node) %}\n \n {# external tables don't appear in information_schema.tables,\n so dbt doesn't cache them #}\n {% if existing_relation is none %}\n\n {% set find_ext_tbl %}\n \n select count(*) from svv_external_tables\n where schemaname = '{{node.schema}}'\n and tablename = '{{node.identifier}}'\n \n {% endset %}\n \n {% if execute %}\n {% set result = run_query(find_ext_tbl)[0][0] %}\n {% else %}\n {% set result = 0 %}\n {% endif %}\n\n {% set is_ext_tbl = (result > 0) %}\n {% do return(is_ext_tbl) %}\n \n {% else %}\n \n {% do return(false) %}\n \n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_relation", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.520683, "supported_languages": null}, "macro.dbt_external_tables.sqlserver__create_external_table": {"unique_id": "macro.dbt_external_tables.sqlserver__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/sqlserver/create_external_table.sql", "original_file_path": "macros/plugins/sqlserver/create_external_table.sql", "name": "sqlserver__create_external_table", "macro_sql": "{% macro sqlserver__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n\n {% if external.ansi_nulls is true -%} SET ANSI_NULLS ON; {%- endif %}\n {% if external.quoted_identifier is true -%} SET QUOTED_IDENTIFIER ON; {%- endif %}\n\n create external table {{source(source_node.source_name, source_node.name)}} (\n {% for column in columns %}\n {# TODO set nullity based on schema tests?? #}\n {%- set nullity = 'NOT NULL' if 'not_null' in columns.tests else 'NULL'-%}\n {{adapter.quote(column.name)}} {{column.data_type}} {{nullity}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n WITH (\n {# remove keys that are None (i.e. not defined for a given source) #}\n {%- for key, value in external.items() if value is not none and key not in ['ansi_nulls', 'quoted_identifier'] -%}\n {{key}} = \n {%- if key in [\"location\", \"schema_name\", \"object_name\"] -%}\n '{{value}}'\n {% elif key in [\"data_source\",\"file_format\"] -%}\n [{{value}}]\n {% else -%}\n {{value}}\n {%- endif -%}\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n )\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5221262, "supported_languages": null}, "macro.dbt_external_tables.sqlserver__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.sqlserver__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/sqlserver/get_external_build_plan.sql", "original_file_path": "macros/plugins/sqlserver/get_external_build_plan.sql", "name": "sqlserver__get_external_build_plan", "macro_sql": "{% macro sqlserver__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n\n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n\n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [ \n dbt_external_tables.dropif(source_node), \n dbt_external_tables.create_external_table(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n {% do return(build_plan) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.dropif", "macro.dbt_external_tables.create_external_table", "macro.dbt_external_tables.refresh_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.522979, "supported_languages": null}, "macro.dbt_external_tables.sqlserver__dropif": {"unique_id": "macro.dbt_external_tables.sqlserver__dropif", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/sqlserver/helpers/dropif.sql", "original_file_path": "macros/plugins/sqlserver/helpers/dropif.sql", "name": "sqlserver__dropif", "macro_sql": "{% macro sqlserver__dropif(node) %}\n \n {% set ddl %}\n if object_id ('{{source(node.source_name, node.name)}}') is not null\n begin\n drop external table {{source(node.source_name, node.name)}}\n end\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.523391, "supported_languages": null}, "macro.dbt_external_tables.spark__create_external_table": {"unique_id": "macro.dbt_external_tables.spark__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/create_external_table.sql", "original_file_path": "macros/plugins/spark/create_external_table.sql", "name": "spark__create_external_table", "macro_sql": "{% macro spark__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n {%- set options = external.options -%}\n\n{# https://spark.apache.org/docs/latest/sql-data-sources-hive-tables.html #}\n create table {{source(source_node.source_name, source_node.name)}} \n {%- if columns|length > 0 %} (\n {% for column in columns %}\n {{column.name}} {{column.data_type}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n ) {% endif -%}\n {% if external.using %} using {{external.using}} {%- endif %}\n {% if options -%} options (\n {%- for key, value in options.items() -%}\n '{{ key }}' = '{{value}}' {{- ', \\n' if not loop.last -}}\n {%- endfor -%}\n ) {%- endif %}\n {% if partitions -%} partitioned by (\n {%- for partition in partitions -%}\n {{partition.name}} {{partition.data_type}}{{', ' if not loop.last}}\n {%- endfor -%}\n ) {%- endif %}\n {% if external.row_format -%} row format {{external.row_format}} {%- endif %}\n {% if external.file_format -%} stored as {{external.file_format}} {%- endif %}\n {% if external.location -%} location '{{external.location}}' {%- endif %}\n {% if external.table_properties -%} tblproperties {{ external.table_properties }} {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.525358, "supported_languages": null}, "macro.dbt_external_tables.spark__refresh_external_table": {"unique_id": "macro.dbt_external_tables.spark__refresh_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/refresh_external_table.sql", "original_file_path": "macros/plugins/spark/refresh_external_table.sql", "name": "spark__refresh_external_table", "macro_sql": "{% macro spark__refresh_external_table(source_node) %}\n \n {% set refresh %}\n refresh table {{source(source_node.source_name, source_node.name)}}\n {% endset %}\n \n {% do return([refresh]) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.525719, "supported_languages": null}, "macro.dbt_external_tables.spark__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.spark__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/get_external_build_plan.sql", "original_file_path": "macros/plugins/spark/get_external_build_plan.sql", "name": "spark__get_external_build_plan", "macro_sql": "{% macro spark__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n\n {% set old_relation = adapter.get_relation(\n database = none,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n\n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [\n dbt_external_tables.dropif(source_node), \n dbt_external_tables.create_external_table(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n\n {% set recover_partitions = dbt_external_tables.recover_partitions(source_node) %}\n {% if recover_partitions %}\n {% set build_plan = build_plan + [\n recover_partitions\n ] %}\n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.dropif", "macro.dbt_external_tables.create_external_table", "macro.dbt_external_tables.refresh_external_table", "macro.dbt_external_tables.recover_partitions"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5267892, "supported_languages": null}, "macro.dbt_external_tables.spark__recover_partitions": {"unique_id": "macro.dbt_external_tables.spark__recover_partitions", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/helpers/recover_partitions.sql", "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", "name": "spark__recover_partitions", "macro_sql": "{% macro spark__recover_partitions(source_node) %}\n {# https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-alter-table.html #}\n\n {%- if source_node.external.partitions and source_node.external.using and source_node.external.using|lower != 'delta' -%}\n {% set ddl %}\n ALTER TABLE {{ source(source_node.source_name, source_node.name) }} RECOVER PARTITIONS\n {% endset %}\n {%- else -%}\n {% set ddl = none %}\n {%- endif -%}\n\n {{return(ddl)}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.527437, "supported_languages": null}, "macro.dbt_external_tables.recover_partitions": {"unique_id": "macro.dbt_external_tables.recover_partitions", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/helpers/recover_partitions.sql", "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", "name": "recover_partitions", "macro_sql": "{% macro recover_partitions(source_node) %}\n {{ return(adapter.dispatch('recover_partitions', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.default__recover_partitions"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5276082, "supported_languages": null}, "macro.dbt_external_tables.default__recover_partitions": {"unique_id": "macro.dbt_external_tables.default__recover_partitions", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/helpers/recover_partitions.sql", "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", "name": "default__recover_partitions", "macro_sql": "{% macro default__recover_partitions(source_node) %}\n /*{# \n We're dispatching this macro so that users can override it if required on other adapters\n but this will work for spark/databricks. \n #}*/\n\n {{ exceptions.raise_not_implemented('recover_partitions macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.527763, "supported_languages": null}, "macro.dbt_external_tables.spark__dropif": {"unique_id": "macro.dbt_external_tables.spark__dropif", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/plugins/spark/helpers/dropif.sql", "original_file_path": "macros/plugins/spark/helpers/dropif.sql", "name": "spark__dropif", "macro_sql": "{% macro spark__dropif(node) %}\n \n {% set ddl %}\n drop table if exists {{source(node.source_name, node.name)}}\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.528088, "supported_languages": null}, "macro.dbt_external_tables.create_external_table": {"unique_id": "macro.dbt_external_tables.create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/create_external_table.sql", "original_file_path": "macros/common/create_external_table.sql", "name": "create_external_table", "macro_sql": "{% macro create_external_table(source_node) %}\n {{ adapter.dispatch('create_external_table', 'dbt_external_tables')(source_node) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.snowflake__create_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5283651, "supported_languages": null}, "macro.dbt_external_tables.default__create_external_table": {"unique_id": "macro.dbt_external_tables.default__create_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/create_external_table.sql", "original_file_path": "macros/common/create_external_table.sql", "name": "default__create_external_table", "macro_sql": "{% macro default__create_external_table(source_node) %}\n {{ exceptions.raise_compiler_error(\"External table creation is not implemented for the default adapter\") }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5284832, "supported_languages": null}, "macro.dbt_external_tables.refresh_external_table": {"unique_id": "macro.dbt_external_tables.refresh_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/refresh_external_table.sql", "original_file_path": "macros/common/refresh_external_table.sql", "name": "refresh_external_table", "macro_sql": "{% macro refresh_external_table(source_node) %}\n {{ return(adapter.dispatch('refresh_external_table', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.snowflake__refresh_external_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.528766, "supported_languages": null}, "macro.dbt_external_tables.default__refresh_external_table": {"unique_id": "macro.dbt_external_tables.default__refresh_external_table", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/refresh_external_table.sql", "original_file_path": "macros/common/refresh_external_table.sql", "name": "default__refresh_external_table", "macro_sql": "{% macro default__refresh_external_table(source_node) %}\n {% do return([]) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.528888, "supported_languages": null}, "macro.dbt_external_tables.get_external_build_plan": {"unique_id": "macro.dbt_external_tables.get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/get_external_build_plan.sql", "original_file_path": "macros/common/get_external_build_plan.sql", "name": "get_external_build_plan", "macro_sql": "{% macro get_external_build_plan(source_node) %}\n {{ return(adapter.dispatch('get_external_build_plan', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.snowflake__get_external_build_plan"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.529182, "supported_languages": null}, "macro.dbt_external_tables.default__get_external_build_plan": {"unique_id": "macro.dbt_external_tables.default__get_external_build_plan", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/get_external_build_plan.sql", "original_file_path": "macros/common/get_external_build_plan.sql", "name": "default__get_external_build_plan", "macro_sql": "{% macro default__get_external_build_plan(source_node) %}\n {{ exceptions.raise_compiler_error(\"Staging external sources is not implemented for the default adapter\") }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.529304, "supported_languages": null}, "macro.dbt_external_tables.stage_external_sources": {"unique_id": "macro.dbt_external_tables.stage_external_sources", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/stage_external_sources.sql", "original_file_path": "macros/common/stage_external_sources.sql", "name": "stage_external_sources", "macro_sql": "{% macro stage_external_sources(select=none) %}\n\n {% set sources_to_stage = [] %}\n \n {% set source_nodes = graph.sources.values() if graph.sources else [] %}\n \n {% for node in source_nodes %}\n {% if node.external %}\n \n {% if select %}\n \n {% for src in select.split(' ') %}\n \n {% if '.' in src %}\n {% set src_s = src.split('.') %}\n {% if src_s[0] == node.source_name and src_s[1] == node.name %}\n {% do sources_to_stage.append(node) %}\n {% endif %}\n {% else %}\n {% if src == node.source_name %}\n {% do sources_to_stage.append(node) %}\n {% endif %}\n {% endif %}\n \n {% endfor %}\n \n {% else %}\n \n {% do sources_to_stage.append(node) %}\n \n {% endif %}\n {% endif %}\n \n {% endfor %}\n \n {% if sources_to_stage|length == 0 %}\n {% do log('No external sources selected', info = true) %}\n {% endif %}\n \n {% for node in sources_to_stage %}\n\n {% set loop_label = loop.index ~ ' of ' ~ loop.length %}\n\n {% do log(loop_label ~ ' START external source ' ~ node.schema ~ '.' ~ node.identifier, info = true) -%}\n \n {% set run_queue = dbt_external_tables.get_external_build_plan(node) %}\n \n {% do log(loop_label ~ ' SKIP', info = true) if run_queue == [] %}\n {% set width = flags.PRINTER_WIDTH %}\n \n {% for q in run_queue %}\n \n {% set q_msg = q|replace('\\n','')|replace('begin;','')|trim %}\n {% set q_log = q_msg[:width] ~ '... ' if q_msg|length > width else q_msg %}\n \n {% do log(loop_label ~ ' (' ~ loop.index ~ ') ' ~ q_log, info = true) %}\n {% set exit_txn = dbt_external_tables.exit_transaction() %}\n \n {% call statement('runner', fetch_result = True, auto_begin = False) %}\n {{ exit_txn }} {{ q }}\n {% endcall %}\n \n {% set runner = load_result('runner') %}\n {% set log_msg = runner['response'] if 'response' in runner.keys() else runner['status'] %}\n {% do log(loop_label ~ ' (' ~ loop.index ~ ') ' ~ log_msg, info = true) %}\n \n {% endfor %}\n \n {% endfor %}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.get_external_build_plan", "macro.dbt_external_tables.exit_transaction", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5339992, "supported_languages": null}, "macro.dbt_external_tables.dropif": {"unique_id": "macro.dbt_external_tables.dropif", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/helpers/dropif.sql", "original_file_path": "macros/common/helpers/dropif.sql", "name": "dropif", "macro_sql": "{% macro dropif(node) %}\n {{ adapter.dispatch('dropif', 'dbt_external_tables')(node) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.default__dropif"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5343099, "supported_languages": null}, "macro.dbt_external_tables.default__dropif": {"unique_id": "macro.dbt_external_tables.default__dropif", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/helpers/dropif.sql", "original_file_path": "macros/common/helpers/dropif.sql", "name": "default__dropif", "macro_sql": "{% macro default__dropif() %}\n {{ exceptions.raise_compiler_error(\n \"Dropping external tables is not implemented for the default adapter\"\n ) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.534424, "supported_languages": null}, "macro.dbt_external_tables.exit_transaction": {"unique_id": "macro.dbt_external_tables.exit_transaction", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/helpers/transaction.sql", "original_file_path": "macros/common/helpers/transaction.sql", "name": "exit_transaction", "macro_sql": "{% macro exit_transaction() %}\n {{ return(adapter.dispatch('exit_transaction', 'dbt_external_tables')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_external_tables.default__exit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.534693, "supported_languages": null}, "macro.dbt_external_tables.default__exit_transaction": {"unique_id": "macro.dbt_external_tables.default__exit_transaction", "package_name": "dbt_external_tables", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", "path": "macros/common/helpers/transaction.sql", "original_file_path": "macros/common/helpers/transaction.sql", "name": "default__exit_transaction", "macro_sql": "{% macro default__exit_transaction() %}\n {{ return('') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.534794, "supported_languages": null}, "macro.dbt_expectations.type_timestamp": {"unique_id": "macro.dbt_expectations.type_timestamp", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "type_timestamp", "macro_sql": "\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt_expectations')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.snowflake__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5351932, "supported_languages": null}, "macro.dbt_expectations.default__type_timestamp": {"unique_id": "macro.dbt_expectations.default__type_timestamp", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() -%}\n timestamp\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5352588, "supported_languages": null}, "macro.dbt_expectations.snowflake__type_timestamp": {"unique_id": "macro.dbt_expectations.snowflake__type_timestamp", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "snowflake__type_timestamp", "macro_sql": "{% macro snowflake__type_timestamp() -%}\n timestamp_ntz\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5353248, "supported_languages": null}, "macro.dbt_expectations.postgres__type_timestamp": {"unique_id": "macro.dbt_expectations.postgres__type_timestamp", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "postgres__type_timestamp", "macro_sql": "{% macro postgres__type_timestamp() -%}\n timestamp without time zone\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5353868, "supported_languages": null}, "macro.dbt_expectations.type_datetime": {"unique_id": "macro.dbt_expectations.type_datetime", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "type_datetime", "macro_sql": "{% macro type_datetime() -%}\n {{ return(adapter.dispatch('type_datetime', 'dbt_expectations')()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.snowflake__type_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5355258, "supported_languages": null}, "macro.dbt_expectations.default__type_datetime": {"unique_id": "macro.dbt_expectations.default__type_datetime", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "default__type_datetime", "macro_sql": "{% macro default__type_datetime() -%}\n datetime\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.535591, "supported_languages": null}, "macro.dbt_expectations.snowflake__type_datetime": {"unique_id": "macro.dbt_expectations.snowflake__type_datetime", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "snowflake__type_datetime", "macro_sql": "{% macro snowflake__type_datetime() -%}\n timestamp_ntz\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5356522, "supported_languages": null}, "macro.dbt_expectations.postgres__type_datetime": {"unique_id": "macro.dbt_expectations.postgres__type_datetime", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/datatypes.sql", "original_file_path": "macros/utils/datatypes.sql", "name": "postgres__type_datetime", "macro_sql": "{% macro postgres__type_datetime() -%}\n timestamp without time zone\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.535712, "supported_languages": null}, "macro.dbt_expectations.group_by": {"unique_id": "macro.dbt_expectations.group_by", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/groupby.sql", "original_file_path": "macros/utils/groupby.sql", "name": "group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_expectations')(n)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.536022, "supported_languages": null}, "macro.dbt_expectations.default__group_by": {"unique_id": "macro.dbt_expectations.default__group_by", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/utils/groupby.sql", "original_file_path": "macros/utils/groupby.sql", "name": "default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }}\n {%- endfor -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.536243, "supported_languages": null}, "macro.dbt_expectations.regexp_instr": {"unique_id": "macro.dbt_expectations.regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "regexp_instr", "macro_sql": "{% macro regexp_instr(source_value, regexp, position=1, occurrence=1, is_raw=False) %}\n\n {{ adapter.dispatch('regexp_instr', 'dbt_expectations')(\n source_value, regexp, position, occurrence, is_raw\n ) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.snowflake__regexp_instr"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.536854, "supported_languages": null}, "macro.dbt_expectations.default__regexp_instr": {"unique_id": "macro.dbt_expectations.default__regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "default__regexp_instr", "macro_sql": "{% macro default__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\nregexp_instr({{ source_value }}, '{{ regexp }}', {{ position }}, {{ occurrence }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5370262, "supported_languages": null}, "macro.dbt_expectations.snowflake__regexp_instr": {"unique_id": "macro.dbt_expectations.snowflake__regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "snowflake__regexp_instr", "macro_sql": "{% macro snowflake__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\n{%- set regexp = \"$$\" ~ regexp ~ \"$$\" if is_raw else \"'\" ~ regexp ~ \"'\" -%}\nregexp_instr({{ source_value }}, {{ regexp }}, {{ position }}, {{ occurrence }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.537292, "supported_languages": null}, "macro.dbt_expectations.bigquery__regexp_instr": {"unique_id": "macro.dbt_expectations.bigquery__regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "bigquery__regexp_instr", "macro_sql": "{% macro bigquery__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\n{%- set regexp = \"r'\" ~ regexp ~ \"'\" if is_raw else \"'\" ~ regexp ~ \"'\" -%}\nregexp_instr({{ source_value }}, {{ regexp }}, {{ position }}, {{ occurrence }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.53762, "supported_languages": null}, "macro.dbt_expectations.postgres__regexp_instr": {"unique_id": "macro.dbt_expectations.postgres__regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "postgres__regexp_instr", "macro_sql": "{% macro postgres__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\narray_length((select regexp_matches({{ source_value }}, '{{ regexp }}')), 1)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.537765, "supported_languages": null}, "macro.dbt_expectations.redshift__regexp_instr": {"unique_id": "macro.dbt_expectations.redshift__regexp_instr", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/regex/regexp_instr.sql", "original_file_path": "macros/regex/regexp_instr.sql", "name": "redshift__regexp_instr", "macro_sql": "{% macro redshift__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\nregexp_instr({{ source_value }}, '{{ regexp }}', {{ position }}, {{ occurrence }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5379379, "supported_languages": null}, "macro.dbt_expectations.log_natural": {"unique_id": "macro.dbt_expectations.log_natural", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/log_natural.sql", "original_file_path": "macros/math/log_natural.sql", "name": "log_natural", "macro_sql": "{% macro log_natural(x) -%}\n {{ adapter.dispatch('log_natural', 'dbt_expectations') (x) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.snowflake__log_natural"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.538249, "supported_languages": null}, "macro.dbt_expectations.default__log_natural": {"unique_id": "macro.dbt_expectations.default__log_natural", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/log_natural.sql", "original_file_path": "macros/math/log_natural.sql", "name": "default__log_natural", "macro_sql": "{% macro default__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.538338, "supported_languages": null}, "macro.dbt_expectations.bigquery__log_natural": {"unique_id": "macro.dbt_expectations.bigquery__log_natural", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/log_natural.sql", "original_file_path": "macros/math/log_natural.sql", "name": "bigquery__log_natural", "macro_sql": "{% macro bigquery__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5384252, "supported_languages": null}, "macro.dbt_expectations.snowflake__log_natural": {"unique_id": "macro.dbt_expectations.snowflake__log_natural", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/log_natural.sql", "original_file_path": "macros/math/log_natural.sql", "name": "snowflake__log_natural", "macro_sql": "{% macro snowflake__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.538511, "supported_languages": null}, "macro.dbt_expectations.rand": {"unique_id": "macro.dbt_expectations.rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "rand", "macro_sql": "{% macro rand() -%}\n {{ adapter.dispatch('rand', 'dbt_expectations') () }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.snowflake__rand"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5388339, "supported_languages": null}, "macro.dbt_expectations.default__rand": {"unique_id": "macro.dbt_expectations.default__rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "default__rand", "macro_sql": "{% macro default__rand() -%}\n\n rand()\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5389, "supported_languages": null}, "macro.dbt_expectations.bigquery__rand": {"unique_id": "macro.dbt_expectations.bigquery__rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "bigquery__rand", "macro_sql": "{% macro bigquery__rand() -%}\n\n rand()\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.538962, "supported_languages": null}, "macro.dbt_expectations.snowflake__rand": {"unique_id": "macro.dbt_expectations.snowflake__rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "snowflake__rand", "macro_sql": "{% macro snowflake__rand(seed) -%}\n\n uniform(0::float, 1::float, random())\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.539032, "supported_languages": null}, "macro.dbt_expectations.postgres__rand": {"unique_id": "macro.dbt_expectations.postgres__rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "postgres__rand", "macro_sql": "{% macro postgres__rand() -%}\n\n random()\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.539092, "supported_languages": null}, "macro.dbt_expectations.redshift__rand": {"unique_id": "macro.dbt_expectations.redshift__rand", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/rand.sql", "original_file_path": "macros/math/rand.sql", "name": "redshift__rand", "macro_sql": "{% macro redshift__rand() -%}\n\n random()\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.539156, "supported_languages": null}, "macro.dbt_expectations.median": {"unique_id": "macro.dbt_expectations.median", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/median.sql", "original_file_path": "macros/math/median.sql", "name": "median", "macro_sql": "{% macro median(field) %}\n{{ dbt_expectations.percentile_cont(field, 0.5) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.percentile_cont"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5393898, "supported_languages": null}, "macro.dbt_expectations.percentile_cont": {"unique_id": "macro.dbt_expectations.percentile_cont", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/percentile_cont.sql", "original_file_path": "macros/math/percentile_cont.sql", "name": "percentile_cont", "macro_sql": "{% macro percentile_cont(field, quantile, partition=None) %}\n {{ adapter.dispatch('quantile', 'dbt_expectations') (field, quantile, partition) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__quantile"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.539837, "supported_languages": null}, "macro.dbt_expectations.default__quantile": {"unique_id": "macro.dbt_expectations.default__quantile", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/percentile_cont.sql", "original_file_path": "macros/math/percentile_cont.sql", "name": "default__quantile", "macro_sql": "{% macro default__quantile(field, quantile, partition) -%}\n percentile_cont({{ quantile }}) within group (order by {{ field }})\n {%- if partition %}over(partition by {{ partition }}){% endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.540024, "supported_languages": null}, "macro.dbt_expectations.bigquery__quantile": {"unique_id": "macro.dbt_expectations.bigquery__quantile", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/math/percentile_cont.sql", "original_file_path": "macros/math/percentile_cont.sql", "name": "bigquery__quantile", "macro_sql": "{% macro bigquery__quantile(field, quantile, partition) -%}\n percentile_cont({{ field }}, {{ quantile }})\n over({%- if partition %}partition by {{ partition }}{% endif -%})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.540208, "supported_languages": null}, "macro.dbt_expectations.ignore_row_if_expression": {"unique_id": "macro.dbt_expectations.ignore_row_if_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", "original_file_path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", "name": "ignore_row_if_expression", "macro_sql": "{% macro ignore_row_if_expression(ignore_row_if, columns) %}\n {{ adapter.dispatch('ignore_row_if_expression', 'dbt_expectations') (ignore_row_if, columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__ignore_row_if_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5406668, "supported_languages": null}, "macro.dbt_expectations.default__ignore_row_if_expression": {"unique_id": "macro.dbt_expectations.default__ignore_row_if_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", "original_file_path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", "name": "default__ignore_row_if_expression", "macro_sql": "{% macro default__ignore_row_if_expression(ignore_row_if, columns) %}\n {%- set ignore_row_if_values = [\"all_values_are_missing\", \"any_value_is_missing\"] -%}\n {% if ignore_row_if not in ignore_row_if_values %}\n {{ exceptions.raise_compiler_error(\n \"`ignore_row_if` must be one of \" ~ (ignore_row_if_values | join(\", \")) ~ \". Got: '\" ~ ignore_row_if ~\"'.'\"\n ) }}\n {% endif %}\n\n {%- set op = \"and\" if ignore_row_if == \"all_values_are_missing\" else \"or\" -%}\n not (\n {% for column in columns -%}\n {{ column }} is null{% if not loop.last %} {{ op }} {% endif %}\n {% endfor %}\n )\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.541265, "supported_languages": null}, "macro.dbt_expectations.test_expression_between": {"unique_id": "macro.dbt_expectations.test_expression_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/expression_between.sql", "original_file_path": "macros/schema_tests/_generalized/expression_between.sql", "name": "test_expression_between", "macro_sql": "{% test expression_between(model,\n expression,\n min_value=None,\n max_value=None,\n group_by_columns=None,\n row_condition=None,\n strictly=False\n ) %}\n\n {{ dbt_expectations.expression_between(model, expression, min_value, max_value, group_by_columns, row_condition, strictly) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.542332, "supported_languages": null}, "macro.dbt_expectations.expression_between": {"unique_id": "macro.dbt_expectations.expression_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/expression_between.sql", "original_file_path": "macros/schema_tests/_generalized/expression_between.sql", "name": "expression_between", "macro_sql": "{% macro expression_between(model,\n expression,\n min_value,\n max_value,\n group_by_columns,\n row_condition,\n strictly\n ) %}\n\n{%- if min_value is none and max_value is none -%}\n{{ exceptions.raise_compiler_error(\n \"You have to provide either a min_value, max_value or both.\"\n) }}\n{%- endif -%}\n\n{%- set strict_operator = \"\" if strictly else \"=\" -%}\n\n{% set expression_min_max %}\n( 1=1\n{%- if min_value is not none %} and {{ expression | trim }} >{{ strict_operator }} {{ min_value }}{% endif %}\n{%- if max_value is not none %} and {{ expression | trim }} <{{ strict_operator }} {{ max_value }}{% endif %}\n)\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression_min_max,\n group_by_columns=group_by_columns,\n row_condition=row_condition)\n }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.542986, "supported_languages": null}, "macro.dbt_expectations.test_expression_is_true": {"unique_id": "macro.dbt_expectations.test_expression_is_true", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/expression_is_true.sql", "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", "name": "test_expression_is_true", "macro_sql": "{% test expression_is_true(model,\n expression,\n test_condition=\"= true\",\n group_by_columns=None,\n row_condition=None\n ) %}\n\n {{ dbt_expectations.expression_is_true(model, expression, test_condition, group_by_columns, row_condition) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.543922, "supported_languages": null}, "macro.dbt_expectations.expression_is_true": {"unique_id": "macro.dbt_expectations.expression_is_true", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/expression_is_true.sql", "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", "name": "expression_is_true", "macro_sql": "{% macro expression_is_true(model,\n expression,\n test_condition=\"= true\",\n group_by_columns=None,\n row_condition=None\n ) %}\n {{ adapter.dispatch('expression_is_true', 'dbt_expectations') (model, expression, test_condition, group_by_columns, row_condition) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.544223, "supported_languages": null}, "macro.dbt_expectations.default__expression_is_true": {"unique_id": "macro.dbt_expectations.default__expression_is_true", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/expression_is_true.sql", "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", "name": "default__expression_is_true", "macro_sql": "{% macro default__expression_is_true(model, expression, test_condition, group_by_columns, row_condition) -%}\nwith grouped_expression as (\n select\n {% if group_by_columns %}\n {% for group_by_column in group_by_columns -%}\n {{ group_by_column }} as col_{{ loop.index }},\n {% endfor -%}\n {% endif %}\n {{ dbt_expectations.truth_expression(expression) }}\n from {{ model }}\n {%- if row_condition %}\n where\n {{ row_condition }}\n {% endif %}\n {% if group_by_columns %}\n group by\n {% for group_by_column in group_by_columns -%}\n {{ group_by_column }}{% if not loop.last %},{% endif %}\n {% endfor %}\n {% endif %}\n\n),\nvalidation_errors as (\n\n select\n *\n from\n grouped_expression\n where\n not(expression {{ test_condition }})\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.truth_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.544829, "supported_languages": null}, "macro.dbt_expectations.get_select": {"unique_id": "macro.dbt_expectations.get_select", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/equal_expression.sql", "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", "name": "get_select", "macro_sql": "{% macro get_select(model, expression, row_condition, group_by) -%}\n {{ adapter.dispatch('get_select', 'dbt_expectations') (model, expression, row_condition, group_by) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__get_select"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.549419, "supported_languages": null}, "macro.dbt_expectations.default__get_select": {"unique_id": "macro.dbt_expectations.default__get_select", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/equal_expression.sql", "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", "name": "default__get_select", "macro_sql": "\n\n{%- macro default__get_select(model, expression, row_condition, group_by) %}\n select\n {% if group_by %}\n {% for g in group_by -%}\n {{ g }} as col_{{ loop.index }},\n {% endfor -%}\n {% endif %}\n {{ expression }} as expression\n from\n {{ model }}\n {%- if row_condition %}\n where\n {{ row_condition }}\n {% endif %}\n {% if group_by %}\n group by\n {% for g in group_by -%}\n {{ loop.index }}{% if not loop.last %},{% endif %}\n {% endfor %}\n {% endif %}\n{% endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.549917, "supported_languages": null}, "macro.dbt_expectations.test_equal_expression": {"unique_id": "macro.dbt_expectations.test_equal_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/equal_expression.sql", "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", "name": "test_equal_expression", "macro_sql": "{% test equal_expression(model, expression,\n compare_model=None,\n compare_expression=None,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None,\n tolerance=0.0,\n tolerance_percent=None\n ) -%}\n\n {{ adapter.dispatch('test_equal_expression', 'dbt_expectations') (\n model,\n expression,\n compare_model,\n compare_expression,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition,\n tolerance,\n tolerance_percent) }}\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_equal_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5503502, "supported_languages": null}, "macro.dbt_expectations.default__test_equal_expression": {"unique_id": "macro.dbt_expectations.default__test_equal_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/equal_expression.sql", "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", "name": "default__test_equal_expression", "macro_sql": "\n\n{%- macro default__test_equal_expression(\n model,\n expression,\n compare_model,\n compare_expression,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition,\n tolerance,\n tolerance_percent) -%}\n\n {%- set compare_model = model if not compare_model else compare_model -%}\n {%- set compare_expression = expression if not compare_expression else compare_expression -%}\n {%- set compare_row_condition = row_condition if not compare_row_condition else compare_row_condition -%}\n {%- set compare_group_by = group_by if not compare_group_by else compare_group_by -%}\n\n {%- set n_cols = (group_by|length) if group_by else 0 %}\n with a as (\n {{ dbt_expectations.get_select(model, expression, row_condition, group_by) }}\n ),\n b as (\n {{ dbt_expectations.get_select(compare_model, compare_expression, compare_row_condition, compare_group_by) }}\n ),\n final as (\n\n select\n {% for i in range(1, n_cols + 1) -%}\n coalesce(a.col_{{ i }}, b.col_{{ i }}) as col_{{ i }},\n {% endfor %}\n a.expression,\n b.expression as compare_expression,\n abs(coalesce(a.expression, 0) - coalesce(b.expression, 0)) as expression_difference,\n abs(coalesce(a.expression, 0) - coalesce(b.expression, 0))/\n nullif(a.expression * 1.0, 0) as expression_difference_percent\n from\n {% if n_cols > 0 %}\n a\n full outer join\n b on\n {% for i in range(1, n_cols + 1) -%}\n a.col_{{ i }} = b.col_{{ i }} {% if not loop.last %}and{% endif %}\n {% endfor -%}\n {% else %}\n a cross join b\n {% endif %}\n )\n -- DEBUG:\n -- select * from final\n select\n *\n from final\n where\n {% if tolerance_percent %}\n expression_difference_percent > {{ tolerance_percent }}\n {% else %}\n expression_difference > {{ tolerance }}\n {% endif %}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.get_select"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.551494, "supported_languages": null}, "macro.dbt_expectations.truth_expression": {"unique_id": "macro.dbt_expectations.truth_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/_truth_expression.sql", "original_file_path": "macros/schema_tests/_generalized/_truth_expression.sql", "name": "truth_expression", "macro_sql": "{% macro truth_expression(expression) %}\n {{ adapter.dispatch('truth_expression', 'dbt_expectations') (expression) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__truth_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.551809, "supported_languages": null}, "macro.dbt_expectations.default__truth_expression": {"unique_id": "macro.dbt_expectations.default__truth_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/_generalized/_truth_expression.sql", "original_file_path": "macros/schema_tests/_generalized/_truth_expression.sql", "name": "default__truth_expression", "macro_sql": "{% macro default__truth_expression(expression) %}\n {{ expression }} as expression\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.551907, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern.sql", "name": "test_expect_column_values_to_match_like_pattern", "macro_sql": "{% test expect_column_values_to_match_like_pattern(model, column_name,\n like_pattern,\n row_condition=None\n ) %}\n\n{% set expression = dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=True) %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_like_pattern_expression", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.552447, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern_list": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern_list.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern_list.sql", "name": "test_expect_column_values_to_match_like_pattern_list", "macro_sql": "{% test expect_column_values_to_match_like_pattern_list(model, column_name,\n like_pattern_list,\n match_on=\"any\",\n row_condition=None\n ) %}\n\n{% set expression %}\n {% for like_pattern in like_pattern_list %}\n {{ dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=True) }}\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_like_pattern_expression", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.553396, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_match_regex": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_regex", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex.sql", "name": "test_expect_column_values_to_match_regex", "macro_sql": "{% test expect_column_values_to_match_regex(model, column_name,\n regex,\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} > 0\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.regexp_instr", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.554038, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_value_lengths_to_equal": {"unique_id": "macro.dbt_expectations.test_expect_column_value_lengths_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_equal.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_equal.sql", "name": "test_expect_column_value_lengths_to_equal", "macro_sql": "{% test expect_column_value_lengths_to_equal(model, column_name,\n value,\n row_condition=None\n ) %}\n\n{% set expression = length(column_name) ~ \" = \" ~ value %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.length", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.554555, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_value_lengths_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_value_lengths_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_be_between.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_be_between.sql", "name": "test_expect_column_value_lengths_to_be_between", "macro_sql": "{% test expect_column_value_lengths_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\n{{ length(column_name) }}\n{% endset %}\n\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=None,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.length", "macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.555298, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_match_regex": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_regex", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex.sql", "name": "test_expect_column_values_to_not_match_regex", "macro_sql": "{% test expect_column_values_to_not_match_regex(model, column_name,\n regex,\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} = 0\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.regexp_instr", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5559292, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_match_regex_list": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_regex_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex_list.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex_list.sql", "name": "test_expect_column_values_to_not_match_regex_list", "macro_sql": "{% test expect_column_values_to_not_match_regex_list(model, column_name,\n regex_list,\n match_on=\"any\",\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{% for regex in regex_list %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} = 0\n{%- if not loop.last %}\n{{ \" and \" if match_on == \"all\" else \" or \"}}\n{% endif -%}\n{% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.regexp_instr", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.55708, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_match_regex_list": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_regex_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex_list.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex_list.sql", "name": "test_expect_column_values_to_match_regex_list", "macro_sql": "{% test expect_column_values_to_match_regex_list(model, column_name,\n regex_list,\n match_on=\"any\",\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n {% for regex in regex_list %}\n {{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} > 0\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.regexp_instr", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.558057, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern_list": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern_list.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern_list.sql", "name": "test_expect_column_values_to_not_match_like_pattern_list", "macro_sql": "{% test expect_column_values_to_not_match_like_pattern_list(model, column_name,\n like_pattern_list,\n match_on=\"any\",\n row_condition=None\n ) %}\n\n{% set expression %}\n {% for like_pattern in like_pattern_list %}\n {{ dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=False) }}\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_like_pattern_expression", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.558999, "supported_languages": null}, "macro.dbt_expectations._get_like_pattern_expression": {"unique_id": "macro.dbt_expectations._get_like_pattern_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/_get_like_pattern_expression.sql", "original_file_path": "macros/schema_tests/string_matching/_get_like_pattern_expression.sql", "name": "_get_like_pattern_expression", "macro_sql": "{% macro _get_like_pattern_expression(column_name, like_pattern, positive) %}\n{{ column_name }} {{ \"not\" if not positive else \"\" }} like '{{ like_pattern }}'\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.559286, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern.sql", "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern.sql", "name": "test_expect_column_values_to_not_match_like_pattern", "macro_sql": "{% test expect_column_values_to_not_match_like_pattern(model, column_name,\n like_pattern,\n row_condition=None\n ) %}\n\n{% set expression = dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=False) %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_like_pattern_expression", "macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.559818, "supported_languages": null}, "macro.dbt_expectations.test_expect_row_values_to_have_recent_data": {"unique_id": "macro.dbt_expectations.test_expect_row_values_to_have_recent_data", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", "original_file_path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", "name": "test_expect_row_values_to_have_recent_data", "macro_sql": "{% test expect_row_values_to_have_recent_data(model,\n column_name,\n datepart,\n interval,\n row_condition=None) %}\n\n {{ adapter.dispatch('test_expect_row_values_to_have_recent_data', 'dbt_expectations') (model,\n column_name,\n datepart,\n interval,\n row_condition) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.560884, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data": {"unique_id": "macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", "original_file_path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", "name": "default__test_expect_row_values_to_have_recent_data", "macro_sql": "{% macro default__test_expect_row_values_to_have_recent_data(model, column_name, datepart, interval, row_condition) %}\n{%- set default_start_date = '1970-01-01' -%}\nwith max_recency as (\n\n select max(cast({{ column_name }} as {{ dbt_expectations.type_timestamp() }})) as max_timestamp\n from\n {{ model }}\n where\n -- to exclude erroneous future dates\n cast({{ column_name }} as {{ dbt_expectations.type_timestamp() }}) <= {{ dbt_date.now() }}\n {% if row_condition %}\n and {{ row_condition }}\n {% endif %}\n)\nselect\n *\nfrom\n max_recency\nwhere\n -- if the row_condition excludes all rows, we need to compare against a default date\n -- to avoid false negatives\n coalesce(max_timestamp, cast('{{ default_start_date }}' as {{ dbt_expectations.type_timestamp() }}))\n <\n cast({{ dbt.dateadd(datepart, interval * -1, dbt_date.now()) }} as {{ dbt_expectations.type_timestamp() }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.type_timestamp", "macro.dbt_date.now", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.561444, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_columns_to_contain_set": {"unique_id": "macro.dbt_expectations.test_expect_table_columns_to_contain_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_columns_to_contain_set.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_contain_set.sql", "name": "test_expect_table_columns_to_contain_set", "macro_sql": "{%- test expect_table_columns_to_contain_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n input_columns i\n left join\n relation_columns r on r.relation_column = i.input_column\n where\n -- catch any column in input list that is not in the list of table columns\n r.relation_column is null\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_column_list", "macro.dbt_expectations._list_intersect", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.562541, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table": {"unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", "name": "test_expect_table_row_count_to_equal_other_table", "macro_sql": "{%- test expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by=None,\n compare_group_by=None,\n factor=1,\n row_condition=None,\n compare_row_condition=None\n ) -%}\n\n {{ adapter.dispatch('test_expect_table_row_count_to_equal_other_table',\n 'dbt_expectations') (model,\n compare_model,\n group_by,\n compare_group_by,\n factor,\n row_condition,\n compare_row_condition\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.563467, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table": {"unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", "name": "default__test_expect_table_row_count_to_equal_other_table", "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by,\n compare_group_by,\n factor,\n row_condition,\n compare_row_condition\n ) -%}\n{{ dbt_expectations.test_equal_expression(model, \"count(*)\",\n compare_model=compare_model,\n compare_expression=\"count(*) * \" + factor|string,\n group_by=group_by,\n compare_group_by=compare_group_by,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_equal_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.563796, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_columns_to_not_contain_set": {"unique_id": "macro.dbt_expectations.test_expect_table_columns_to_not_contain_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_columns_to_not_contain_set.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_not_contain_set.sql", "name": "test_expect_table_columns_to_not_contain_set", "macro_sql": "{%- test expect_table_columns_to_not_contain_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n -- catch any column in input list that is in the list of table columns\n select *\n from\n input_columns i\n inner join\n relation_columns r on r.relation_column = i.input_column\n\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_column_list", "macro.dbt_expectations._list_intersect", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.564859, "supported_languages": null}, "macro.dbt_expectations.test_expect_grouped_row_values_to_have_recent_data": {"unique_id": "macro.dbt_expectations.test_expect_grouped_row_values_to_have_recent_data", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", "original_file_path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", "name": "test_expect_grouped_row_values_to_have_recent_data", "macro_sql": "{% test expect_grouped_row_values_to_have_recent_data(model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition=None) %}\n\n {{ adapter.dispatch('test_expect_grouped_row_values_to_have_recent_data', 'dbt_expectations') (model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.566947, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data": {"unique_id": "macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", "original_file_path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", "name": "default__test_expect_grouped_row_values_to_have_recent_data", "macro_sql": "{% macro default__test_expect_grouped_row_values_to_have_recent_data(model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition) %}\nwith latest_grouped_timestamps as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n max(1) as join_key,\n max(cast({{ timestamp_column }} as {{ dbt_expectations.type_timestamp() }})) as latest_timestamp_column\n from\n {{ model }}\n where\n -- to exclude erroneous future dates\n cast({{ timestamp_column }} as {{ dbt_expectations.type_timestamp() }}) <= {{ dbt_date.now() }}\n {% if row_condition %}\n and {{ row_condition }}\n {% endif %}\n\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n),\ntotal_row_counts as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n max(1) as join_key,\n count(*) as row_count\n from\n latest_grouped_timestamps\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n\n\n),\noutdated_grouped_timestamps as (\n\n select *\n from\n latest_grouped_timestamps\n where\n -- are the max timestamps per group older than the specified cutoff?\n latest_timestamp_column <\n cast(\n {{ dbt.dateadd(datepart, interval * -1, dbt_date.now()) }}\n as {{ dbt_expectations.type_timestamp() }}\n )\n\n),\nvalidation_errors as (\n\n select\n r.row_count,\n t.*\n from\n total_row_counts r\n left join\n outdated_grouped_timestamps t\n on\n {% for g in group_by %}\n r.{{ g }} = t.{{ g }} and\n {% endfor %}\n r.join_key = t.join_key\n where\n -- fail if either no rows were returned due to row_condition,\n -- or the recency test returned failed rows\n r.row_count = 0\n or\n t.join_key is not null\n\n)\nselect * from validation_errors\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.type_timestamp", "macro.dbt_date.now", "macro.dbt_expectations.group_by", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.567868, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_to_exist": {"unique_id": "macro.dbt_expectations.test_expect_column_to_exist", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_column_to_exist.sql", "original_file_path": "macros/schema_tests/table_shape/expect_column_to_exist.sql", "name": "test_expect_column_to_exist", "macro_sql": "{%- test expect_column_to_exist(model, column_name, column_index=None, transform=\"upper\") -%}\n{%- if execute -%}\n\n {%- set column_name = column_name | map(transform) | join -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n\n {%- set matching_column_index = relation_column_names.index(column_name) if column_name in relation_column_names else -1 %}\n\n {%- if column_index -%}\n\n {%- set column_index_0 = column_index - 1 if column_index > 0 else 0 -%}\n\n {%- set column_index_matches = true if matching_column_index == column_index_0 else false %}\n\n {%- else -%}\n\n {%- set column_index_matches = true -%}\n\n {%- endif %}\n\n with test_data as (\n\n select\n cast('{{ column_name }}' as {{ dbt.type_string() }}) as column_name,\n {{ matching_column_index }} as matching_column_index,\n {{ column_index_matches }} as column_index_matches\n\n )\n select *\n from test_data\n where\n not(matching_column_index >= 0 and column_index_matches)\n\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_column_list", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.568991, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_row_count_to_equal": {"unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", "name": "test_expect_table_row_count_to_equal", "macro_sql": "{%- test expect_table_row_count_to_equal(model,\n value,\n group_by=None,\n row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_equal',\n 'dbt_expectations') (model,\n value,\n group_by,\n row_condition\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_table_row_count_to_equal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5696452, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_table_row_count_to_equal": {"unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", "name": "default__test_expect_table_row_count_to_equal", "macro_sql": "\n\n\n\n{%- macro default__test_expect_table_row_count_to_equal(model,\n value,\n group_by,\n row_condition\n ) -%}\n{% set expression %}\ncount(*) = {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5699, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_row_count_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", "name": "test_expect_table_row_count_to_be_between", "macro_sql": "{%- test expect_table_row_count_to_be_between(model,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_be_between',\n 'dbt_expectations') (model,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_table_row_count_to_be_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.570776, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_table_row_count_to_be_between": {"unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", "name": "default__test_expect_table_row_count_to_be_between", "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_be_between(model,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) -%}\n{% set expression %}\ncount(*)\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.571151, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table_times_factor": {"unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table_times_factor", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", "name": "test_expect_table_row_count_to_equal_other_table_times_factor", "macro_sql": "{%- test expect_table_row_count_to_equal_other_table_times_factor(model,\n compare_model,\n factor,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_equal_other_table_times_factor',\n 'dbt_expectations') (model,\n compare_model,\n factor,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.572184, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor": {"unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", "name": "default__test_expect_table_row_count_to_equal_other_table_times_factor", "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_equal_other_table_times_factor(model,\n compare_model,\n factor,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition\n ) -%}\n\n{{ dbt_expectations.test_expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by=group_by,\n compare_group_by=compare_group_by,\n factor=factor,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5724611, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_columns_to_match_set": {"unique_id": "macro.dbt_expectations.test_expect_table_columns_to_match_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_columns_to_match_set.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_match_set.sql", "name": "test_expect_table_columns_to_match_set", "macro_sql": "{%- test expect_table_columns_to_match_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n relation_columns r\n full outer join\n input_columns i on r.relation_column = i.input_column\n where\n -- catch any column in input list that is not in the list of table columns\n -- or any table column that is not in the input list\n r.relation_column is null or\n i.input_column is null\n\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_column_list", "macro.dbt_expectations._list_intersect", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5736089, "supported_languages": null}, "macro.dbt_expectations._get_column_list": {"unique_id": "macro.dbt_expectations._get_column_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/_get_column_list.sql", "original_file_path": "macros/schema_tests/table_shape/_get_column_list.sql", "name": "_get_column_list", "macro_sql": "{%- macro _get_column_list(model, transform=\"upper\") -%}\n{%- set relation_columns = adapter.get_columns_in_relation(model) -%}\n{%- set relation_column_names = relation_columns | map(attribute=\"name\") | map(transform) | list -%}\n{%- do return(relation_column_names) -%}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.574019, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_columns_to_match_ordered_list": {"unique_id": "macro.dbt_expectations.test_expect_table_columns_to_match_ordered_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_columns_to_match_ordered_list.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_match_ordered_list.sql", "name": "test_expect_table_columns_to_match_ordered_list", "macro_sql": "{%- test expect_table_columns_to_match_ordered_list(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select\n {{ loop.index }} as relation_column_idx,\n cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select\n {{ loop.index }} as input_column_idx,\n cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n relation_columns r\n full outer join\n input_columns i on r.relation_column = i.input_column and r.relation_column_idx = i.input_column_idx\n where\n -- catch any column in input list that is not in the sequence of table columns\n -- or any table column that is not in the input sequence\n r.relation_column is null or\n i.input_column is null\n\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations._get_column_list", "macro.dbt_expectations._list_intersect", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.575304, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_aggregation_to_equal_other_table": {"unique_id": "macro.dbt_expectations.test_expect_table_aggregation_to_equal_other_table", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_aggregation_to_equal_other_table.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_aggregation_to_equal_other_table.sql", "name": "test_expect_table_aggregation_to_equal_other_table", "macro_sql": "{%- test expect_table_aggregation_to_equal_other_table(model,\n expression,\n compare_model,\n compare_expression=None,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None,\n tolerance=0.0,\n tolerance_percent=None\n ) -%}\n\n\n{{ dbt_expectations.test_equal_expression(\n model,\n expression=expression,\n compare_model=compare_model,\n compare_expression=compare_expression,\n group_by=group_by,\n compare_group_by=compare_group_by,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition,\n tolerance=tolerance,\n tolerance_percent=tolerance_percent\n) }}\n\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_equal_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.57592, "supported_languages": null}, "macro.dbt_expectations._list_intersect": {"unique_id": "macro.dbt_expectations._list_intersect", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/_list_intersect.sql", "original_file_path": "macros/schema_tests/table_shape/_list_intersect.sql", "name": "_list_intersect", "macro_sql": "{%- macro _list_intersect(list1, list2) -%}\n{%- set matching_items = [] -%}\n{%- for itm in list1 -%}\n {%- if itm in list2 -%}\n {%- do matching_items.append(itm) -%}\n {%- endif -%}\n{%- endfor -%}\n{%- do return(matching_items) -%}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5763462, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_column_count_to_equal_other_table": {"unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_equal_other_table", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal_other_table.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal_other_table.sql", "name": "test_expect_table_column_count_to_equal_other_table", "macro_sql": "{%- test expect_table_column_count_to_equal_other_table(model, compare_model) -%}\n{%- if execute -%}\n{%- set number_columns = (adapter.get_columns_in_relation(model) | length) -%}\n{%- set compare_number_columns = (adapter.get_columns_in_relation(compare_model) | length) -%}\nwith test_data as (\n\n select\n {{ number_columns }} as number_columns,\n {{ compare_number_columns }} as compare_number_columns\n\n)\nselect *\nfrom test_data\nwhere\n number_columns != compare_number_columns\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.576833, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_column_count_to_equal": {"unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal.sql", "name": "test_expect_table_column_count_to_equal", "macro_sql": "{%- test expect_table_column_count_to_equal(model, value) -%}\n{%- if execute -%}\n{%- set number_actual_columns = (adapter.get_columns_in_relation(model) | length) -%}\nwith test_data as (\n\n select\n {{ number_actual_columns }} as number_actual_columns,\n {{ value }} as value\n\n)\nselect *\nfrom test_data\nwhere\n number_actual_columns != value\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5772219, "supported_languages": null}, "macro.dbt_expectations.test_expect_table_column_count_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/table_shape/expect_table_column_count_to_be_between.sql", "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_be_between.sql", "name": "test_expect_table_column_count_to_be_between", "macro_sql": "{%- test expect_table_column_count_to_be_between(model,\n min_value=None,\n max_value=None\n ) -%}\n{%- if min_value is none and max_value is none -%}\n{{ exceptions.raise_compiler_error(\n \"You have to provide either a min_value, max_value or both.\"\n) }}\n{%- endif -%}\n{%- if execute -%}\n{%- set number_actual_columns = (adapter.get_columns_in_relation(model) | length) -%}\n\n{%- set expression %}\n( 1=1\n{%- if min_value %} and number_actual_columns >= min_value{% endif %}\n{%- if max_value %} and number_actual_columns <= max_value{% endif %}\n)\n{% endset -%}\n\nwith test_data as (\n\n select\n {{ number_actual_columns }} as number_actual_columns,\n {{ min_value if min_value else 0 }} as min_value,\n {{ max_value if max_value else 0 }} as max_value\n\n)\nselect *\nfrom test_data\nwhere\n not {{ expression }}\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.578149, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_be_in_set": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_in_set.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_in_set.sql", "name": "test_expect_column_values_to_not_be_in_set", "macro_sql": "{% test expect_column_values_to_not_be_in_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n cast('{{ value }}' as {{ dbt.type_string() }})\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n -- values from the model that match the set\n select\n v.value_field\n from\n all_values v\n join\n set_values s on v.value_field = s.value_field\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5789819, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_in_set": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_set.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_set.sql", "name": "test_expect_column_values_to_be_in_set", "macro_sql": "{% test expect_column_values_to_be_in_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n cast('{{ value }}' as {{ dbt.type_string() }})\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n v.value_field\n from\n all_values v\n left join\n set_values s on v.value_field = s.value_field\n where\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.57984, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_increasing": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_increasing", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_increasing.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_increasing.sql", "name": "test_expect_column_values_to_be_increasing", "macro_sql": "{% test expect_column_values_to_be_increasing(model, column_name,\n sort_column=None,\n strictly=True,\n row_condition=None,\n group_by=None) %}\n\n{%- set sort_column = column_name if not sort_column else sort_column -%}\n{%- set operator = \">\" if strictly else \">=\" -%}\nwith all_values as (\n\n select\n {{ sort_column }} as sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n {{ column_name }} as value_field\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nadd_lag_values as (\n\n select\n sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n value_field,\n lag(value_field) over\n {%- if not group_by -%}\n (order by sort_column)\n {%- else -%}\n (partition by {{ group_by | join(\", \") }} order by sort_column)\n {%- endif %} as value_field_lag\n from\n all_values\n\n),\nvalidation_errors as (\n select\n *\n from\n add_lag_values\n where\n value_field_lag is not null\n and\n not (value_field {{ operator }} value_field_lag)\n\n)\nselect *\nfrom validation_errors\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.581088, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_null": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_null", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_null.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_null.sql", "name": "test_expect_column_values_to_be_null", "macro_sql": "{% test expect_column_values_to_be_null(model, column_name, row_condition=None) %}\n\n{% set expression = column_name ~ \" is null\" %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5815601, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_unique": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_unique", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_unique.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_unique.sql", "name": "test_expect_column_values_to_be_unique", "macro_sql": "{% test expect_column_values_to_be_unique(model, column_name, row_condition=None) %}\n{{ dbt_expectations.test_expect_compound_columns_to_be_unique(model, [column_name], row_condition=row_condition) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_expect_compound_columns_to_be_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.581853, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_between.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_between.sql", "name": "test_expect_column_values_to_be_between", "macro_sql": "{% test expect_column_values_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ column_name }}\n{% endset %}\n\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=None,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.582569, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_decreasing": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_decreasing", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_decreasing.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_decreasing.sql", "name": "test_expect_column_values_to_be_decreasing", "macro_sql": "{% test expect_column_values_to_be_decreasing(model, column_name,\n sort_column=None,\n strictly=True,\n row_condition=None,\n group_by=None) %}\n\n{%- set sort_column = column_name if not sort_column else sort_column -%}\n{%- set operator = \"<\" if strictly else \"<=\" %}\nwith all_values as (\n\n select\n {{ sort_column }} as sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n {{ column_name }} as value_field\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nadd_lag_values as (\n\n select\n sort_column,\n value_field,\n lag(value_field) over\n {%- if not group_by -%}\n (order by sort_column)\n {%- else -%}\n (partition by {{ group_by | join(\", \") }} order by sort_column)\n {%- endif %} as value_field_lag\n from\n all_values\n\n),\nvalidation_errors as (\n\n select\n *\n from\n add_lag_values\n where\n value_field_lag is not null\n and\n not (value_field {{ operator }} value_field_lag)\n\n)\nselect *\nfrom validation_errors\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.58374, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_in_type_list": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_in_type_list", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_type_list.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_type_list.sql", "name": "test_expect_column_values_to_be_in_type_list", "macro_sql": "{%- test expect_column_values_to_be_in_type_list(model, column_name, column_type_list) -%}\n{%- if execute -%}\n\n {%- set column_name = column_name | upper -%}\n {%- set columns_in_relation = adapter.get_columns_in_relation(model) -%}\n {%- set column_type_list = column_type_list| map(\"upper\") | list -%}\n with relation_columns as (\n\n {% for column in columns_in_relation %}\n select\n cast('{{ column.name | upper }}' as {{ dbt.type_string() }}) as relation_column,\n cast('{{ column.dtype | upper }}' as {{ dbt.type_string() }}) as relation_column_type\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n test_data as (\n\n select\n *\n from\n relation_columns\n where\n relation_column = '{{ column_name }}'\n and\n relation_column_type not in ('{{ column_type_list | join(\"', '\") }}')\n\n )\n select *\n from test_data\n\n{%- endif -%}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.584741, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_of_type": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_of_type", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_of_type.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_of_type.sql", "name": "test_expect_column_values_to_be_of_type", "macro_sql": "{%- test expect_column_values_to_be_of_type(model, column_name, column_type) -%}\n{{ dbt_expectations.test_expect_column_values_to_be_in_type_list(model, column_name, [column_type]) }}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_expect_column_values_to_be_in_type_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5850081, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_have_consistent_casing": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_have_consistent_casing", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_have_consistent_casing.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_have_consistent_casing.sql", "name": "test_expect_column_values_to_have_consistent_casing", "macro_sql": "{% test expect_column_values_to_have_consistent_casing(model, column_name, display_inconsistent_columns=False) %}\n\nwith test_data as (\n\n select\n distinct {{ column_name }} as distinct_values\n from\n {{ model }}\n\n ),\n {% if display_inconsistent_columns %}\n validation_errors as (\n\n select\n lower(distinct_values) as inconsistent_columns,\n count(distinct_values) as set_count_case_insensitive\n from\n test_data\n group by 1\n having\n count(distinct_values) > 1\n\n )\n select * from validation_errors\n {% else %}\n validation_errors as (\n\n select\n count(1) as set_count,\n count(distinct lower(distinct_values)) as set_count_case_insensitive\n from\n test_data\n\n )\n select *\n from\n validation_errors\n where\n set_count != set_count_case_insensitive\n {% endif %}\n {%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5854578, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_not_be_null": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_be_null", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_null.sql", "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_null.sql", "name": "test_expect_column_values_to_not_be_null", "macro_sql": "{% test expect_column_values_to_not_be_null(model, column_name, row_condition=None) %}\n\n{% set expression = column_name ~ \" is not null\" %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5859141, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_min_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_min_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_min_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_min_to_be_between.sql", "name": "test_expect_column_min_to_be_between", "macro_sql": "{% test expect_column_min_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nmin({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.586655, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_unique_value_count_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_unique_value_count_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_unique_value_count_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_unique_value_count_to_be_between.sql", "name": "test_expect_column_unique_value_count_to_be_between", "macro_sql": "{% test expect_column_unique_value_count_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.587415, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_quantile_values_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_quantile_values_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_quantile_values_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_quantile_values_to_be_between.sql", "name": "test_expect_column_quantile_values_to_be_between", "macro_sql": "{% test expect_column_quantile_values_to_be_between(model, column_name,\n quantile,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.percentile_cont(column_name, quantile) }}\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.percentile_cont", "macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.588223, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_median_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_median_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_median_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_median_to_be_between.sql", "name": "test_expect_column_median_to_be_between", "macro_sql": "{% test expect_column_median_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.median(column_name) }}\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.median", "macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5889878, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_proportion_of_unique_values_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_proportion_of_unique_values_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_proportion_of_unique_values_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_proportion_of_unique_values_to_be_between.sql", "name": "test_expect_column_proportion_of_unique_values_to_be_between", "macro_sql": "{% test expect_column_proportion_of_unique_values_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }})/count({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.589798, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_values_to_equal_set": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_equal_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_equal_set.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_equal_set.sql", "name": "test_expect_column_distinct_values_to_equal_set", "macro_sql": "{% test expect_column_distinct_values_to_equal_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as column_value\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n\n select\n *\n from\n all_values v\n full outer join\n unique_set_values s on v.column_value = s.value_field\n where\n v.column_value is null or\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5906339, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_most_common_value_to_be_in_set": {"unique_id": "macro.dbt_expectations.test_expect_column_most_common_value_to_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", "name": "test_expect_column_most_common_value_to_be_in_set", "macro_sql": "{% test expect_column_most_common_value_to_be_in_set(model,\n column_name,\n value_set,\n top_n,\n quote_values=True,\n data_type=\"decimal\",\n row_condition=None\n ) -%}\n\n {{ adapter.dispatch('test_expect_column_most_common_value_to_be_in_set', 'dbt_expectations') (\n model, column_name, value_set, top_n, quote_values, data_type, row_condition\n ) }}\n\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.592224, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set": {"unique_id": "macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", "name": "default__test_expect_column_most_common_value_to_be_in_set", "macro_sql": "{% macro default__test_expect_column_most_common_value_to_be_in_set(model,\n column_name,\n value_set,\n top_n,\n quote_values,\n data_type,\n row_condition\n ) %}\n\nwith value_counts as (\n\n select\n {% if quote_values -%}\n {{ column_name }}\n {%- else -%}\n cast({{ column_name }} as {{ data_type }})\n {%- endif %} as value_field,\n count(*) as value_count\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n group by {% if quote_values -%}\n {{ column_name }}\n {%- else -%}\n cast({{ column_name }} as {{ data_type }})\n {%- endif %}\n\n),\nvalue_counts_ranked as (\n\n select\n *,\n row_number() over(order by value_count desc) as value_count_rank\n from\n value_counts\n\n),\nvalue_count_top_n as (\n\n select\n value_field\n from\n value_counts_ranked\n where\n value_count_rank = {{ top_n }}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n cast({{ value }} as {{ data_type }})\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n value_field\n from\n value_count_top_n\n where\n value_field not in (select value_field from unique_set_values)\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.592923, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_values_to_contain_set": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_contain_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_contain_set.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_contain_set.sql", "name": "test_expect_column_distinct_values_to_contain_set", "macro_sql": "{% test expect_column_distinct_values_to_contain_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values in set that are not in the list of values from the model\n select\n s.value_field\n from\n unique_set_values s\n left join\n all_values v on s.value_field = v.value_field\n where\n v.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5937788, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_count_to_equal": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal.sql", "name": "test_expect_column_distinct_count_to_equal", "macro_sql": "{% test expect_column_distinct_count_to_equal(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) = {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.594362, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_count_to_be_less_than": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_be_less_than", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_less_than.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_less_than.sql", "name": "test_expect_column_distinct_count_to_be_less_than", "macro_sql": "{% test expect_column_distinct_count_to_be_less_than(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) < {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.594951, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_sum_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_sum_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_sum_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_sum_to_be_between.sql", "name": "test_expect_column_sum_to_be_between", "macro_sql": "{% test expect_column_sum_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nsum({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.595687, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_stdev_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_stdev_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", "name": "test_expect_column_stdev_to_be_between", "macro_sql": "{% test expect_column_stdev_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) -%}\n {{ adapter.dispatch('test_expect_column_stdev_to_be_between', 'dbt_expectations') (\n model, column_name,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) }}\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_column_stdev_to_be_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.596888, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_column_stdev_to_be_between": {"unique_id": "macro.dbt_expectations.default__test_expect_column_stdev_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", "name": "default__test_expect_column_stdev_to_be_between", "macro_sql": "{% macro default__test_expect_column_stdev_to_be_between(\n model, column_name,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) %}\n\n{% set expression %}\nstddev({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5972989, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_mean_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_mean_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_mean_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_mean_to_be_between.sql", "name": "test_expect_column_mean_to_be_between", "macro_sql": "{% test expect_column_mean_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\navg({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.5980392, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_max_to_be_between": {"unique_id": "macro.dbt_expectations.test_expect_column_max_to_be_between", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_max_to_be_between.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_max_to_be_between.sql", "name": "test_expect_column_max_to_be_between", "macro_sql": "{% test expect_column_max_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nmax({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.598778, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_count_to_be_greater_than": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_be_greater_than", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_greater_than.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_greater_than.sql", "name": "test_expect_column_distinct_count_to_be_greater_than", "macro_sql": "{% test expect_column_distinct_count_to_be_greater_than(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) > {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.599369, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_values_to_be_in_set": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_be_in_set.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_be_in_set.sql", "name": "test_expect_column_distinct_values_to_be_in_set", "macro_sql": "{% test expect_column_distinct_values_to_be_in_set(model,\n column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n v.value_field\n from\n all_values v\n left join\n unique_set_values s on v.value_field = s.value_field\n where\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.600217, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_distinct_count_to_equal_other_table": {"unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_equal_other_table", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal_other_table.sql", "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal_other_table.sql", "name": "test_expect_column_distinct_count_to_equal_other_table", "macro_sql": "{% test expect_column_distinct_count_to_equal_other_table(model,\n compare_model,\n column_name,\n compare_column_name,\n row_condition=None,\n compare_row_condition=None\n ) %}\n{%- set expression -%}\ncount(distinct {{ column_name }})\n{%- endset -%}\n{%- set compare_expression -%}\n{%- if compare_column_name -%}\ncount(distinct {{ compare_column_name }})\n{%- else -%}\n{{ expression }}\n{%- endif -%}\n{%- endset -%}\n{{ dbt_expectations.test_equal_expression(\n model,\n expression=expression,\n compare_model=compare_model,\n compare_expression=compare_expression,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.test_equal_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6009421, "supported_languages": null}, "macro.dbt_expectations.test_expect_row_values_to_have_data_for_every_n_datepart": {"unique_id": "macro.dbt_expectations.test_expect_row_values_to_have_data_for_every_n_datepart", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_row_values_to_have_data_for_every_n_datepart.sql", "original_file_path": "macros/schema_tests/distributional/expect_row_values_to_have_data_for_every_n_datepart.sql", "name": "test_expect_row_values_to_have_data_for_every_n_datepart", "macro_sql": "{%- test expect_row_values_to_have_data_for_every_n_datepart(model,\n date_col,\n date_part=\"day\",\n interval=None,\n row_condition=None,\n exclusion_condition=None,\n test_start_date=None,\n test_end_date=None) -%}\n{% if not execute %}\n {{ return('') }}\n{% endif %}\n\n{% if not test_start_date or not test_end_date %}\n {% set sql %}\n\n select\n min({{ date_col }}) as start_{{ date_part }},\n max({{ date_col }}) as end_{{ date_part }}\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n {% endset %}\n\n {%- set dr = run_query(sql) -%}\n {%- set db_start_date = dr.columns[0].values()[0].strftime('%Y-%m-%d') -%}\n {%- set db_end_date = dr.columns[1].values()[0].strftime('%Y-%m-%d') -%}\n\n{% endif %}\n\n{% if not test_start_date %}\n{% set start_date = db_start_date %}\n{% else %}\n{% set start_date = test_start_date %}\n{% endif %}\n\n\n{% if not test_end_date %}\n{% set end_date = db_end_date %}\n{% else %}\n{% set end_date = test_end_date %}\n{% endif %}\nwith base_dates as (\n\n {{ dbt_date.get_base_dates(start_date=start_date, end_date=end_date, datepart=date_part) }}\n {% if interval %}\n {#\n Filter the date spine created above down to the interval granularity using a modulo operation.\n The number of date_parts after the start_date divided by the integer interval will produce no remainder for the desired intervals,\n e.g. for 2-day interval from a starting Jan 1, 2020:\n params: start_date = '2020-01-01', date_part = 'day', interval = 2\n date spine created above: [2020-01-01, 2020-01-02, 2020-01-03, 2020-01-04, 2020-01-05, ...]\n The first parameter to the `mod` function would be the number of days between the start_date and the spine date, i.e. [0, 1, 2, 3, 4 ...]\n The second parameter to the `mod` function would be the integer interval, i.e. 2\n This modulo operation produces the following remainders: [0, 1, 0, 1, 0, ...]\n Filtering the spine only where this remainder == 0 will return a spine with every other day as desired, i.e. [2020-01-01, 2020-01-03, 2020-01-05, ...]\n #}\n where mod(\n cast({{ dbt.datediff(\"'\" ~ start_date ~ \"'\", 'date_' ~ date_part, date_part) }} as {{ dbt.type_int() }}),\n cast({{interval}} as {{ dbt.type_int() }})\n ) = 0\n {% endif %}\n\n),\nmodel_data as (\n\n select\n {% if not interval %}\n\n cast({{ dbt.date_trunc(date_part, date_col) }} as {{ dbt_expectations.type_datetime() }}) as date_{{ date_part }},\n\n {% else %}\n {#\n Use a modulo operator to determine the number of intervals that a date_col is away from the interval-date spine\n and subtracts that amount to effectively slice each date_col record into its corresponding spine bucket,\n e.g. given a date_col of with records [2020-01-01, 2020-01-02, 2020-01-03, 2020-01-11, 2020-01-12]\n if we want to slice these dates into their 2-day buckets starting Jan 1, 2020 (start_date = '2020-01-01', date_part='day', interval=2),\n the modulo operation described above will produce these remainders: [0, 1, 0, 0, 1]\n subtracting that number of days from the observations will produce records [2020-01-01, 2020-01-01, 2020-01-03, 2020-01-11, 2020-01-11],\n all of which align with records from the interval-date spine\n #}\n {{ dbt.dateadd(\n date_part,\n \"mod(\n cast(\" ~ dbt.datediff(\"'\" ~ start_date ~ \"'\", date_col, date_part) ~ \" as \" ~ dbt.type_int() ~ \" ),\n cast(\" ~ interval ~ \" as \" ~ dbt.type_int() ~ \" )\n ) * (-1)\",\n \"cast( \" ~ dbt.date_trunc(date_part, date_col) ~ \" as \" ~ dbt_expectations.type_datetime() ~ \")\"\n )}} as date_{{ date_part }},\n\n {% endif %}\n\n count(*) as row_cnt\n from\n {{ model }} f\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n group by\n date_{{date_part}}\n\n),\n\nfinal as (\n\n select\n cast(d.date_{{ date_part }} as {{ dbt_expectations.type_datetime() }}) as date_{{ date_part }},\n case when f.date_{{ date_part }} is null then true else false end as is_missing,\n coalesce(f.row_cnt, 0) as row_cnt\n from\n base_dates d\n left join\n model_data f on cast(d.date_{{ date_part }} as {{ dbt_expectations.type_datetime() }}) = f.date_{{ date_part }}\n)\nselect\n *\nfrom final\nwhere row_cnt = 0\n{% if exclusion_condition %}\n and {{ exclusion_condition }}\n{% endif %}\n{%- endtest -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_date.get_base_dates", "macro.dbt.datediff", "macro.dbt.type_int", "macro.dbt.date_trunc", "macro.dbt_expectations.type_datetime", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6045702, "supported_languages": null}, "macro.dbt_expectations._get_metric_expression": {"unique_id": "macro.dbt_expectations._get_metric_expression", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "name": "_get_metric_expression", "macro_sql": "{%- macro _get_metric_expression(metric_column, take_logs) -%}\n\n{%- if take_logs %}\n{%- set expr = \"nullif(\" ~ metric_column ~ \", 0)\" -%}\ncoalesce({{ dbt_expectations.log_natural(expr) }}, 0)\n{%- else -%}\ncoalesce({{ metric_column }}, 0)\n{%- endif %}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.log_natural"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6083379, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_within_n_moving_stdevs": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_within_n_moving_stdevs", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "name": "test_expect_column_values_to_be_within_n_moving_stdevs", "macro_sql": "{% test expect_column_values_to_be_within_n_moving_stdevs(model,\n column_name,\n date_column_name,\n group_by=None,\n period='day',\n lookback_periods=1,\n trend_periods=7,\n test_periods=14,\n sigma_threshold=3,\n sigma_threshold_upper=None,\n sigma_threshold_lower=None,\n take_diffs=true,\n take_logs=true\n ) -%}\n {{ adapter.dispatch('test_expect_column_values_to_be_within_n_moving_stdevs', 'dbt_expectations') (model,\n column_name,\n date_column_name,\n group_by,\n period,\n lookback_periods,\n trend_periods,\n test_periods,\n sigma_threshold,\n sigma_threshold_upper,\n sigma_threshold_lower,\n take_diffs,\n take_logs\n ) }}\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6088388, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs": {"unique_id": "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", "name": "default__test_expect_column_values_to_be_within_n_moving_stdevs", "macro_sql": "{% macro default__test_expect_column_values_to_be_within_n_moving_stdevs(model,\n column_name,\n date_column_name,\n group_by,\n period,\n lookback_periods,\n trend_periods,\n test_periods,\n sigma_threshold,\n sigma_threshold_upper,\n sigma_threshold_lower,\n take_diffs,\n take_logs\n ) %}\n\n{%- set sigma_threshold_upper = sigma_threshold_upper if sigma_threshold_upper else sigma_threshold -%}\n{%- set sigma_threshold_lower = sigma_threshold_lower if sigma_threshold_lower else -1 * sigma_threshold -%}\n{%- set partition_by = \"partition by \" ~ (group_by | join(\",\")) if group_by -%}\n{%- set group_by_length = (group_by | length ) if group_by else 0 -%}\n\nwith metric_values as (\n\n with grouped_metric_values as (\n\n select\n {{ dbt.date_trunc(period, date_column_name) }} as metric_period,\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n sum({{ column_name }}) as agg_metric_value\n from\n {{ model }}\n {{ dbt_expectations.group_by(1 + group_by_length) }}\n\n )\n {%- if take_diffs %}\n , grouped_metric_values_with_priors as (\n\n select\n *,\n lag(agg_metric_value, {{ lookback_periods }}) over(\n {{ partition_by }}\n order by metric_period) as prior_agg_metric_value\n from\n grouped_metric_values d\n\n )\n select\n *,\n {{ dbt_expectations._get_metric_expression(\"agg_metric_value\", take_logs) }}\n -\n {{ dbt_expectations._get_metric_expression(\"prior_agg_metric_value\", take_logs) }}\n as metric_test_value\n from\n grouped_metric_values_with_priors d\n\n {%- else %}\n\n select\n *,\n {{ dbt_expectations._get_metric_expression(\"agg_metric_value\", take_logs) }}\n as metric_test_value\n from\n grouped_metric_values\n\n {%- endif %}\n\n),\nmetric_moving_calcs as (\n\n select\n *,\n avg(metric_test_value)\n over({{ partition_by }}\n order by metric_period rows\n between {{ trend_periods }} preceding and 1 preceding) as metric_test_rolling_average,\n stddev(metric_test_value)\n over({{ partition_by }}\n order by metric_period rows\n between {{ trend_periods }} preceding and 1 preceding) as metric_test_rolling_stddev\n from\n metric_values\n\n),\nmetric_sigma as (\n\n select\n *,\n (metric_test_value - metric_test_rolling_average) as metric_test_delta,\n (metric_test_value - metric_test_rolling_average)/\n nullif(metric_test_rolling_stddev, 0) as metric_test_sigma\n from\n metric_moving_calcs\n\n)\nselect\n *\nfrom\n metric_sigma\nwhere\n\n metric_period >= cast(\n {{ dbt.dateadd(period, -test_periods, dbt.date_trunc(period, dbt_date.now())) }}\n as {{ dbt_expectations.type_timestamp() }})\n and\n metric_period < {{ dbt.date_trunc(period, dbt_date.now()) }}\n and\n\n not (\n metric_test_sigma >= {{ sigma_threshold_lower }} and\n metric_test_sigma <= {{ sigma_threshold_upper }}\n )\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.date_trunc", "macro.dbt_expectations.group_by", "macro.dbt_expectations._get_metric_expression", "macro.dbt.dateadd", "macro.dbt_date.now", "macro.dbt_expectations.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.610208, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_values_to_be_within_n_stdevs": {"unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_within_n_stdevs", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", "name": "test_expect_column_values_to_be_within_n_stdevs", "macro_sql": "{% test expect_column_values_to_be_within_n_stdevs(model,\n column_name,\n group_by=None,\n sigma_threshold=3\n ) -%}\n {{\n adapter.dispatch('test_expect_column_values_to_be_within_n_stdevs', 'dbt_expectations') (\n model, column_name, group_by, sigma_threshold\n )\n }}\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.611085, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs": {"unique_id": "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", "name": "default__test_expect_column_values_to_be_within_n_stdevs", "macro_sql": "{% macro default__test_expect_column_values_to_be_within_n_stdevs(model,\n column_name,\n group_by,\n sigma_threshold\n ) %}\n\nwith metric_values as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n sum({{ column_name }}) as {{ column_name }}\n from\n {{ model }}\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n\n),\nmetric_values_with_statistics as (\n\n select\n *,\n avg({{ column_name }}) over() as {{ column_name }}_average,\n stddev({{ column_name }}) over() as {{ column_name }}_stddev\n from\n metric_values\n\n),\nmetric_values_z_scores as (\n\n select\n *,\n ({{ column_name }} - {{ column_name }}_average)/\n nullif({{ column_name }}_stddev, 0) as {{ column_name }}_sigma\n from\n metric_values_with_statistics\n\n)\nselect\n *\nfrom\n metric_values_z_scores\nwhere\n abs({{ column_name }}_sigma) > {{ sigma_threshold }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.61159, "supported_languages": null}, "macro.dbt_expectations.test_expect_select_column_values_to_be_unique_within_record": {"unique_id": "macro.dbt_expectations.test_expect_select_column_values_to_be_unique_within_record", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", "original_file_path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", "name": "test_expect_select_column_values_to_be_unique_within_record", "macro_sql": "{% test expect_select_column_values_to_be_unique_within_record(model,\n column_list,\n quote_columns=False,\n ignore_row_if=\"all_values_are_missing\",\n row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_select_column_values_to_be_unique_within_record', 'dbt_expectations') (model, column_list, quote_columns, ignore_row_if, row_condition) }}\n{%- endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.612949, "supported_languages": null}, "macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record": {"unique_id": "macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", "original_file_path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", "name": "default__test_expect_select_column_values_to_be_unique_within_record", "macro_sql": "{% macro default__test_expect_select_column_values_to_be_unique_within_record(model,\n column_list,\n quote_columns,\n ignore_row_if,\n row_condition\n ) %}\n\n{% if not quote_columns %}\n {%- set columns=column_list %}\n{% elif quote_columns %}\n {%- set columns=[] %}\n {% for column in column_list -%}\n {% set columns = columns.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote_columns ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set row_condition_ext -%}\n\n {%- if row_condition %}\n {{ row_condition }} and\n {% endif -%}\n\n {{ dbt_expectations.ignore_row_if_expression(ignore_row_if, columns) }}\n\n{%- endset -%}\n\nwith column_values as (\n\n select\n row_number() over(order by 1) as row_index,\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n from {{ model }}\n where\n 1=1\n {%- if row_condition_ext %}\n and {{ row_condition_ext }}\n {% endif %}\n\n),\nunpivot_columns as (\n\n {% for column in columns %}\n select row_index, '{{ column }}' as column_name, {{ column }} as column_value from column_values\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n\n select\n row_index,\n count(distinct column_value) as column_values\n from unpivot_columns\n group by 1\n having count(distinct column_value) < {{ columns | length }}\n\n)\nselect * from validation_errors\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.ignore_row_if_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6139462, "supported_languages": null}, "macro.dbt_expectations.test_expect_compound_columns_to_be_unique": {"unique_id": "macro.dbt_expectations.test_expect_compound_columns_to_be_unique", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_compound_columns_to_be_unique.sql", "original_file_path": "macros/schema_tests/multi-column/expect_compound_columns_to_be_unique.sql", "name": "test_expect_compound_columns_to_be_unique", "macro_sql": "{% test expect_compound_columns_to_be_unique(model,\n column_list,\n quote_columns=False,\n ignore_row_if=\"all_values_are_missing\",\n row_condition=None\n ) %}\n{% if not column_list %}\n {{ exceptions.raise_compiler_error(\n \"`column_list` must be specified as a list of columns. Got: '\" ~ column_list ~\"'.'\"\n ) }}\n{% endif %}\n\n{% if not quote_columns %}\n {%- set columns=column_list %}\n{% elif quote_columns %}\n {%- set columns=[] %}\n {% for column in column_list -%}\n {% set columns = columns.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for expect_compound_columns_to_be_unique test must be one of [True, False] Got: '\" ~ quote_columns ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set row_condition_ext -%}\n\n {%- if row_condition %}\n {{ row_condition }} and\n {% endif -%}\n\n {{ dbt_expectations.ignore_row_if_expression(ignore_row_if, columns) }}\n\n{%- endset -%}\n\nwith validation_errors as (\n\n select\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n from {{ model }}\n where\n 1=1\n {%- if row_condition_ext %}\n and {{ row_condition_ext }}\n {% endif %}\n group by\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n having count(*) > 1\n\n)\nselect * from validation_errors\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.ignore_row_if_expression"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.6157582, "supported_languages": null}, "macro.dbt_expectations.test_expect_multicolumn_sum_to_equal": {"unique_id": "macro.dbt_expectations.test_expect_multicolumn_sum_to_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_multicolumn_sum_to_equal.sql", "original_file_path": "macros/schema_tests/multi-column/expect_multicolumn_sum_to_equal.sql", "name": "test_expect_multicolumn_sum_to_equal", "macro_sql": "{% test expect_multicolumn_sum_to_equal(model,\n column_list,\n sum_total,\n group_by=None,\n row_condition=None\n ) %}\n\n{% set expression %}\n{% for column in column_list %}\nsum({{ column }}){% if not loop.last %} + {% endif %}\n{% endfor %} = {{ sum_total }}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.616595, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_pair_values_to_be_equal": {"unique_id": "macro.dbt_expectations.test_expect_column_pair_values_to_be_equal", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_equal.sql", "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_equal.sql", "name": "test_expect_column_pair_values_to_be_equal", "macro_sql": "{% test expect_column_pair_values_to_be_equal(model,\n column_A,\n column_B,\n row_condition=None\n ) %}\n\n{% set operator = \"=\" %}\n{% set expression = column_A ~ \" \" ~ operator ~ \" \" ~ column_B %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.617192, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_pair_values_A_to_be_greater_than_B": {"unique_id": "macro.dbt_expectations.test_expect_column_pair_values_A_to_be_greater_than_B", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_column_pair_values_A_to_be_greater_than_B.sql", "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_A_to_be_greater_than_B.sql", "name": "test_expect_column_pair_values_A_to_be_greater_than_B", "macro_sql": "{% test expect_column_pair_values_A_to_be_greater_than_B(model,\n column_A,\n column_B,\n or_equal=False,\n row_condition=None\n ) %}\n\n{% set operator = \">=\" if or_equal else \">\" %}\n{% set expression = column_A ~ \" \" ~ operator ~ \" \" ~ column_B %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.617835, "supported_languages": null}, "macro.dbt_expectations.test_expect_column_pair_values_to_be_in_set": {"unique_id": "macro.dbt_expectations.test_expect_column_pair_values_to_be_in_set", "package_name": "dbt_expectations", "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", "path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_in_set.sql", "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_in_set.sql", "name": "test_expect_column_pair_values_to_be_in_set", "macro_sql": "{% test expect_column_pair_values_to_be_in_set(model,\n column_A,\n column_B,\n value_pairs_set,\n row_condition=None\n ) %}\n\n{% set expression %}\n{% for pair in value_pairs_set %}\n{%- if (pair | length) == 2 %}\n({{ column_A }} = {{ pair[0] }} and {{ column_B }} = {{ pair[1] }}){% if not loop.last %} or {% endif %}\n{% else %}\n{{ exceptions.raise_compiler_error(\n \"`value_pairs_set` argument for expect_column_pair_values_to_be_in_set test cannot have more than 2 item per element.\n Got: '\" ~ pair ~ \"'.'\"\n ) }}\n{% endif %}\n{% endfor %}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_expectations.expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1675954222.619081, "supported_languages": null}}, "docs": {"dbt.__overview__": {"unique_id": "dbt.__overview__", "package_name": "dbt", "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", "path": "overview.md", "original_file_path": "docs/overview.md", "name": "__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}}, "exposures": {}, "metrics": {}, "selectors": {}, "disabled": {}, "parent_map": {"operation.livequery_models.livequery_models-on-run-start-0": [], "operation.livequery_models.livequery_models-on-run-end-0": [], "source.livequery_models.crosschain.dim_date_hours": []}, "child_map": {"operation.livequery_models.livequery_models-on-run-start-0": [], "operation.livequery_models.livequery_models-on-run-end-0": [], "source.livequery_models.crosschain.dim_date_hours": []}} \ No newline at end of file +{ + "metadata": { + "dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v7.json", + "dbt_version": "1.3.2", + "generated_at": "2023-02-09T14:53:51.874744Z", + "invocation_id": "6aac413a-cd1e-4019-821c-a9938f6c1fc3", + "env": {}, + "project_id": "77aec67e40364978dc5eae24f2b474a3", + "user_id": null, + "send_anonymous_usage_stats": false, + "adapter_type": "snowflake" + }, + "nodes": { + "operation.livequery_models.livequery_models-on-run-start-0": { + "compiled": true, + "resource_type": "operation", + "depends_on": { + "macros": ["macro.livequery_models.create_sps"], + "nodes": [] + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "grants": {}, + "packages": [], + "docs": { "show": true, "node_color": null }, + "post-hook": [], + "pre-hook": [] + }, + "database": "LIVEQUERY_DEV", + "schema": "livequery_models-on-run-start-0", + "fqn": ["livequery_models", "hooks", "livequery_models-on-run-start-0"], + "unique_id": "operation.livequery_models.livequery_models-on-run-start-0", + "raw_code": "{{ create_sps() }}", + "language": "sql", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "hooks/livequery_models-on-run-start-0.sql", + "original_file_path": "./dbt_project.yml", + "name": "livequery_models-on-run-start-0", + "alias": "", + "checksum": { + "name": "sha256", + "checksum": "db3ddf0272fd42cc1729433ba48aeef486b0bd492a03df34f2d269afa12a1e94" + }, + "tags": ["on-run-start"], + "refs": [], + "sources": [], + "metrics": [], + "description": "", + "columns": {}, + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "compiled_path": "target/compiled/livequery_models/./dbt_project.yml/hooks/livequery_models-on-run-start-0.sql", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1675954222.8728378, + "compiled_code": "\n \n", + "extra_ctes_injected": true, + "extra_ctes": [], + "relation_name": null, + "index": 0 + }, + "operation.livequery_models.livequery_models-on-run-end-0": { + "compiled": true, + "resource_type": "operation", + "depends_on": { + "macros": ["macro.livequery_models.apply_meta_as_tags"], + "nodes": [] + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "grants": {}, + "packages": [], + "docs": { "show": true, "node_color": null }, + "post-hook": [], + "pre-hook": [] + }, + "database": "LIVEQUERY_DEV", + "schema": "livequery_models-on-run-end-0", + "fqn": ["livequery_models", "hooks", "livequery_models-on-run-end-0"], + "unique_id": "operation.livequery_models.livequery_models-on-run-end-0", + "raw_code": "{{ apply_meta_as_tags(results) }}", + "language": "sql", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "hooks/livequery_models-on-run-end-0.sql", + "original_file_path": "./dbt_project.yml", + "name": "livequery_models-on-run-end-0", + "alias": "", + "checksum": { + "name": "sha256", + "checksum": "db3ddf0272fd42cc1729433ba48aeef486b0bd492a03df34f2d269afa12a1e94" + }, + "tags": ["on-run-end"], + "refs": [], + "sources": [], + "metrics": [], + "description": "", + "columns": {}, + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "compiled_path": "target/compiled/livequery_models/./dbt_project.yml/hooks/livequery_models-on-run-end-0.sql", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1675954222.8786502, + "compiled_code": "\n \n \n \n \n \n \n", + "extra_ctes_injected": true, + "extra_ctes": [], + "relation_name": null, + "index": 0 + } + }, + "sources": { + "source.livequery_models.crosschain.dim_date_hours": { + "fqn": ["livequery_models", "crosschain", "dim_date_hours"], + "database": "crosschain_dev", + "schema": "core", + "unique_id": "source.livequery_models.crosschain.dim_date_hours", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "models/sources.yml", + "original_file_path": "models/sources.yml", + "name": "dim_date_hours", + "source_name": "crosschain", + "source_description": "", + "loader": "", + "identifier": "dim_date_hours", + "resource_type": "source", + "quoting": { + "database": null, + "schema": null, + "identifier": null, + "column": null + }, + "loaded_at_field": null, + "freshness": { + "warn_after": { "count": null, "period": null }, + "error_after": { "count": null, "period": null }, + "filter": null + }, + "external": null, + "description": "", + "columns": {}, + "meta": {}, + "source_meta": {}, + "tags": [], + "config": { "enabled": true }, + "patch_path": null, + "unrendered_config": {}, + "relation_name": "crosschain_dev.core.dim_date_hours", + "created_at": 1675954222.9114618 + } + }, + "macros": { + "macro.livequery_models.create_sps": { + "unique_id": "macro.livequery_models.create_sps", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/create_sps.sql", + "original_file_path": "macros/create_sps.sql", + "name": "create_sps", + "macro_sql": "{% macro create_sps() %}\n {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.livequery_models.sp_create_prod_clone"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.18193, + "supported_languages": null + }, + "macro.livequery_models.generate_schema_name": { + "unique_id": "macro.livequery_models.generate_schema_name", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/custom_naming_macros.sql", + "original_file_path": "macros/custom_naming_macros.sql", + "name": "generate_schema_name", + "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {% set node_name = node.name %}\n {% set split_name = node_name.split('__') %}\n {{ split_name[0] | trim }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.1824331, + "supported_languages": null + }, + "macro.livequery_models.generate_alias_name": { + "unique_id": "macro.livequery_models.generate_alias_name", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/custom_naming_macros.sql", + "original_file_path": "macros/custom_naming_macros.sql", + "name": "generate_alias_name", + "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% set node_name = node.name %}\n {% set split_name = node_name.split('__') %}\n {{ split_name[1] | trim }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.1826959, + "supported_languages": null + }, + "macro.livequery_models.run_sp_create_prod_clone": { + "unique_id": "macro.livequery_models.run_sp_create_prod_clone", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/run_sp_create_prod_clone.sql", + "original_file_path": "macros/run_sp_create_prod_clone.sql", + "name": "run_sp_create_prod_clone", + "macro_sql": "{% macro run_sp_create_prod_clone() %}\n {% set clone_query %}\n call livequery._internal.create_prod_clone(\n 'livequery',\n 'livequery_dev',\n 'livequery_dev_owner'\n );\n{% endset %}\n {% do run_query(clone_query) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.1829991, + "supported_languages": null + }, + "macro.livequery_models.create_udfs": { + "unique_id": "macro.livequery_models.create_udfs", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/create_udfs.sql", + "original_file_path": "macros/create_udfs.sql", + "name": "create_udfs", + "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.1833768, + "supported_languages": null + }, + "macro.livequery_models.set_query_tag": { + "unique_id": "macro.livequery_models.set_query_tag", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/custom_query_tag.sql", + "original_file_path": "macros/custom_query_tag.sql", + "name": "set_query_tag", + "macro_sql": "{% macro set_query_tag() -%}\n {% set new_json = {\"repo\":project_name, \"object\":this.table, \"profile\":target.profile_name, \"env\":target.name, \"existing_tag\":get_current_query_tag() } %}\n{% set new_query_tag = tojson(new_json) | as_text %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.get_current_query_tag", + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.184247, + "supported_languages": null + }, + "macro.livequery_models.sp_create_prod_clone": { + "unique_id": "macro.livequery_models.sp_create_prod_clone", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/sp_create_prod_clone.sql", + "original_file_path": "macros/sp_create_prod_clone.sql", + "name": "sp_create_prod_clone", + "macro_sql": "{% macro sp_create_prod_clone(target_schema) -%}\n\ncreate or replace procedure {{ target_schema }}.create_prod_clone(source_db_name string, destination_db_name string, role_name string)\nreturns boolean \nlanguage javascript\nexecute as caller\nas\n$$\n snowflake.execute({sqlText: `BEGIN TRANSACTION;`});\n try {\n snowflake.execute({sqlText: `CREATE OR REPLACE DATABASE ${DESTINATION_DB_NAME} CLONE ${SOURCE_DB_NAME}`});\n snowflake.execute({sqlText: `DROP SCHEMA IF EXISTS ${DESTINATION_DB_NAME}._INTERNAL`}); /* this only needs to be in prod */\n\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL SCHEMAS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); \n\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`})\n\n var existing_tags = snowflake.execute({sqlText: `SHOW TAGS IN DATABASE ${DESTINATION_DB_NAME};`});\n while (existing_tags.next()) {\n var schema = existing_tags.getColumnValue(4);\n var tag_name = existing_tags.getColumnValue(2)\n snowflake.execute({sqlText: `GRANT OWNERSHIP ON TAG ${DESTINATION_DB_NAME}.${schema}.${tag_name} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});\n }\n\n snowflake.execute({sqlText: `COMMIT;`});\n } catch (err) {\n snowflake.execute({sqlText: `ROLLBACK;`});\n throw(err);\n }\n\n return true\n$$\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.184911, + "supported_languages": null + }, + "macro.livequery_models.add_database_or_schema_tags": { + "unique_id": "macro.livequery_models.add_database_or_schema_tags", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/add_database_or_schema_tags.sql", + "original_file_path": "macros/tags/add_database_or_schema_tags.sql", + "name": "add_database_or_schema_tags", + "macro_sql": "{% macro add_database_or_schema_tags() %}\n {{ set_database_tag_value('BLOCKCHAIN_NAME','LIVEQUERY') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.livequery_models.set_database_tag_value"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.18513, + "supported_languages": null + }, + "macro.livequery_models.apply_meta_as_tags": { + "unique_id": "macro.livequery_models.apply_meta_as_tags", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "apply_meta_as_tags", + "macro_sql": "{% macro apply_meta_as_tags(results) %}\n {% if var(\"UPDATE_SNOWFLAKE_TAGS\") %}\n {{ log('apply_meta_as_tags', info=False) }}\n {{ log(results, info=False) }}\n {% if execute %}\n\n {%- set tags_by_schema = {} -%}\n {% for res in results -%}\n {% if res.node.meta.database_tags %}\n\n {%- set model_database = res.node.database -%}\n {%- set model_schema = res.node.schema -%}\n {%- set model_schema_full = model_database+'.'+model_schema -%}\n {%- set model_alias = res.node.alias -%}\n\n {% if model_schema_full not in tags_by_schema.keys() %}\n {{ log('need to fetch tags for schema '+model_schema_full, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n show tags in {{model_database}}.{{model_schema}}\n {%- endcall -%}\n {%- set _ = tags_by_schema.update({model_schema_full: load_result('main')['table'].columns.get('name').values()|list}) -%}\n {{ log('Added tags to cache', info=False) }}\n {% else %}\n {{ log('already have tag info for schema', info=False) }}\n {% endif %}\n\n {%- set current_tags_in_schema = tags_by_schema[model_schema_full] -%}\n {{ log('current_tags_in_schema:', info=False) }}\n {{ log(current_tags_in_schema, info=False) }}\n {{ log(\"========== Processing tags for \"+model_schema_full+\".\"+model_alias+\" ==========\", info=False) }}\n\n {% set line -%}\n node: {{ res.node.unique_id }}; status: {{ res.status }} (message: {{ res.message }})\n node full: {{ res.node}}\n meta: {{ res.node.meta}}\n materialized: {{ res.node.config.materialized }}\n {%- endset %}\n {{ log(line, info=False) }}\n\n {%- call statement('main', fetch_result=True) -%}\n select LEVEL,UPPER(TAG_NAME) as TAG_NAME,TAG_VALUE from table(information_schema.tag_references_all_columns('{{model_schema}}.{{model_alias}}', 'table'))\n {%- endcall -%}\n {%- set existing_tags_for_table = load_result('main')['data'] -%}\n {{ log('Existing tags for table:', info=False) }}\n {{ log(existing_tags_for_table, info=False) }}\n\n {{ log('--', info=False) }}\n {% for table_tag in res.node.meta.database_tags.table %}\n\n {{ create_tag_if_missing(current_tags_in_schema,table_tag|upper) }}\n {% set desired_tag_value = res.node.meta.database_tags.table[table_tag] %}\n\n {{set_table_tag_value_if_different(model_schema,model_alias,table_tag,desired_tag_value,existing_tags_for_table)}}\n {% endfor %}\n {{ log(\"========== Finished processing tags for \"+model_alias+\" ==========\", info=False) }}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.livequery_models.create_tag_if_missing", + "macro.livequery_models.set_table_tag_value_if_different" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.196293, + "supported_languages": null + }, + "macro.livequery_models.create_tag_if_missing": { + "unique_id": "macro.livequery_models.create_tag_if_missing", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "create_tag_if_missing", + "macro_sql": "{% macro create_tag_if_missing(all_tag_names,table_tag) %}\n\t{% if table_tag not in all_tag_names %}\n\t\t{{ log('Creating missing tag '+table_tag, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n create tag if not exists silver.{{table_tag}}\n {%- endcall -%}\n\t\t{{ log(load_result('main').data, info=False) }}\n\t{% else %}\n\t\t{{ log('Tag already exists: '+table_tag, info=False) }}\n\t{% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.196773, + "supported_languages": null + }, + "macro.livequery_models.set_table_tag_value_if_different": { + "unique_id": "macro.livequery_models.set_table_tag_value_if_different", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "set_table_tag_value_if_different", + "macro_sql": "{% macro set_table_tag_value_if_different(model_schema,table_name,tag_name,desired_tag_value,existing_tags) %}\n {{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at table level', info=False) }}\n {%- set existing_tag_for_table = existing_tags|selectattr('0','equalto','TABLE')|selectattr('1','equalto',tag_name|upper)|list -%}\n {{ log('Filtered tags for table:', info=False) }}\n {{ log(existing_tag_for_table[0], info=False) }}\n {% if existing_tag_for_table|length > 0 and existing_tag_for_table[0][2]==desired_tag_value %}\n {{ log('Correct tag value already exists', info=False) }}\n {% else %}\n {{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n alter table {{model_schema}}.{{table_name}} set tag {{tag_name}} = '{{desired_tag_value}}'\n {%- endcall -%}\n {{ log(load_result('main').data, info=False) }}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.1977339, + "supported_languages": null + }, + "macro.livequery_models.set_column_tag_value_if_different": { + "unique_id": "macro.livequery_models.set_column_tag_value_if_different", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "set_column_tag_value_if_different", + "macro_sql": "{% macro set_column_tag_value_if_different(table_name,column_name,tag_name,desired_tag_value,existing_tags) %}\n {{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at column level', info=False) }}\n {%- set existing_tag_for_column = existing_tags|selectattr('0','equalto','COLUMN')|selectattr('1','equalto',tag_name|upper)|list -%}\n {{ log('Filtered tags for column:', info=False) }}\n {{ log(existing_tag_for_column[0], info=False) }}\n {% if existing_tag_for_column|length > 0 and existing_tag_for_column[0][2]==desired_tag_value %}\n {{ log('Correct tag value already exists', info=False) }}\n {% else %}\n {{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}\n {%- call statement('main', fetch_result=True) -%}\n alter table {{table_name}} modify column {{column_name}} set tag {{tag_name}} = '{{desired_tag_value}}'\n {%- endcall -%}\n {{ log(load_result('main').data, info=False) }}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.198677, + "supported_languages": null + }, + "macro.livequery_models.set_database_tag_value": { + "unique_id": "macro.livequery_models.set_database_tag_value", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "set_database_tag_value", + "macro_sql": "{% macro set_database_tag_value(tag_name,tag_value) %}\n {% set query %}\n create tag if not exists silver.{{tag_name}}\n {% endset %}\n {% do run_query(query) %}\n {% set query %}\n alter database {{target.database}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'\n {% endset %}\n {% do run_query(query) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.199031, + "supported_languages": null + }, + "macro.livequery_models.set_schema_tag_value": { + "unique_id": "macro.livequery_models.set_schema_tag_value", + "package_name": "livequery_models", + "root_path": "/Users/ericlaurello/git/livequery-models", + "path": "macros/tags/snowflake_tagging.sql", + "original_file_path": "macros/tags/snowflake_tagging.sql", + "name": "set_schema_tag_value", + "macro_sql": "{% macro set_schema_tag_value(target_schema,tag_name,tag_value) %}\n {% set query %}\n create tag if not exists silver.{{tag_name}}\n {% endset %}\n {% do run_query(query) %}\n {% set query %}\n alter schema {{target.database}}.{{target_schema}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'\n {% endset %}\n {% do run_query(query) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.199394, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog": { + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "name": "snowflake__get_catalog", + "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n {% set query %}\n with tables as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n table_type as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n\n from {{ information_schema }}.tables\n\n ),\n\n columns as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n\n from {{ information_schema }}.columns\n )\n\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n where (\n {%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by \"column_index\"\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.200282, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_table_as": { + "unique_id": "macro.dbt_snowflake.snowflake__create_table_as", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__create_table_as", + "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- if language == 'sql' -%}\n {%- set transient = config.get('transient', default=true) -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {% if temporary -%}\n temporary\n {%- elif transient -%}\n transient\n {%- endif %} table {{ relation }} {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from(\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, temporary=temporary) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_snowflake.py_write_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2121012, + "supported_languages": null + }, + "macro.dbt_snowflake.get_column_comment_sql": { + "unique_id": "macro.dbt_snowflake.get_column_comment_sql", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "get_column_comment_sql", + "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.212733, + "supported_languages": null + }, + "macro.dbt_snowflake.get_persist_docs_column_list": { + "unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "get_persist_docs_column_list", + "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.get_column_comment_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2129862, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_view_as": { + "unique_id": "macro.dbt_snowflake.snowflake__create_view_as", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__create_view_as", + "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_columns_in_query", + "macro.dbt_snowflake.get_persist_docs_column_list" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.213637, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_columns_in_relation": { + "unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__get_columns_in_relation", + "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.214319, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__list_schemas": { + "unique_id": "macro.dbt_snowflake.snowflake__list_schemas", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__list_schemas", + "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2148092, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__list_relations_without_caching": { + "unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__list_relations_without_caching", + "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation) %}\n {%- set sql -%}\n show terse objects in {{ schema_relation }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in schema {{ schema_relation }}! dbt can only get\n information about schemas with fewer than {{ maximum }} objects.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {%- do return(result) -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2152488, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__check_schema_exists": { + "unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__check_schema_exists", + "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.215531, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__rename_relation": { + "unique_id": "macro.dbt_snowflake.snowflake__rename_relation", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__rename_relation", + "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.215701, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_column_type": { + "unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__alter_column_type", + "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.215924, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_relation_comment": { + "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__alter_relation_comment", + "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n comment on {{ relation.type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2161112, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_column_comment": { + "unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__alter_column_comment", + "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n alter {{ relation.type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.get_column_comment_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.216565, + "supported_languages": null + }, + "macro.dbt_snowflake.get_current_query_tag": { + "unique_id": "macro.dbt_snowflake.get_current_query_tag", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "get_current_query_tag", + "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.21673, + "supported_languages": null + }, + "macro.dbt_snowflake.set_query_tag": { + "unique_id": "macro.dbt_snowflake.set_query_tag", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "set_query_tag", + "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__set_query_tag"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.216872, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__set_query_tag": { + "unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__set_query_tag", + "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.get_current_query_tag", + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.217592, + "supported_languages": null + }, + "macro.dbt_snowflake.unset_query_tag": { + "unique_id": "macro.dbt_snowflake.unset_query_tag", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "unset_query_tag", + "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.217758, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__unset_query_tag": { + "unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__unset_query_tag", + "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.218187, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": { + "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__alter_relation_add_remove_columns", + "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.218845, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake_dml_explicit_transaction": { + "unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake_dml_explicit_transaction", + "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2190359, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__truncate_relation": { + "unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "name": "snowflake__truncate_relation", + "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.219248, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__copy_grants": { + "unique_id": "macro.dbt_snowflake.snowflake__copy_grants", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/apply_grants.sql", + "original_file_path": "macros/apply_grants.sql", + "name": "snowflake__copy_grants", + "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.219574, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": { + "unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/apply_grants.sql", + "original_file_path": "macros/apply_grants.sql", + "name": "snowflake__support_multiple_grantees_per_dcl_statement", + "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.219674, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_test_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_test_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/test.sql", + "original_file_path": "macros/materializations/test.sql", + "name": "materialization_test_snowflake", + "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.materialization_test_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.220047, + "supported_languages": ["sql"] + }, + "macro.dbt_snowflake.snowflake__get_merge_sql": { + "unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "name": "snowflake__get_merge_sql", + "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv", + "macro.dbt.default__get_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.221177, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": { + "unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "name": "snowflake__get_delete_insert_merge_sql", + "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.default__get_delete_insert_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.221427, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_merge_sql": { + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "name": "snowflake__snapshot_merge_sql", + "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.default__snapshot_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.221656, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__load_csv_rows": { + "unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/seed.sql", + "original_file_path": "macros/materializations/seed.sql", + "name": "snowflake__load_csv_rows", + "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_batch_size", + "macro.dbt.get_seed_column_quoted_csv" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.223575, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_seed_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/seed.sql", + "original_file_path": "macros/materializations/seed.sql", + "name": "materialization_seed_snowflake", + "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.materialization_seed_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.223907, + "supported_languages": ["sql"] + }, + "macro.dbt_snowflake.materialization_view_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_view_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/view.sql", + "original_file_path": "macros/materializations/view.sql", + "name": "materialization_view_snowflake", + "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do return(to_return) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n{%- endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.create_or_replace_view", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2244601, + "supported_languages": ["sql"] + }, + "macro.dbt_snowflake.materialization_table_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_table_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "name": "materialization_table_snowflake", + "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.run_hooks", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.statement", + "macro.dbt.create_table_as", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.22664, + "supported_languages": ["sql", "python"] + }, + "macro.dbt_snowflake.py_write_table": { + "unique_id": "macro.dbt_snowflake.py_write_table", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "name": "py_write_table", + "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False) %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n df.write.mode(\"overwrite\").save_as_table(\"{{ target_relation }}\", create_temp_table={{temporary}})\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.226835, + "supported_languages": null + }, + "macro.dbt_snowflake.py_script_comment": { + "unique_id": "macro.dbt_snowflake.py_script_comment", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "name": "py_script_comment", + "macro_sql": "{%macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.22693, + "supported_languages": null + }, + "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": { + "unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "name": "dbt_snowflake_get_tmp_relation_type", + "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n\n /* {#\n If we are running multiple statements (DELETE + INSERT),\n we must first save the model query results as a temporary table\n in order to guarantee consistent inputs to both statements.\n\n If we are running a single statement (MERGE or INSERT alone),\n we can save the model query definition as a view instead,\n for faster overall incremental processing.\n #} */\n\n {% if language == 'sql' and (strategy in ('default', 'append', 'merge') or (unique_key is none)) %}\n {{ return('view') }}\n {% else %} {#-- play it safe -- #}\n {{ return('table') }}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.228244, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_incremental_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "name": "materialization_incremental_snowflake", + "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ create_view_as(tmp_relation, compiled_code) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.should_full_refresh", + "macro.dbt.load_relation", + "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", + "macro.dbt.make_temp_relation", + "macro.dbt.incremental_validate_on_schema_change", + "macro.dbt.run_hooks", + "macro.dbt.statement", + "macro.dbt.create_table_as", + "macro.dbt.create_view_as", + "macro.dbt.process_schema_changes", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.231225, + "supported_languages": ["sql", "python"] + }, + "macro.dbt_snowflake.snowflake__get_incremental_default_sql": { + "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "name": "snowflake__get_incremental_default_sql", + "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_incremental_merge_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2313778, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_snapshot_snowflake": { + "unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/materializations/snapshot.sql", + "original_file_path": "macros/materializations/snapshot.sql", + "name": "materialization_snapshot_snowflake", + "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.materialization_snapshot_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.231769, + "supported_languages": ["sql"] + }, + "macro.dbt_snowflake.snowflake__current_timestamp": { + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "name": "snowflake__current_timestamp", + "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.232095, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_string_as_time": { + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "name": "snowflake__snapshot_string_as_time", + "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2322528, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_get_time": { + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "name": "snowflake__snapshot_get_time", + "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.current_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.232351, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": { + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "name": "snowflake__current_timestamp_backcompat", + "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.type_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2324429, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": { + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "name": "snowflake__current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", + "macro.dbt_expectations.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2325609, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__escape_single_quotes": { + "unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "name": "snowflake__escape_single_quotes", + "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2327921, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__right": { + "unique_id": "macro.dbt_snowflake.snowflake__right", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "name": "snowflake__right", + "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.233056, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__safe_cast": { + "unique_id": "macro.dbt_snowflake.snowflake__safe_cast", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "name": "snowflake__safe_cast", + "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.233263, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__bool_or": { + "unique_id": "macro.dbt_snowflake.snowflake__bool_or", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "name": "snowflake__bool_or", + "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2334368, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__array_construct": { + "unique_id": "macro.dbt_snowflake.snowflake__array_construct", + "package_name": "dbt_snowflake", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/snowflake", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "name": "snowflake__array_construct", + "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2336488, + "supported_languages": null + }, + "macro.dbt.run_hooks": { + "unique_id": "macro.dbt.run_hooks", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "name": "run_hooks", + "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.234656, + "supported_languages": null + }, + "macro.dbt.make_hook_config": { + "unique_id": "macro.dbt.make_hook_config", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "name": "make_hook_config", + "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.234829, + "supported_languages": null + }, + "macro.dbt.before_begin": { + "unique_id": "macro.dbt.before_begin", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "name": "before_begin", + "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.make_hook_config"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2349591, + "supported_languages": null + }, + "macro.dbt.in_transaction": { + "unique_id": "macro.dbt.in_transaction", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "name": "in_transaction", + "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.make_hook_config"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.235083, + "supported_languages": null + }, + "macro.dbt.after_commit": { + "unique_id": "macro.dbt.after_commit", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "name": "after_commit", + "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.make_hook_config"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2352068, + "supported_languages": null + }, + "macro.dbt.set_sql_header": { + "unique_id": "macro.dbt.set_sql_header", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "name": "set_sql_header", + "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.235591, + "supported_languages": null + }, + "macro.dbt.should_full_refresh": { + "unique_id": "macro.dbt.should_full_refresh", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "name": "should_full_refresh", + "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.23592, + "supported_languages": null + }, + "macro.dbt.should_store_failures": { + "unique_id": "macro.dbt.should_store_failures", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "name": "should_store_failures", + "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.236209, + "supported_languages": null + }, + "macro.dbt.snapshot_merge_sql": { + "unique_id": "macro.dbt.snapshot_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/snapshot_merge.sql", + "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", + "name": "snapshot_merge_sql", + "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2366662, + "supported_languages": null + }, + "macro.dbt.default__snapshot_merge_sql": { + "unique_id": "macro.dbt.default__snapshot_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/snapshot_merge.sql", + "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", + "name": "default__snapshot_merge_sql", + "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2369049, + "supported_languages": null + }, + "macro.dbt.strategy_dispatch": { + "unique_id": "macro.dbt.strategy_dispatch", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "strategy_dispatch", + "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.239976, + "supported_languages": null + }, + "macro.dbt.snapshot_hash_arguments": { + "unique_id": "macro.dbt.snapshot_hash_arguments", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "snapshot_hash_arguments", + "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__snapshot_hash_arguments"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.240125, + "supported_languages": null + }, + "macro.dbt.default__snapshot_hash_arguments": { + "unique_id": "macro.dbt.default__snapshot_hash_arguments", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "default__snapshot_hash_arguments", + "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.240319, + "supported_languages": null + }, + "macro.dbt.snapshot_timestamp_strategy": { + "unique_id": "macro.dbt.snapshot_timestamp_strategy", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "snapshot_timestamp_strategy", + "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.snapshot_hash_arguments"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.240957, + "supported_languages": null + }, + "macro.dbt.snapshot_string_as_time": { + "unique_id": "macro.dbt.snapshot_string_as_time", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "snapshot_string_as_time", + "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2411032, + "supported_languages": null + }, + "macro.dbt.default__snapshot_string_as_time": { + "unique_id": "macro.dbt.default__snapshot_string_as_time", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "default__snapshot_string_as_time", + "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.241257, + "supported_languages": null + }, + "macro.dbt.snapshot_check_all_get_existing_columns": { + "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "snapshot_check_all_get_existing_columns", + "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n select {{ check_cols_config | join(', ') }} from ({{ node['compiled_code'] }}) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_columns_in_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.242493, + "supported_languages": null + }, + "macro.dbt.snapshot_check_strategy": { + "unique_id": "macro.dbt.snapshot_check_strategy", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "name": "snapshot_check_strategy", + "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.snapshot_get_time", + "macro.dbt.snapshot_check_all_get_existing_columns", + "macro.dbt.get_true_sql", + "macro.dbt.snapshot_hash_arguments" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2437189, + "supported_languages": null + }, + "macro.dbt.create_columns": { + "unique_id": "macro.dbt.create_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "create_columns", + "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__create_columns"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2471738, + "supported_languages": null + }, + "macro.dbt.default__create_columns": { + "unique_id": "macro.dbt.default__create_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "default__create_columns", + "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2474282, + "supported_languages": null + }, + "macro.dbt.post_snapshot": { + "unique_id": "macro.dbt.post_snapshot", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "post_snapshot", + "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__post_snapshot"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2475789, + "supported_languages": null + }, + "macro.dbt.default__post_snapshot": { + "unique_id": "macro.dbt.default__post_snapshot", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "default__post_snapshot", + "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.247657, + "supported_languages": null + }, + "macro.dbt.get_true_sql": { + "unique_id": "macro.dbt.get_true_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "get_true_sql", + "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_true_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.247787, + "supported_languages": null + }, + "macro.dbt.default__get_true_sql": { + "unique_id": "macro.dbt.default__get_true_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "default__get_true_sql", + "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2478862, + "supported_languages": null + }, + "macro.dbt.snapshot_staging_table": { + "unique_id": "macro.dbt.snapshot_staging_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "snapshot_staging_table", + "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__snapshot_staging_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.248069, + "supported_languages": null + }, + "macro.dbt.default__snapshot_staging_table": { + "unique_id": "macro.dbt.default__snapshot_staging_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "default__snapshot_staging_table", + "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.snapshot_get_time"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.248846, + "supported_languages": null + }, + "macro.dbt.build_snapshot_table": { + "unique_id": "macro.dbt.build_snapshot_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "build_snapshot_table", + "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__build_snapshot_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.249014, + "supported_languages": null + }, + "macro.dbt.default__build_snapshot_table": { + "unique_id": "macro.dbt.default__build_snapshot_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "default__build_snapshot_table", + "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.249233, + "supported_languages": null + }, + "macro.dbt.build_snapshot_staging_table": { + "unique_id": "macro.dbt.build_snapshot_staging_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "name": "build_snapshot_staging_table", + "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.make_temp_relation", + "macro.dbt.snapshot_staging_table", + "macro.dbt.statement", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.249608, + "supported_languages": null + }, + "macro.dbt.materialization_snapshot_default": { + "unique_id": "macro.dbt.materialization_snapshot_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/snapshots/snapshot.sql", + "original_file_path": "macros/materializations/snapshots/snapshot.sql", + "name": "materialization_snapshot_default", + "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_or_create_relation", + "macro.dbt.run_hooks", + "macro.dbt.strategy_dispatch", + "macro.dbt.build_snapshot_table", + "macro.dbt.create_table_as", + "macro.dbt.build_snapshot_staging_table", + "macro.dbt.create_columns", + "macro.dbt.snapshot_merge_sql", + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes", + "macro.dbt.post_snapshot" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.254879, + "supported_languages": ["sql"] + }, + "macro.dbt.materialization_test_default": { + "unique_id": "macro.dbt.materialization_test_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/tests/test.sql", + "original_file_path": "macros/materializations/tests/test.sql", + "name": "materialization_test_default", + "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type='table') -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ create_table_as(False, target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.should_store_failures", + "macro.dbt.statement", + "macro.dbt.create_table_as", + "macro.dbt.get_test_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2567658, + "supported_languages": ["sql"] + }, + "macro.dbt.get_test_sql": { + "unique_id": "macro.dbt.get_test_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/tests/helpers.sql", + "original_file_path": "macros/materializations/tests/helpers.sql", + "name": "get_test_sql", + "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_test_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.257233, + "supported_languages": null + }, + "macro.dbt.default__get_test_sql": { + "unique_id": "macro.dbt.default__get_test_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/tests/helpers.sql", + "original_file_path": "macros/materializations/tests/helpers.sql", + "name": "default__get_test_sql", + "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.257504, + "supported_languages": null + }, + "macro.dbt.get_where_subquery": { + "unique_id": "macro.dbt.get_where_subquery", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/tests/where_subquery.sql", + "original_file_path": "macros/materializations/tests/where_subquery.sql", + "name": "get_where_subquery", + "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_where_subquery"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2578912, + "supported_languages": null + }, + "macro.dbt.default__get_where_subquery": { + "unique_id": "macro.dbt.default__get_where_subquery", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/tests/where_subquery.sql", + "original_file_path": "macros/materializations/tests/where_subquery.sql", + "name": "default__get_where_subquery", + "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.258224, + "supported_languages": null + }, + "macro.dbt.get_quoted_csv": { + "unique_id": "macro.dbt.get_quoted_csv", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "name": "get_quoted_csv", + "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.259655, + "supported_languages": null + }, + "macro.dbt.diff_columns": { + "unique_id": "macro.dbt.diff_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "name": "diff_columns", + "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2601411, + "supported_languages": null + }, + "macro.dbt.diff_column_data_types": { + "unique_id": "macro.dbt.diff_column_data_types", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "name": "diff_column_data_types", + "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.260737, + "supported_languages": null + }, + "macro.dbt.get_merge_update_columns": { + "unique_id": "macro.dbt.get_merge_update_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "name": "get_merge_update_columns", + "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_merge_update_columns"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.260947, + "supported_languages": null + }, + "macro.dbt.default__get_merge_update_columns": { + "unique_id": "macro.dbt.default__get_merge_update_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "name": "default__get_merge_update_columns", + "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.261577, + "supported_languages": null + }, + "macro.dbt.get_merge_sql": { + "unique_id": "macro.dbt.get_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "get_merge_sql", + "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.265389, + "supported_languages": null + }, + "macro.dbt.default__get_merge_sql": { + "unique_id": "macro.dbt.default__get_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "default__get_merge_sql", + "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, predicates) -%}\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{ predicates | join(' and ') }}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv", + "macro.dbt.get_merge_update_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2668219, + "supported_languages": null + }, + "macro.dbt.get_delete_insert_merge_sql": { + "unique_id": "macro.dbt.get_delete_insert_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "get_delete_insert_merge_sql", + "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2670321, + "supported_languages": null + }, + "macro.dbt.default__get_delete_insert_merge_sql": { + "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "default__get_delete_insert_merge_sql", + "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last }}\n {% endfor %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_quoted_csv"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.26768, + "supported_languages": null + }, + "macro.dbt.get_insert_overwrite_merge_sql": { + "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "get_insert_overwrite_merge_sql", + "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.267919, + "supported_languages": null + }, + "macro.dbt.default__get_insert_overwrite_merge_sql": { + "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "name": "default__get_insert_overwrite_merge_sql", + "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_quoted_csv"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.268481, + "supported_languages": null + }, + "macro.dbt.is_incremental": { + "unique_id": "macro.dbt.is_incremental", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/is_incremental.sql", + "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", + "name": "is_incremental", + "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.should_full_refresh"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2690969, + "supported_languages": null + }, + "macro.dbt.get_incremental_append_sql": { + "unique_id": "macro.dbt.get_incremental_append_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_incremental_append_sql", + "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_incremental_append_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.26992, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_append_sql": { + "unique_id": "macro.dbt.default__get_incremental_append_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "default__get_incremental_append_sql", + "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_insert_into_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.270132, + "supported_languages": null + }, + "macro.dbt.get_incremental_delete_insert_sql": { + "unique_id": "macro.dbt.get_incremental_delete_insert_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_incremental_delete_insert_sql", + "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_incremental_delete_insert_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2702951, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_delete_insert_sql": { + "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "default__get_incremental_delete_insert_sql", + "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_delete_insert_merge_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2705312, + "supported_languages": null + }, + "macro.dbt.get_incremental_merge_sql": { + "unique_id": "macro.dbt.get_incremental_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_incremental_merge_sql", + "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_incremental_merge_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.270696, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_merge_sql": { + "unique_id": "macro.dbt.default__get_incremental_merge_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "default__get_incremental_merge_sql", + "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_merge_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.270932, + "supported_languages": null + }, + "macro.dbt.get_incremental_insert_overwrite_sql": { + "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_incremental_insert_overwrite_sql", + "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2710972, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_insert_overwrite_sql": { + "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "default__get_incremental_insert_overwrite_sql", + "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"predicates\"])) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_insert_overwrite_merge_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2713332, + "supported_languages": null + }, + "macro.dbt.get_incremental_default_sql": { + "unique_id": "macro.dbt.get_incremental_default_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_incremental_default_sql", + "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.271504, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_default_sql": { + "unique_id": "macro.dbt.default__get_incremental_default_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "default__get_incremental_default_sql", + "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_incremental_append_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.271636, + "supported_languages": null + }, + "macro.dbt.get_insert_into_sql": { + "unique_id": "macro.dbt.get_insert_into_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "name": "get_insert_into_sql", + "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.get_quoted_csv"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.27188, + "supported_languages": null + }, + "macro.dbt.materialization_incremental_default": { + "unique_id": "macro.dbt.materialization_incremental_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/incremental.sql", + "original_file_path": "macros/materializations/models/incremental/incremental.sql", + "name": "materialization_incremental_default", + "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_temp_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.should_full_refresh", + "macro.dbt.incremental_validate_on_schema_change", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks", + "macro.dbt.get_create_table_as_sql", + "macro.dbt.run_query", + "macro.dbt.process_schema_changes", + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.276313, + "supported_languages": ["sql"] + }, + "macro.dbt.incremental_validate_on_schema_change": { + "unique_id": "macro.dbt.incremental_validate_on_schema_change", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "name": "incremental_validate_on_schema_change", + "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.281012, + "supported_languages": null + }, + "macro.dbt.check_for_schema_changes": { + "unique_id": "macro.dbt.check_for_schema_changes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "name": "check_for_schema_changes", + "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.282086, + "supported_languages": null + }, + "macro.dbt.sync_column_schemas": { + "unique_id": "macro.dbt.sync_column_schemas", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "name": "sync_column_schemas", + "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.alter_relation_add_remove_columns", + "macro.dbt.alter_column_type" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.283144, + "supported_languages": null + }, + "macro.dbt.process_schema_changes": { + "unique_id": "macro.dbt.process_schema_changes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "name": "process_schema_changes", + "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.check_for_schema_changes", + "macro.dbt.sync_column_schemas" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.283888, + "supported_languages": null + }, + "macro.dbt.materialization_table_default": { + "unique_id": "macro.dbt.materialization_table_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/table/table.sql", + "original_file_path": "macros/materializations/models/table/table.sql", + "name": "materialization_table_default", + "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks", + "macro.dbt.statement", + "macro.dbt.get_create_table_as_sql", + "macro.dbt.create_indexes", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2862191, + "supported_languages": ["sql"] + }, + "macro.dbt.get_create_table_as_sql": { + "unique_id": "macro.dbt.get_create_table_as_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/table/create_table_as.sql", + "original_file_path": "macros/materializations/models/table/create_table_as.sql", + "name": "get_create_table_as_sql", + "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__get_create_table_as_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.286738, + "supported_languages": null + }, + "macro.dbt.default__get_create_table_as_sql": { + "unique_id": "macro.dbt.default__get_create_table_as_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/table/create_table_as.sql", + "original_file_path": "macros/materializations/models/table/create_table_as.sql", + "name": "default__get_create_table_as_sql", + "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.create_table_as"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2869031, + "supported_languages": null + }, + "macro.dbt.create_table_as": { + "unique_id": "macro.dbt.create_table_as", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/table/create_table_as.sql", + "original_file_path": "macros/materializations/models/table/create_table_as.sql", + "name": "create_table_as", + "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__create_table_as"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.28728, + "supported_languages": null + }, + "macro.dbt.default__create_table_as": { + "unique_id": "macro.dbt.default__create_table_as", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/table/create_table_as.sql", + "original_file_path": "macros/materializations/models/table/create_table_as.sql", + "name": "default__create_table_as", + "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n as (\n {{ sql }}\n );\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.287642, + "supported_languages": null + }, + "macro.dbt.materialization_view_default": { + "unique_id": "macro.dbt.materialization_view_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/view.sql", + "original_file_path": "macros/materializations/models/view/view.sql", + "name": "materialization_view_default", + "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.run_hooks", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.statement", + "macro.dbt.get_create_view_as_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2899609, + "supported_languages": ["sql"] + }, + "macro.dbt.handle_existing_table": { + "unique_id": "macro.dbt.handle_existing_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/helpers.sql", + "original_file_path": "macros/materializations/models/view/helpers.sql", + "name": "handle_existing_table", + "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__handle_existing_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2902899, + "supported_languages": null + }, + "macro.dbt.default__handle_existing_table": { + "unique_id": "macro.dbt.default__handle_existing_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/helpers.sql", + "original_file_path": "macros/materializations/models/view/helpers.sql", + "name": "default__handle_existing_table", + "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.290487, + "supported_languages": null + }, + "macro.dbt.create_or_replace_view": { + "unique_id": "macro.dbt.create_or_replace_view", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/create_or_replace_view.sql", + "original_file_path": "macros/materializations/models/view/create_or_replace_view.sql", + "name": "create_or_replace_view", + "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=True) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.run_hooks", + "macro.dbt.handle_existing_table", + "macro.dbt.should_full_refresh", + "macro.dbt.statement", + "macro.dbt.get_create_view_as_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2918642, + "supported_languages": null + }, + "macro.dbt.get_create_view_as_sql": { + "unique_id": "macro.dbt.get_create_view_as_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/create_view_as.sql", + "original_file_path": "macros/materializations/models/view/create_view_as.sql", + "name": "get_create_view_as_sql", + "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_create_view_as_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2922502, + "supported_languages": null + }, + "macro.dbt.default__get_create_view_as_sql": { + "unique_id": "macro.dbt.default__get_create_view_as_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/create_view_as.sql", + "original_file_path": "macros/materializations/models/view/create_view_as.sql", + "name": "default__get_create_view_as_sql", + "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.create_view_as"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.292392, + "supported_languages": null + }, + "macro.dbt.create_view_as": { + "unique_id": "macro.dbt.create_view_as", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/create_view_as.sql", + "original_file_path": "macros/materializations/models/view/create_view_as.sql", + "name": "create_view_as", + "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__create_view_as"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.2925508, + "supported_languages": null + }, + "macro.dbt.default__create_view_as": { + "unique_id": "macro.dbt.default__create_view_as", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/models/view/create_view_as.sql", + "original_file_path": "macros/materializations/models/view/create_view_as.sql", + "name": "default__create_view_as", + "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }} as (\n {{ sql }}\n );\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.292777, + "supported_languages": null + }, + "macro.dbt.materialization_seed_default": { + "unique_id": "macro.dbt.materialization_seed_default", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/seed.sql", + "original_file_path": "macros/materializations/seeds/seed.sql", + "name": "materialization_seed_default", + "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparision later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.should_full_refresh", + "macro.dbt.run_hooks", + "macro.dbt.reset_csv_table", + "macro.dbt.create_csv_table", + "macro.dbt.load_csv_rows", + "macro.dbt.noop_statement", + "macro.dbt.get_csv_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.295721, + "supported_languages": ["sql"] + }, + "macro.dbt.create_csv_table": { + "unique_id": "macro.dbt.create_csv_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "create_csv_table", + "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__create_csv_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.29993, + "supported_languages": null + }, + "macro.dbt.default__create_csv_table": { + "unique_id": "macro.dbt.default__create_csv_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__create_csv_table", + "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.300724, + "supported_languages": null + }, + "macro.dbt.reset_csv_table": { + "unique_id": "macro.dbt.reset_csv_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "reset_csv_table", + "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__reset_csv_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.300931, + "supported_languages": null + }, + "macro.dbt.default__reset_csv_table": { + "unique_id": "macro.dbt.default__reset_csv_table", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__reset_csv_table", + "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.create_csv_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.301358, + "supported_languages": null + }, + "macro.dbt.get_csv_sql": { + "unique_id": "macro.dbt.get_csv_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "get_csv_sql", + "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_csv_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3015301, + "supported_languages": null + }, + "macro.dbt.default__get_csv_sql": { + "unique_id": "macro.dbt.default__get_csv_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__get_csv_sql", + "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.301646, + "supported_languages": null + }, + "macro.dbt.get_binding_char": { + "unique_id": "macro.dbt.get_binding_char", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "get_binding_char", + "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_binding_char"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.301771, + "supported_languages": null + }, + "macro.dbt.default__get_binding_char": { + "unique_id": "macro.dbt.default__get_binding_char", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__get_binding_char", + "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.30187, + "supported_languages": null + }, + "macro.dbt.get_batch_size": { + "unique_id": "macro.dbt.get_batch_size", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "get_batch_size", + "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_batch_size"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.302015, + "supported_languages": null + }, + "macro.dbt.default__get_batch_size": { + "unique_id": "macro.dbt.default__get_batch_size", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__get_batch_size", + "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3021178, + "supported_languages": null + }, + "macro.dbt.get_seed_column_quoted_csv": { + "unique_id": "macro.dbt.get_seed_column_quoted_csv", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "get_seed_column_quoted_csv", + "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3025339, + "supported_languages": null + }, + "macro.dbt.load_csv_rows": { + "unique_id": "macro.dbt.load_csv_rows", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "load_csv_rows", + "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3026938, + "supported_languages": null + }, + "macro.dbt.default__load_csv_rows": { + "unique_id": "macro.dbt.default__load_csv_rows", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "name": "default__load_csv_rows", + "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.get_batch_size", + "macro.dbt.get_seed_column_quoted_csv", + "macro.dbt.get_binding_char" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.303833, + "supported_languages": null + }, + "macro.dbt.generate_alias_name": { + "unique_id": "macro.dbt.generate_alias_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_alias.sql", + "original_file_path": "macros/get_custom_name/get_custom_alias.sql", + "name": "generate_alias_name", + "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__generate_alias_name"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3042402, + "supported_languages": null + }, + "macro.dbt.default__generate_alias_name": { + "unique_id": "macro.dbt.default__generate_alias_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_alias.sql", + "original_file_path": "macros/get_custom_name/get_custom_alias.sql", + "name": "default__generate_alias_name", + "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name is none -%}\n\n {{ node.name }}\n\n {%- else -%}\n\n {{ custom_alias_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3044422, + "supported_languages": null + }, + "macro.dbt.generate_schema_name": { + "unique_id": "macro.dbt.generate_schema_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "name": "generate_schema_name", + "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__generate_schema_name"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.304976, + "supported_languages": null + }, + "macro.dbt.default__generate_schema_name": { + "unique_id": "macro.dbt.default__generate_schema_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "name": "default__generate_schema_name", + "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.305205, + "supported_languages": null + }, + "macro.dbt.generate_schema_name_for_env": { + "unique_id": "macro.dbt.generate_schema_name_for_env", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "name": "generate_schema_name_for_env", + "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.305465, + "supported_languages": null + }, + "macro.dbt.generate_database_name": { + "unique_id": "macro.dbt.generate_database_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_database.sql", + "original_file_path": "macros/get_custom_name/get_custom_database.sql", + "name": "generate_database_name", + "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__generate_database_name"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.305872, + "supported_languages": null + }, + "macro.dbt.default__generate_database_name": { + "unique_id": "macro.dbt.default__generate_database_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/get_custom_name/get_custom_database.sql", + "original_file_path": "macros/get_custom_name/get_custom_database.sql", + "name": "default__generate_database_name", + "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3060942, + "supported_languages": null + }, + "macro.dbt.default__test_relationships": { + "unique_id": "macro.dbt.default__test_relationships", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/generic_test_sql/relationships.sql", + "original_file_path": "macros/generic_test_sql/relationships.sql", + "name": "default__test_relationships", + "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.306464, + "supported_languages": null + }, + "macro.dbt.default__test_not_null": { + "unique_id": "macro.dbt.default__test_not_null", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/generic_test_sql/not_null.sql", + "original_file_path": "macros/generic_test_sql/not_null.sql", + "name": "default__test_not_null", + "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.should_store_failures"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3067882, + "supported_languages": null + }, + "macro.dbt.default__test_unique": { + "unique_id": "macro.dbt.default__test_unique", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/generic_test_sql/unique.sql", + "original_file_path": "macros/generic_test_sql/unique.sql", + "name": "default__test_unique", + "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.307063, + "supported_languages": null + }, + "macro.dbt.default__test_accepted_values": { + "unique_id": "macro.dbt.default__test_accepted_values", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/generic_test_sql/accepted_values.sql", + "original_file_path": "macros/generic_test_sql/accepted_values.sql", + "name": "default__test_accepted_values", + "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.307619, + "supported_languages": null + }, + "macro.dbt.statement": { + "unique_id": "macro.dbt.statement", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "name": "statement", + "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.308962, + "supported_languages": null + }, + "macro.dbt.noop_statement": { + "unique_id": "macro.dbt.noop_statement", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "name": "noop_statement", + "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.309532, + "supported_languages": null + }, + "macro.dbt.run_query": { + "unique_id": "macro.dbt.run_query", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "name": "run_query", + "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3097951, + "supported_languages": null + }, + "macro.dbt.convert_datetime": { + "unique_id": "macro.dbt.convert_datetime", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "name": "convert_datetime", + "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.311424, + "supported_languages": null + }, + "macro.dbt.dates_in_range": { + "unique_id": "macro.dbt.dates_in_range", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "name": "dates_in_range", + "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partiton start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.convert_datetime"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3124712, + "supported_languages": null + }, + "macro.dbt.partition_range": { + "unique_id": "macro.dbt.partition_range", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "name": "partition_range", + "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.dates_in_range"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.313131, + "supported_languages": null + }, + "macro.dbt.py_current_timestring": { + "unique_id": "macro.dbt.py_current_timestring", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "name": "py_current_timestring", + "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.313341, + "supported_languages": null + }, + "macro.dbt.except": { + "unique_id": "macro.dbt.except", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/except.sql", + "original_file_path": "macros/utils/except.sql", + "name": "except", + "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__except"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.313611, + "supported_languages": null + }, + "macro.dbt.default__except": { + "unique_id": "macro.dbt.default__except", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/except.sql", + "original_file_path": "macros/utils/except.sql", + "name": "default__except", + "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.313676, + "supported_languages": null + }, + "macro.dbt.replace": { + "unique_id": "macro.dbt.replace", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/replace.sql", + "original_file_path": "macros/utils/replace.sql", + "name": "replace", + "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__replace"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3140259, + "supported_languages": null + }, + "macro.dbt.default__replace": { + "unique_id": "macro.dbt.default__replace", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/replace.sql", + "original_file_path": "macros/utils/replace.sql", + "name": "default__replace", + "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.314168, + "supported_languages": null + }, + "macro.dbt.concat": { + "unique_id": "macro.dbt.concat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/concat.sql", + "original_file_path": "macros/utils/concat.sql", + "name": "concat", + "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__concat"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3144681, + "supported_languages": null + }, + "macro.dbt.default__concat": { + "unique_id": "macro.dbt.default__concat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/concat.sql", + "original_file_path": "macros/utils/concat.sql", + "name": "default__concat", + "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3145878, + "supported_languages": null + }, + "macro.dbt.length": { + "unique_id": "macro.dbt.length", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/length.sql", + "original_file_path": "macros/utils/length.sql", + "name": "length", + "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__length"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.314872, + "supported_languages": null + }, + "macro.dbt.default__length": { + "unique_id": "macro.dbt.default__length", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/length.sql", + "original_file_path": "macros/utils/length.sql", + "name": "default__length", + "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.314971, + "supported_languages": null + }, + "macro.dbt.dateadd": { + "unique_id": "macro.dbt.dateadd", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/dateadd.sql", + "original_file_path": "macros/utils/dateadd.sql", + "name": "dateadd", + "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__dateadd"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.315331, + "supported_languages": null + }, + "macro.dbt.default__dateadd": { + "unique_id": "macro.dbt.default__dateadd", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/dateadd.sql", + "original_file_path": "macros/utils/dateadd.sql", + "name": "default__dateadd", + "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.315477, + "supported_languages": null + }, + "macro.dbt.intersect": { + "unique_id": "macro.dbt.intersect", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/intersect.sql", + "original_file_path": "macros/utils/intersect.sql", + "name": "intersect", + "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__intersect"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.315735, + "supported_languages": null + }, + "macro.dbt.default__intersect": { + "unique_id": "macro.dbt.default__intersect", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/intersect.sql", + "original_file_path": "macros/utils/intersect.sql", + "name": "default__intersect", + "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.315805, + "supported_languages": null + }, + "macro.dbt.escape_single_quotes": { + "unique_id": "macro.dbt.escape_single_quotes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "name": "escape_single_quotes", + "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.316094, + "supported_languages": null + }, + "macro.dbt.default__escape_single_quotes": { + "unique_id": "macro.dbt.default__escape_single_quotes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "name": "default__escape_single_quotes", + "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.316221, + "supported_languages": null + }, + "macro.dbt.right": { + "unique_id": "macro.dbt.right", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "name": "right", + "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_snowflake.snowflake__right"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.316531, + "supported_languages": null + }, + "macro.dbt.default__right": { + "unique_id": "macro.dbt.default__right", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "name": "default__right", + "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3167129, + "supported_languages": null + }, + "macro.dbt.listagg": { + "unique_id": "macro.dbt.listagg", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/listagg.sql", + "original_file_path": "macros/utils/listagg.sql", + "name": "listagg", + "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__listagg"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.317313, + "supported_languages": null + }, + "macro.dbt.default__listagg": { + "unique_id": "macro.dbt.default__listagg", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/listagg.sql", + "original_file_path": "macros/utils/listagg.sql", + "name": "default__listagg", + "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3176708, + "supported_languages": null + }, + "macro.dbt.datediff": { + "unique_id": "macro.dbt.datediff", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/datediff.sql", + "original_file_path": "macros/utils/datediff.sql", + "name": "datediff", + "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__datediff"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3180218, + "supported_languages": null + }, + "macro.dbt.default__datediff": { + "unique_id": "macro.dbt.default__datediff", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/datediff.sql", + "original_file_path": "macros/utils/datediff.sql", + "name": "default__datediff", + "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3181682, + "supported_languages": null + }, + "macro.dbt.safe_cast": { + "unique_id": "macro.dbt.safe_cast", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "name": "safe_cast", + "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_snowflake.snowflake__safe_cast"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.318481, + "supported_languages": null + }, + "macro.dbt.default__safe_cast": { + "unique_id": "macro.dbt.default__safe_cast", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "name": "default__safe_cast", + "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.318604, + "supported_languages": null + }, + "macro.dbt.hash": { + "unique_id": "macro.dbt.hash", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/hash.sql", + "original_file_path": "macros/utils/hash.sql", + "name": "hash", + "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__hash"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.318888, + "supported_languages": null + }, + "macro.dbt.default__hash": { + "unique_id": "macro.dbt.default__hash", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/hash.sql", + "original_file_path": "macros/utils/hash.sql", + "name": "default__hash", + "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.319027, + "supported_languages": null + }, + "macro.dbt.cast_bool_to_text": { + "unique_id": "macro.dbt.cast_bool_to_text", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/cast_bool_to_text.sql", + "original_file_path": "macros/utils/cast_bool_to_text.sql", + "name": "cast_bool_to_text", + "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__cast_bool_to_text"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3193002, + "supported_languages": null + }, + "macro.dbt.default__cast_bool_to_text": { + "unique_id": "macro.dbt.default__cast_bool_to_text", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/cast_bool_to_text.sql", + "original_file_path": "macros/utils/cast_bool_to_text.sql", + "name": "default__cast_bool_to_text", + "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.319437, + "supported_languages": null + }, + "macro.dbt.any_value": { + "unique_id": "macro.dbt.any_value", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/any_value.sql", + "original_file_path": "macros/utils/any_value.sql", + "name": "any_value", + "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__any_value"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.319712, + "supported_languages": null + }, + "macro.dbt.default__any_value": { + "unique_id": "macro.dbt.default__any_value", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/any_value.sql", + "original_file_path": "macros/utils/any_value.sql", + "name": "default__any_value", + "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.319805, + "supported_languages": null + }, + "macro.dbt.position": { + "unique_id": "macro.dbt.position", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/position.sql", + "original_file_path": "macros/utils/position.sql", + "name": "position", + "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__position"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.320113, + "supported_languages": null + }, + "macro.dbt.default__position": { + "unique_id": "macro.dbt.default__position", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/position.sql", + "original_file_path": "macros/utils/position.sql", + "name": "default__position", + "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.320232, + "supported_languages": null + }, + "macro.dbt.string_literal": { + "unique_id": "macro.dbt.string_literal", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/literal.sql", + "original_file_path": "macros/utils/literal.sql", + "name": "string_literal", + "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__string_literal"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.320504, + "supported_languages": null + }, + "macro.dbt.default__string_literal": { + "unique_id": "macro.dbt.default__string_literal", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/literal.sql", + "original_file_path": "macros/utils/literal.sql", + "name": "default__string_literal", + "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3205929, + "supported_languages": null + }, + "macro.dbt.type_string": { + "unique_id": "macro.dbt.type_string", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_string", + "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_string"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3214772, + "supported_languages": null + }, + "macro.dbt.default__type_string": { + "unique_id": "macro.dbt.default__type_string", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_string", + "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.321621, + "supported_languages": null + }, + "macro.dbt.type_timestamp": { + "unique_id": "macro.dbt.type_timestamp", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_timestamp", + "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3219469, + "supported_languages": null + }, + "macro.dbt.default__type_timestamp": { + "unique_id": "macro.dbt.default__type_timestamp", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_timestamp", + "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3220859, + "supported_languages": null + }, + "macro.dbt.type_float": { + "unique_id": "macro.dbt.type_float", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_float", + "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_float"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.32223, + "supported_languages": null + }, + "macro.dbt.default__type_float": { + "unique_id": "macro.dbt.default__type_float", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_float", + "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.322361, + "supported_languages": null + }, + "macro.dbt.type_numeric": { + "unique_id": "macro.dbt.type_numeric", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_numeric", + "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_numeric"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3225012, + "supported_languages": null + }, + "macro.dbt.default__type_numeric": { + "unique_id": "macro.dbt.default__type_numeric", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_numeric", + "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.322656, + "supported_languages": null + }, + "macro.dbt.type_bigint": { + "unique_id": "macro.dbt.type_bigint", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_bigint", + "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_bigint"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.322795, + "supported_languages": null + }, + "macro.dbt.default__type_bigint": { + "unique_id": "macro.dbt.default__type_bigint", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_bigint", + "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.322929, + "supported_languages": null + }, + "macro.dbt.type_int": { + "unique_id": "macro.dbt.type_int", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_int", + "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_int"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.323072, + "supported_languages": null + }, + "macro.dbt.default__type_int": { + "unique_id": "macro.dbt.default__type_int", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_int", + "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.323201, + "supported_languages": null + }, + "macro.dbt.type_boolean": { + "unique_id": "macro.dbt.type_boolean", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "type_boolean", + "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__type_boolean"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3233411, + "supported_languages": null + }, + "macro.dbt.default__type_boolean": { + "unique_id": "macro.dbt.default__type_boolean", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "name": "default__type_boolean", + "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.323467, + "supported_languages": null + }, + "macro.dbt.array_concat": { + "unique_id": "macro.dbt.array_concat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_concat.sql", + "original_file_path": "macros/utils/array_concat.sql", + "name": "array_concat", + "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__array_concat"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.323775, + "supported_languages": null + }, + "macro.dbt.default__array_concat": { + "unique_id": "macro.dbt.default__array_concat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_concat.sql", + "original_file_path": "macros/utils/array_concat.sql", + "name": "default__array_concat", + "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.323894, + "supported_languages": null + }, + "macro.dbt.bool_or": { + "unique_id": "macro.dbt.bool_or", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "name": "bool_or", + "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_snowflake.snowflake__bool_or"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.324169, + "supported_languages": null + }, + "macro.dbt.default__bool_or": { + "unique_id": "macro.dbt.default__bool_or", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "name": "default__bool_or", + "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.324259, + "supported_languages": null + }, + "macro.dbt.last_day": { + "unique_id": "macro.dbt.last_day", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "name": "last_day", + "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__last_day"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3246138, + "supported_languages": null + }, + "macro.dbt.default_last_day": { + "unique_id": "macro.dbt.default_last_day", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "name": "default_last_day", + "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3248482, + "supported_languages": null + }, + "macro.dbt.default__last_day": { + "unique_id": "macro.dbt.default__last_day", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "name": "default__last_day", + "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default_last_day"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3249779, + "supported_languages": null + }, + "macro.dbt.split_part": { + "unique_id": "macro.dbt.split_part", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "name": "split_part", + "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__split_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3254988, + "supported_languages": null + }, + "macro.dbt.default__split_part": { + "unique_id": "macro.dbt.default__split_part", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "name": "default__split_part", + "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.325707, + "supported_languages": null + }, + "macro.dbt._split_part_negative": { + "unique_id": "macro.dbt._split_part_negative", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "name": "_split_part_negative", + "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 {{ part_number }}\n )\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3259032, + "supported_languages": null + }, + "macro.dbt.date_trunc": { + "unique_id": "macro.dbt.date_trunc", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/date_trunc.sql", + "original_file_path": "macros/utils/date_trunc.sql", + "name": "date_trunc", + "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__date_trunc"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3262022, + "supported_languages": null + }, + "macro.dbt.default__date_trunc": { + "unique_id": "macro.dbt.default__date_trunc", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/date_trunc.sql", + "original_file_path": "macros/utils/date_trunc.sql", + "name": "default__date_trunc", + "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.326317, + "supported_languages": null + }, + "macro.dbt.array_construct": { + "unique_id": "macro.dbt.array_construct", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "name": "array_construct", + "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__array_construct"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.326705, + "supported_languages": null + }, + "macro.dbt.default__array_construct": { + "unique_id": "macro.dbt.default__array_construct", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "name": "default__array_construct", + "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.32692, + "supported_languages": null + }, + "macro.dbt.array_append": { + "unique_id": "macro.dbt.array_append", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_append.sql", + "original_file_path": "macros/utils/array_append.sql", + "name": "array_append", + "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__array_append"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3272269, + "supported_languages": null + }, + "macro.dbt.default__array_append": { + "unique_id": "macro.dbt.default__array_append", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/utils/array_append.sql", + "original_file_path": "macros/utils/array_append.sql", + "name": "default__array_append", + "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.327345, + "supported_languages": null + }, + "macro.dbt.create_schema": { + "unique_id": "macro.dbt.create_schema", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "name": "create_schema", + "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__create_schema"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.327728, + "supported_languages": null + }, + "macro.dbt.default__create_schema": { + "unique_id": "macro.dbt.default__create_schema", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "name": "default__create_schema", + "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.327889, + "supported_languages": null + }, + "macro.dbt.drop_schema": { + "unique_id": "macro.dbt.drop_schema", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "name": "drop_schema", + "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__drop_schema"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.328033, + "supported_languages": null + }, + "macro.dbt.default__drop_schema": { + "unique_id": "macro.dbt.default__drop_schema", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "name": "default__drop_schema", + "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.328195, + "supported_languages": null + }, + "macro.dbt.current_timestamp": { + "unique_id": "macro.dbt.current_timestamp", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "current_timestamp", + "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__current_timestamp"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.32868, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp": { + "unique_id": "macro.dbt.default__current_timestamp", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "default__current_timestamp", + "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.328811, + "supported_languages": null + }, + "macro.dbt.snapshot_get_time": { + "unique_id": "macro.dbt.snapshot_get_time", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "snapshot_get_time", + "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3289359, + "supported_languages": null + }, + "macro.dbt.default__snapshot_get_time": { + "unique_id": "macro.dbt.default__snapshot_get_time", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "default__snapshot_get_time", + "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.current_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.329029, + "supported_languages": null + }, + "macro.dbt.current_timestamp_backcompat": { + "unique_id": "macro.dbt.current_timestamp_backcompat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "current_timestamp_backcompat", + "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.329176, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp_backcompat": { + "unique_id": "macro.dbt.default__current_timestamp_backcompat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "default__current_timestamp_backcompat", + "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3292422, + "supported_languages": null + }, + "macro.dbt.current_timestamp_in_utc_backcompat": { + "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.329389, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp_in_utc_backcompat": { + "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "name": "default__current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.current_timestamp_backcompat", + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.329537, + "supported_languages": null + }, + "macro.dbt.get_create_index_sql": { + "unique_id": "macro.dbt.get_create_index_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "name": "get_create_index_sql", + "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_create_index_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.330055, + "supported_languages": null + }, + "macro.dbt.default__get_create_index_sql": { + "unique_id": "macro.dbt.default__get_create_index_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "name": "default__get_create_index_sql", + "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.330178, + "supported_languages": null + }, + "macro.dbt.create_indexes": { + "unique_id": "macro.dbt.create_indexes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "name": "create_indexes", + "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__create_indexes"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.330335, + "supported_languages": null + }, + "macro.dbt.default__create_indexes": { + "unique_id": "macro.dbt.default__create_indexes", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "name": "default__create_indexes", + "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3307, + "supported_languages": null + }, + "macro.dbt.make_intermediate_relation": { + "unique_id": "macro.dbt.make_intermediate_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "make_intermediate_relation", + "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__make_intermediate_relation"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.333606, + "supported_languages": null + }, + "macro.dbt.default__make_intermediate_relation": { + "unique_id": "macro.dbt.default__make_intermediate_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__make_intermediate_relation", + "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__make_temp_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.333757, + "supported_languages": null + }, + "macro.dbt.make_temp_relation": { + "unique_id": "macro.dbt.make_temp_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "make_temp_relation", + "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__make_temp_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.333951, + "supported_languages": null + }, + "macro.dbt.default__make_temp_relation": { + "unique_id": "macro.dbt.default__make_temp_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__make_temp_relation", + "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.334209, + "supported_languages": null + }, + "macro.dbt.make_backup_relation": { + "unique_id": "macro.dbt.make_backup_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "make_backup_relation", + "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__make_backup_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3344278, + "supported_languages": null + }, + "macro.dbt.default__make_backup_relation": { + "unique_id": "macro.dbt.default__make_backup_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__make_backup_relation", + "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.334712, + "supported_languages": null + }, + "macro.dbt.drop_relation": { + "unique_id": "macro.dbt.drop_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "drop_relation", + "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__drop_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3348742, + "supported_languages": null + }, + "macro.dbt.default__drop_relation": { + "unique_id": "macro.dbt.default__drop_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__drop_relation", + "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n {%- endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3350642, + "supported_languages": null + }, + "macro.dbt.truncate_relation": { + "unique_id": "macro.dbt.truncate_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "truncate_relation", + "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__truncate_relation"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.335223, + "supported_languages": null + }, + "macro.dbt.default__truncate_relation": { + "unique_id": "macro.dbt.default__truncate_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__truncate_relation", + "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.335365, + "supported_languages": null + }, + "macro.dbt.rename_relation": { + "unique_id": "macro.dbt.rename_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "rename_relation", + "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__rename_relation"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.335542, + "supported_languages": null + }, + "macro.dbt.default__rename_relation": { + "unique_id": "macro.dbt.default__rename_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__rename_relation", + "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.335792, + "supported_languages": null + }, + "macro.dbt.get_or_create_relation": { + "unique_id": "macro.dbt.get_or_create_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "get_or_create_relation", + "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_or_create_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.336011, + "supported_languages": null + }, + "macro.dbt.default__get_or_create_relation": { + "unique_id": "macro.dbt.default__get_or_create_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "default__get_or_create_relation", + "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.336562, + "supported_languages": null + }, + "macro.dbt.load_cached_relation": { + "unique_id": "macro.dbt.load_cached_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "load_cached_relation", + "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3367648, + "supported_languages": null + }, + "macro.dbt.load_relation": { + "unique_id": "macro.dbt.load_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "load_relation", + "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.load_cached_relation"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.336889, + "supported_languages": null + }, + "macro.dbt.drop_relation_if_exists": { + "unique_id": "macro.dbt.drop_relation_if_exists", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "name": "drop_relation_if_exists", + "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.337059, + "supported_languages": null + }, + "macro.dbt.collect_freshness": { + "unique_id": "macro.dbt.collect_freshness", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/freshness.sql", + "original_file_path": "macros/adapters/freshness.sql", + "name": "collect_freshness", + "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__collect_freshness"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.337497, + "supported_languages": null + }, + "macro.dbt.default__collect_freshness": { + "unique_id": "macro.dbt.default__collect_freshness", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/freshness.sql", + "original_file_path": "macros/adapters/freshness.sql", + "name": "default__collect_freshness", + "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness').table) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3378649, + "supported_languages": null + }, + "macro.dbt.copy_grants": { + "unique_id": "macro.dbt.copy_grants", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "copy_grants", + "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__copy_grants"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.339423, + "supported_languages": null + }, + "macro.dbt.default__copy_grants": { + "unique_id": "macro.dbt.default__copy_grants", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__copy_grants", + "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.339523, + "supported_languages": null + }, + "macro.dbt.support_multiple_grantees_per_dcl_statement": { + "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "support_multiple_grantees_per_dcl_statement", + "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3396711, + "supported_languages": null + }, + "macro.dbt.default__support_multiple_grantees_per_dcl_statement": { + "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__support_multiple_grantees_per_dcl_statement", + "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.339766, + "supported_languages": null + }, + "macro.dbt.should_revoke": { + "unique_id": "macro.dbt.should_revoke", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "should_revoke", + "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.copy_grants"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.340068, + "supported_languages": null + }, + "macro.dbt.get_show_grant_sql": { + "unique_id": "macro.dbt.get_show_grant_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "get_show_grant_sql", + "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_show_grant_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.340231, + "supported_languages": null + }, + "macro.dbt.default__get_show_grant_sql": { + "unique_id": "macro.dbt.default__get_show_grant_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__get_show_grant_sql", + "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.340322, + "supported_languages": null + }, + "macro.dbt.get_grant_sql": { + "unique_id": "macro.dbt.get_grant_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "get_grant_sql", + "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_grant_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.34052, + "supported_languages": null + }, + "macro.dbt.default__get_grant_sql": { + "unique_id": "macro.dbt.default__get_grant_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__get_grant_sql", + "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.340683, + "supported_languages": null + }, + "macro.dbt.get_revoke_sql": { + "unique_id": "macro.dbt.get_revoke_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "get_revoke_sql", + "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_revoke_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.340886, + "supported_languages": null + }, + "macro.dbt.default__get_revoke_sql": { + "unique_id": "macro.dbt.default__get_revoke_sql", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__get_revoke_sql", + "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.341053, + "supported_languages": null + }, + "macro.dbt.get_dcl_statement_list": { + "unique_id": "macro.dbt.get_dcl_statement_list", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "get_dcl_statement_list", + "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_dcl_statement_list"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.341252, + "supported_languages": null + }, + "macro.dbt.default__get_dcl_statement_list": { + "unique_id": "macro.dbt.default__get_dcl_statement_list", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__get_dcl_statement_list", + "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.341851, + "supported_languages": null + }, + "macro.dbt.call_dcl_statements": { + "unique_id": "macro.dbt.call_dcl_statements", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "call_dcl_statements", + "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__call_dcl_statements"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3420851, + "supported_languages": null + }, + "macro.dbt.default__call_dcl_statements": { + "unique_id": "macro.dbt.default__call_dcl_statements", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__call_dcl_statements", + "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.34231, + "supported_languages": null + }, + "macro.dbt.apply_grants": { + "unique_id": "macro.dbt.apply_grants", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "apply_grants", + "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__apply_grants"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.342517, + "supported_languages": null + }, + "macro.dbt.default__apply_grants": { + "unique_id": "macro.dbt.default__apply_grants", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "name": "default__apply_grants", + "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.run_query", + "macro.dbt.get_show_grant_sql", + "macro.dbt.get_dcl_statement_list", + "macro.dbt.call_dcl_statements" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3436038, + "supported_languages": null + }, + "macro.dbt.alter_column_comment": { + "unique_id": "macro.dbt.alter_column_comment", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "alter_column_comment", + "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.34432, + "supported_languages": null + }, + "macro.dbt.default__alter_column_comment": { + "unique_id": "macro.dbt.default__alter_column_comment", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "default__alter_column_comment", + "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.344482, + "supported_languages": null + }, + "macro.dbt.alter_relation_comment": { + "unique_id": "macro.dbt.alter_relation_comment", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "alter_relation_comment", + "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3446841, + "supported_languages": null + }, + "macro.dbt.default__alter_relation_comment": { + "unique_id": "macro.dbt.default__alter_relation_comment", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "default__alter_relation_comment", + "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.344852, + "supported_languages": null + }, + "macro.dbt.persist_docs": { + "unique_id": "macro.dbt.persist_docs", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "persist_docs", + "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__persist_docs"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.345095, + "supported_languages": null + }, + "macro.dbt.default__persist_docs": { + "unique_id": "macro.dbt.default__persist_docs", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "name": "default__persist_docs", + "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.run_query", + "macro.dbt.alter_relation_comment", + "macro.dbt.alter_column_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.345526, + "supported_languages": null + }, + "macro.dbt.get_catalog": { + "unique_id": "macro.dbt.get_catalog", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "get_catalog", + "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__get_catalog"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.346912, + "supported_languages": null + }, + "macro.dbt.default__get_catalog": { + "unique_id": "macro.dbt.default__get_catalog", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "default__get_catalog", + "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3471448, + "supported_languages": null + }, + "macro.dbt.information_schema_name": { + "unique_id": "macro.dbt.information_schema_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "information_schema_name", + "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.default__information_schema_name"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.347313, + "supported_languages": null + }, + "macro.dbt.default__information_schema_name": { + "unique_id": "macro.dbt.default__information_schema_name", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "default__information_schema_name", + "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.347449, + "supported_languages": null + }, + "macro.dbt.list_schemas": { + "unique_id": "macro.dbt.list_schemas", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "list_schemas", + "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__list_schemas"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.347611, + "supported_languages": null + }, + "macro.dbt.default__list_schemas": { + "unique_id": "macro.dbt.default__list_schemas", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "default__list_schemas", + "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.347832, + "supported_languages": null + }, + "macro.dbt.check_schema_exists": { + "unique_id": "macro.dbt.check_schema_exists", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "check_schema_exists", + "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.348022, + "supported_languages": null + }, + "macro.dbt.default__check_schema_exists": { + "unique_id": "macro.dbt.default__check_schema_exists", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "default__check_schema_exists", + "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.replace", "macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.348295, + "supported_languages": null + }, + "macro.dbt.list_relations_without_caching": { + "unique_id": "macro.dbt.list_relations_without_caching", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "list_relations_without_caching", + "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__list_relations_without_caching" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.348462, + "supported_languages": null + }, + "macro.dbt.default__list_relations_without_caching": { + "unique_id": "macro.dbt.default__list_relations_without_caching", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "name": "default__list_relations_without_caching", + "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.348605, + "supported_languages": null + }, + "macro.dbt.get_columns_in_relation": { + "unique_id": "macro.dbt.get_columns_in_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "get_columns_in_relation", + "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.350165, + "supported_languages": null + }, + "macro.dbt.default__get_columns_in_relation": { + "unique_id": "macro.dbt.default__get_columns_in_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "default__get_columns_in_relation", + "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.350376, + "supported_languages": null + }, + "macro.dbt.sql_convert_columns_in_relation": { + "unique_id": "macro.dbt.sql_convert_columns_in_relation", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "sql_convert_columns_in_relation", + "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.350655, + "supported_languages": null + }, + "macro.dbt.get_columns_in_query": { + "unique_id": "macro.dbt.get_columns_in_query", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "get_columns_in_query", + "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__get_columns_in_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3508239, + "supported_languages": null + }, + "macro.dbt.default__get_columns_in_query": { + "unique_id": "macro.dbt.default__get_columns_in_query", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "default__get_columns_in_query", + "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.351125, + "supported_languages": null + }, + "macro.dbt.alter_column_type": { + "unique_id": "macro.dbt.alter_column_type", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "alter_column_type", + "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_snowflake.snowflake__alter_column_type"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.351331, + "supported_languages": null + }, + "macro.dbt.default__alter_column_type": { + "unique_id": "macro.dbt.default__alter_column_type", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "default__alter_column_type", + "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.351871, + "supported_languages": null + }, + "macro.dbt.alter_relation_add_remove_columns": { + "unique_id": "macro.dbt.alter_relation_add_remove_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "alter_relation_add_remove_columns", + "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.352103, + "supported_languages": null + }, + "macro.dbt.default__alter_relation_add_remove_columns": { + "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "name": "default__alter_relation_add_remove_columns", + "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3528051, + "supported_languages": null + }, + "macro.dbt.build_ref_function": { + "unique_id": "macro.dbt.build_ref_function", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "name": "build_ref_function", + "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {%- set resolved = ref(*_ref) -%}\n {%- do ref_dict.update({_ref | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef ref(*args,dbt_load_df_function):\n refs = {{ ref_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.354187, + "supported_languages": null + }, + "macro.dbt.build_source_function": { + "unique_id": "macro.dbt.build_source_function", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "name": "build_source_function", + "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.354607, + "supported_languages": null + }, + "macro.dbt.build_config_dict": { + "unique_id": "macro.dbt.build_config_dict", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "name": "build_config_dict", + "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {%- for key in model.config.config_keys_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == 'language' -%}\n {%- set value = 'python' -%}\n {%- endif -%}\n {%- set value = model.config[key] -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.355018, + "supported_languages": null + }, + "macro.dbt.py_script_postfix": { + "unique_id": "macro.dbt.py_script_postfix", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "name": "py_script_postfix", + "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = '{{ this.database }}'\n schema = '{{ this.schema }}'\n identifier = '{{ this.identifier }}'\n def __repr__(self):\n return '{{ this }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args: ref(*args, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.build_ref_function", + "macro.dbt.build_source_function", + "macro.dbt.build_config_dict", + "macro.dbt.is_incremental", + "macro.dbt.py_script_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.355385, + "supported_languages": null + }, + "macro.dbt.py_script_comment": { + "unique_id": "macro.dbt.py_script_comment", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "name": "py_script_comment", + "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3554492, + "supported_languages": null + }, + "macro.dbt.test_unique": { + "unique_id": "macro.dbt.test_unique", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "name": "test_unique", + "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__test_unique"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.355972, + "supported_languages": null + }, + "macro.dbt.test_not_null": { + "unique_id": "macro.dbt.test_not_null", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "name": "test_not_null", + "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__test_not_null"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.356176, + "supported_languages": null + }, + "macro.dbt.test_accepted_values": { + "unique_id": "macro.dbt.test_accepted_values", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "name": "test_accepted_values", + "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__test_accepted_values"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.35643, + "supported_languages": null + }, + "macro.dbt.test_relationships": { + "unique_id": "macro.dbt.test_relationships", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "name": "test_relationships", + "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.default__test_relationships"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3566778, + "supported_languages": null + }, + "macro.dbt_utils.get_url_host": { + "unique_id": "macro.dbt_utils.get_url_host", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_host.sql", + "original_file_path": "macros/web/get_url_host.sql", + "name": "get_url_host", + "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__get_url_host"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.357051, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_host": { + "unique_id": "macro.dbt_utils.default__get_url_host", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_host.sql", + "original_file_path": "macros/web/get_url_host.sql", + "name": "default__get_url_host", + "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.split_part", + "macro.dbt.replace", + "macro.dbt.safe_cast", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.357544, + "supported_languages": null + }, + "macro.dbt_utils.get_url_path": { + "unique_id": "macro.dbt_utils.get_url_path", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_path.sql", + "original_file_path": "macros/web/get_url_path.sql", + "name": "get_url_path", + "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__get_url_path"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.358022, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_path": { + "unique_id": "macro.dbt_utils.default__get_url_path", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_path.sql", + "original_file_path": "macros/web/get_url_path.sql", + "name": "default__get_url_path", + "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.replace", + "macro.dbt.position", + "macro.dbt.split_part", + "macro.dbt.right", + "macro.dbt.length", + "macro.dbt.safe_cast", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.358612, + "supported_languages": null + }, + "macro.dbt_utils.get_url_parameter": { + "unique_id": "macro.dbt_utils.get_url_parameter", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_parameter.sql", + "original_file_path": "macros/web/get_url_parameter.sql", + "name": "get_url_parameter", + "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_url_parameter"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.358957, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_parameter": { + "unique_id": "macro.dbt_utils.default__get_url_parameter", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/web/get_url_parameter.sql", + "original_file_path": "macros/web/get_url_parameter.sql", + "name": "default__get_url_parameter", + "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.split_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3592489, + "supported_languages": null + }, + "macro.dbt_utils.test_fewer_rows_than": { + "unique_id": "macro.dbt_utils.test_fewer_rows_than", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/fewer_rows_than.sql", + "original_file_path": "macros/generic_tests/fewer_rows_than.sql", + "name": "test_fewer_rows_than", + "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_fewer_rows_than"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3602629, + "supported_languages": null + }, + "macro.dbt_utils.default__test_fewer_rows_than": { + "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/fewer_rows_than.sql", + "original_file_path": "macros/generic_tests/fewer_rows_than.sql", + "name": "default__test_fewer_rows_than", + "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.361165, + "supported_languages": null + }, + "macro.dbt_utils.test_equal_rowcount": { + "unique_id": "macro.dbt_utils.test_equal_rowcount", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/equal_rowcount.sql", + "original_file_path": "macros/generic_tests/equal_rowcount.sql", + "name": "test_equal_rowcount", + "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_equal_rowcount"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.361994, + "supported_languages": null + }, + "macro.dbt_utils.default__test_equal_rowcount": { + "unique_id": "macro.dbt_utils.default__test_equal_rowcount", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/equal_rowcount.sql", + "original_file_path": "macros/generic_tests/equal_rowcount.sql", + "name": "default__test_equal_rowcount", + "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3629498, + "supported_languages": null + }, + "macro.dbt_utils.test_relationships_where": { + "unique_id": "macro.dbt_utils.test_relationships_where", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/relationships_where.sql", + "original_file_path": "macros/generic_tests/relationships_where.sql", + "name": "test_relationships_where", + "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_relationships_where"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.363662, + "supported_languages": null + }, + "macro.dbt_utils.default__test_relationships_where": { + "unique_id": "macro.dbt_utils.default__test_relationships_where", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/relationships_where.sql", + "original_file_path": "macros/generic_tests/relationships_where.sql", + "name": "default__test_relationships_where", + "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3639638, + "supported_languages": null + }, + "macro.dbt_utils.test_recency": { + "unique_id": "macro.dbt_utils.test_recency", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/recency.sql", + "original_file_path": "macros/generic_tests/recency.sql", + "name": "test_recency", + "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__test_recency"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.364676, + "supported_languages": null + }, + "macro.dbt_utils.default__test_recency": { + "unique_id": "macro.dbt_utils.default__test_recency", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/recency.sql", + "original_file_path": "macros/generic_tests/recency.sql", + "name": "default__test_recency", + "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.dateadd", + "macro.dbt.current_timestamp", + "macro.dbt.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.36542, + "supported_languages": null + }, + "macro.dbt_utils.test_not_constant": { + "unique_id": "macro.dbt_utils.test_not_constant", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_constant.sql", + "original_file_path": "macros/generic_tests/not_constant.sql", + "name": "test_not_constant", + "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_not_constant"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3658838, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_constant": { + "unique_id": "macro.dbt_utils.default__test_not_constant", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_constant.sql", + "original_file_path": "macros/generic_tests/not_constant.sql", + "name": "default__test_not_constant", + "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.366295, + "supported_languages": null + }, + "macro.dbt_utils.test_accepted_range": { + "unique_id": "macro.dbt_utils.test_accepted_range", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/accepted_range.sql", + "original_file_path": "macros/generic_tests/accepted_range.sql", + "name": "test_accepted_range", + "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_accepted_range"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3669, + "supported_languages": null + }, + "macro.dbt_utils.default__test_accepted_range": { + "unique_id": "macro.dbt_utils.default__test_accepted_range", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/accepted_range.sql", + "original_file_path": "macros/generic_tests/accepted_range.sql", + "name": "default__test_accepted_range", + "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3673222, + "supported_languages": null + }, + "macro.dbt_utils.test_not_accepted_values": { + "unique_id": "macro.dbt_utils.test_not_accepted_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_accepted_values.sql", + "original_file_path": "macros/generic_tests/not_accepted_values.sql", + "name": "test_not_accepted_values", + "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_not_accepted_values"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.367862, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_accepted_values": { + "unique_id": "macro.dbt_utils.default__test_not_accepted_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_accepted_values.sql", + "original_file_path": "macros/generic_tests/not_accepted_values.sql", + "name": "default__test_not_accepted_values", + "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.368268, + "supported_languages": null + }, + "macro.dbt_utils.test_at_least_one": { + "unique_id": "macro.dbt_utils.test_at_least_one", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/at_least_one.sql", + "original_file_path": "macros/generic_tests/at_least_one.sql", + "name": "test_at_least_one", + "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_at_least_one"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.36875, + "supported_languages": null + }, + "macro.dbt_utils.default__test_at_least_one": { + "unique_id": "macro.dbt_utils.default__test_at_least_one", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/at_least_one.sql", + "original_file_path": "macros/generic_tests/at_least_one.sql", + "name": "default__test_at_least_one", + "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nselect *\nfrom (\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from {{ model }}\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3691819, + "supported_languages": null + }, + "macro.dbt_utils.test_unique_combination_of_columns": { + "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/unique_combination_of_columns.sql", + "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", + "name": "test_unique_combination_of_columns", + "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_unique_combination_of_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.369783, + "supported_languages": null + }, + "macro.dbt_utils.default__test_unique_combination_of_columns": { + "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/unique_combination_of_columns.sql", + "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", + "name": "default__test_unique_combination_of_columns", + "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.370355, + "supported_languages": null + }, + "macro.dbt_utils.test_cardinality_equality": { + "unique_id": "macro.dbt_utils.test_cardinality_equality", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/cardinality_equality.sql", + "original_file_path": "macros/generic_tests/cardinality_equality.sql", + "name": "test_cardinality_equality", + "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_cardinality_equality"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3709319, + "supported_languages": null + }, + "macro.dbt_utils.default__test_cardinality_equality": { + "unique_id": "macro.dbt_utils.default__test_cardinality_equality", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/cardinality_equality.sql", + "original_file_path": "macros/generic_tests/cardinality_equality.sql", + "name": "default__test_cardinality_equality", + "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.except"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3712482, + "supported_languages": null + }, + "macro.dbt_utils.test_expression_is_true": { + "unique_id": "macro.dbt_utils.test_expression_is_true", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/expression_is_true.sql", + "original_file_path": "macros/generic_tests/expression_is_true.sql", + "name": "test_expression_is_true", + "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_expression_is_true"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.371661, + "supported_languages": null + }, + "macro.dbt_utils.default__test_expression_is_true": { + "unique_id": "macro.dbt_utils.default__test_expression_is_true", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/expression_is_true.sql", + "original_file_path": "macros/generic_tests/expression_is_true.sql", + "name": "default__test_expression_is_true", + "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.should_store_failures"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3719811, + "supported_languages": null + }, + "macro.dbt_utils.test_not_null_proportion": { + "unique_id": "macro.dbt_utils.test_not_null_proportion", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_null_proportion.sql", + "original_file_path": "macros/generic_tests/not_null_proportion.sql", + "name": "test_not_null_proportion", + "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_not_null_proportion"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3726258, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_null_proportion": { + "unique_id": "macro.dbt_utils.default__test_not_null_proportion", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_null_proportion.sql", + "original_file_path": "macros/generic_tests/not_null_proportion.sql", + "name": "default__test_not_null_proportion", + "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.373369, + "supported_languages": null + }, + "macro.dbt_utils.test_sequential_values": { + "unique_id": "macro.dbt_utils.test_sequential_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/sequential_values.sql", + "original_file_path": "macros/generic_tests/sequential_values.sql", + "name": "test_sequential_values", + "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_sequential_values"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.374219, + "supported_languages": null + }, + "macro.dbt_utils.default__test_sequential_values": { + "unique_id": "macro.dbt_utils.default__test_sequential_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/sequential_values.sql", + "original_file_path": "macros/generic_tests/sequential_values.sql", + "name": "default__test_sequential_values", + "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils.slugify", + "macro.dbt.type_timestamp", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.375051, + "supported_languages": null + }, + "macro.dbt_utils.test_equality": { + "unique_id": "macro.dbt_utils.test_equality", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/equality.sql", + "original_file_path": "macros/generic_tests/equality.sql", + "name": "test_equality", + "macro_sql": "{% test equality(model, compare_model, compare_columns=None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__test_equality"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3757792, + "supported_languages": null + }, + "macro.dbt_utils.default__test_equality": { + "unique_id": "macro.dbt_utils.default__test_equality", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/equality.sql", + "original_file_path": "macros/generic_tests/equality.sql", + "name": "default__test_equality", + "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None) %}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.except" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3765771, + "supported_languages": null + }, + "macro.dbt_utils.test_not_empty_string": { + "unique_id": "macro.dbt_utils.test_not_empty_string", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_empty_string.sql", + "original_file_path": "macros/generic_tests/not_empty_string.sql", + "name": "test_not_empty_string", + "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_not_empty_string"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.377088, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_empty_string": { + "unique_id": "macro.dbt_utils.default__test_not_empty_string", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/not_empty_string.sql", + "original_file_path": "macros/generic_tests/not_empty_string.sql", + "name": "default__test_not_empty_string", + "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.377356, + "supported_languages": null + }, + "macro.dbt_utils.test_mutually_exclusive_ranges": { + "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "name": "test_mutually_exclusive_ranges", + "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.380419, + "supported_languages": null + }, + "macro.dbt_utils.default__test_mutually_exclusive_ranges": { + "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "name": "default__test_mutually_exclusive_ranges", + "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.381848, + "supported_languages": null + }, + "macro.dbt_utils.pretty_log_format": { + "unique_id": "macro.dbt_utils.pretty_log_format", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/pretty_log_format.sql", + "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", + "name": "pretty_log_format", + "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__pretty_log_format"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3821619, + "supported_languages": null + }, + "macro.dbt_utils.default__pretty_log_format": { + "unique_id": "macro.dbt_utils.default__pretty_log_format", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/pretty_log_format.sql", + "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", + "name": "default__pretty_log_format", + "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.pretty_time"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.382318, + "supported_languages": null + }, + "macro.dbt_utils._is_relation": { + "unique_id": "macro.dbt_utils._is_relation", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/_is_relation.sql", + "original_file_path": "macros/jinja_helpers/_is_relation.sql", + "name": "_is_relation", + "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3827689, + "supported_languages": null + }, + "macro.dbt_utils.pretty_time": { + "unique_id": "macro.dbt_utils.pretty_time", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/pretty_time.sql", + "original_file_path": "macros/jinja_helpers/pretty_time.sql", + "name": "pretty_time", + "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__pretty_time"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.383074, + "supported_languages": null + }, + "macro.dbt_utils.default__pretty_time": { + "unique_id": "macro.dbt_utils.default__pretty_time", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/pretty_time.sql", + "original_file_path": "macros/jinja_helpers/pretty_time.sql", + "name": "default__pretty_time", + "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.383252, + "supported_languages": null + }, + "macro.dbt_utils.log_info": { + "unique_id": "macro.dbt_utils.log_info", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/log_info.sql", + "original_file_path": "macros/jinja_helpers/log_info.sql", + "name": "log_info", + "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__log_info"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3835342, + "supported_languages": null + }, + "macro.dbt_utils.default__log_info": { + "unique_id": "macro.dbt_utils.default__log_info", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/log_info.sql", + "original_file_path": "macros/jinja_helpers/log_info.sql", + "name": "default__log_info", + "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.pretty_log_format"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3836899, + "supported_languages": null + }, + "macro.dbt_utils.slugify": { + "unique_id": "macro.dbt_utils.slugify", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/slugify.sql", + "original_file_path": "macros/jinja_helpers/slugify.sql", + "name": "slugify", + "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.384299, + "supported_languages": null + }, + "macro.dbt_utils._is_ephemeral": { + "unique_id": "macro.dbt_utils._is_ephemeral", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/jinja_helpers/_is_ephemeral.sql", + "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", + "name": "_is_ephemeral", + "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3850958, + "supported_languages": null + }, + "macro.dbt_utils.get_intervals_between": { + "unique_id": "macro.dbt_utils.get_intervals_between", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "name": "get_intervals_between", + "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_intervals_between"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.385773, + "supported_languages": null + }, + "macro.dbt_utils.default__get_intervals_between": { + "unique_id": "macro.dbt_utils.default__get_intervals_between", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "name": "default__get_intervals_between", + "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement", "macro.dbt.datediff"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3863091, + "supported_languages": null + }, + "macro.dbt_utils.date_spine": { + "unique_id": "macro.dbt_utils.date_spine", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "name": "date_spine", + "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__date_spine"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.386515, + "supported_languages": null + }, + "macro.dbt_utils.default__date_spine": { + "unique_id": "macro.dbt_utils.default__date_spine", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "name": "default__date_spine", + "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils.generate_series", + "macro.dbt_utils.get_intervals_between", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3868392, + "supported_languages": null + }, + "macro.dbt_utils.nullcheck_table": { + "unique_id": "macro.dbt_utils.nullcheck_table", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/nullcheck_table.sql", + "original_file_path": "macros/sql/nullcheck_table.sql", + "name": "nullcheck_table", + "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__nullcheck_table"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.387179, + "supported_languages": null + }, + "macro.dbt_utils.default__nullcheck_table": { + "unique_id": "macro.dbt_utils.default__nullcheck_table", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/nullcheck_table.sql", + "original_file_path": "macros/sql/nullcheck_table.sql", + "name": "default__nullcheck_table", + "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt_utils.nullcheck" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.387488, + "supported_languages": null + }, + "macro.dbt_utils.get_relations_by_pattern": { + "unique_id": "macro.dbt_utils.get_relations_by_pattern", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_relations_by_pattern.sql", + "original_file_path": "macros/sql/get_relations_by_pattern.sql", + "name": "get_relations_by_pattern", + "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_relations_by_pattern"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.388188, + "supported_languages": null + }, + "macro.dbt_utils.default__get_relations_by_pattern": { + "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_relations_by_pattern.sql", + "original_file_path": "macros/sql/get_relations_by_pattern.sql", + "name": "default__get_relations_by_pattern", + "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_utils.get_tables_by_pattern_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.389052, + "supported_languages": null + }, + "macro.dbt_utils.get_powers_of_two": { + "unique_id": "macro.dbt_utils.get_powers_of_two", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "name": "get_powers_of_two", + "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_powers_of_two"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.389877, + "supported_languages": null + }, + "macro.dbt_utils.default__get_powers_of_two": { + "unique_id": "macro.dbt_utils.default__get_powers_of_two", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "name": "default__get_powers_of_two", + "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3902452, + "supported_languages": null + }, + "macro.dbt_utils.generate_series": { + "unique_id": "macro.dbt_utils.generate_series", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "name": "generate_series", + "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__generate_series"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.390409, + "supported_languages": null + }, + "macro.dbt_utils.default__generate_series": { + "unique_id": "macro.dbt_utils.default__generate_series", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "name": "default__generate_series", + "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.get_powers_of_two"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.390869, + "supported_languages": null + }, + "macro.dbt_utils.get_relations_by_prefix": { + "unique_id": "macro.dbt_utils.get_relations_by_prefix", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_relations_by_prefix.sql", + "original_file_path": "macros/sql/get_relations_by_prefix.sql", + "name": "get_relations_by_prefix", + "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_relations_by_prefix"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.391517, + "supported_languages": null + }, + "macro.dbt_utils.default__get_relations_by_prefix": { + "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_relations_by_prefix.sql", + "original_file_path": "macros/sql/get_relations_by_prefix.sql", + "name": "default__get_relations_by_prefix", + "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_utils.get_tables_by_prefix_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3922718, + "supported_languages": null + }, + "macro.dbt_utils.get_tables_by_prefix_sql": { + "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_prefix_sql.sql", + "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", + "name": "get_tables_by_prefix_sql", + "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3927062, + "supported_languages": null + }, + "macro.dbt_utils.default__get_tables_by_prefix_sql": { + "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_prefix_sql.sql", + "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", + "name": "default__get_tables_by_prefix_sql", + "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.get_tables_by_pattern_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3929589, + "supported_languages": null + }, + "macro.dbt_utils.star": { + "unique_id": "macro.dbt_utils.star", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/star.sql", + "original_file_path": "macros/sql/star.sql", + "name": "star", + "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__star"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3940768, + "supported_languages": null + }, + "macro.dbt_utils.default__star": { + "unique_id": "macro.dbt_utils.default__star", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/star.sql", + "original_file_path": "macros/sql/star.sql", + "name": "default__star", + "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt_utils.get_filtered_columns_in_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.395324, + "supported_languages": null + }, + "macro.dbt_utils.unpivot": { + "unique_id": "macro.dbt_utils.unpivot", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/unpivot.sql", + "original_file_path": "macros/sql/unpivot.sql", + "name": "unpivot", + "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__unpivot"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3965352, + "supported_languages": null + }, + "macro.dbt_utils.default__unpivot": { + "unique_id": "macro.dbt_utils.default__unpivot", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/unpivot.sql", + "original_file_path": "macros/sql/unpivot.sql", + "name": "default__unpivot", + "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.type_string", + "macro.dbt.cast_bool_to_text" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.398005, + "supported_languages": null + }, + "macro.dbt_utils.safe_divide": { + "unique_id": "macro.dbt_utils.safe_divide", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/safe_divide.sql", + "original_file_path": "macros/sql/safe_divide.sql", + "name": "safe_divide", + "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__safe_divide"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.3983328, + "supported_languages": null + }, + "macro.dbt_utils.default__safe_divide": { + "unique_id": "macro.dbt_utils.default__safe_divide", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/safe_divide.sql", + "original_file_path": "macros/sql/safe_divide.sql", + "name": "default__safe_divide", + "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.398452, + "supported_languages": null + }, + "macro.dbt_utils.union_relations": { + "unique_id": "macro.dbt_utils.union_relations", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/union.sql", + "original_file_path": "macros/sql/union.sql", + "name": "union_relations", + "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__union_relations"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.401163, + "supported_languages": null + }, + "macro.dbt_utils.default__union_relations": { + "unique_id": "macro.dbt_utils.default__union_relations", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/union.sql", + "original_file_path": "macros/sql/union.sql", + "name": "default__union_relations", + "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.string_literal", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4042728, + "supported_languages": null + }, + "macro.dbt_utils.group_by": { + "unique_id": "macro.dbt_utils.group_by", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/groupby.sql", + "original_file_path": "macros/sql/groupby.sql", + "name": "group_by", + "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__group_by"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.404688, + "supported_languages": null + }, + "macro.dbt_utils.default__group_by": { + "unique_id": "macro.dbt_utils.default__group_by", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/groupby.sql", + "original_file_path": "macros/sql/groupby.sql", + "name": "default__group_by", + "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.404921, + "supported_languages": null + }, + "macro.dbt_utils.deduplicate": { + "unique_id": "macro.dbt_utils.deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "deduplicate", + "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.snowflake__deduplicate"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4057012, + "supported_languages": null + }, + "macro.dbt_utils.default__deduplicate": { + "unique_id": "macro.dbt_utils.default__deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "default__deduplicate", + "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.405914, + "supported_languages": null + }, + "macro.dbt_utils.redshift__deduplicate": { + "unique_id": "macro.dbt_utils.redshift__deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "redshift__deduplicate", + "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n {{ return(dbt_utils.default__deduplicate(relation, partition_by, order_by=order_by)) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__deduplicate"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.406091, + "supported_languages": null + }, + "macro.dbt_utils.postgres__deduplicate": { + "unique_id": "macro.dbt_utils.postgres__deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "postgres__deduplicate", + "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.406261, + "supported_languages": null + }, + "macro.dbt_utils.snowflake__deduplicate": { + "unique_id": "macro.dbt_utils.snowflake__deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "snowflake__deduplicate", + "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4064052, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__deduplicate": { + "unique_id": "macro.dbt_utils.bigquery__deduplicate", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "name": "bigquery__deduplicate", + "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4065611, + "supported_languages": null + }, + "macro.dbt_utils.surrogate_key": { + "unique_id": "macro.dbt_utils.surrogate_key", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/surrogate_key.sql", + "original_file_path": "macros/sql/surrogate_key.sql", + "name": "surrogate_key", + "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__surrogate_key"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.406983, + "supported_languages": null + }, + "macro.dbt_utils.default__surrogate_key": { + "unique_id": "macro.dbt_utils.default__surrogate_key", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/surrogate_key.sql", + "original_file_path": "macros/sql/surrogate_key.sql", + "name": "default__surrogate_key", + "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4072099, + "supported_languages": null + }, + "macro.dbt_utils.safe_add": { + "unique_id": "macro.dbt_utils.safe_add", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/safe_add.sql", + "original_file_path": "macros/sql/safe_add.sql", + "name": "safe_add", + "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__safe_add"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4076219, + "supported_languages": null + }, + "macro.dbt_utils.default__safe_add": { + "unique_id": "macro.dbt_utils.default__safe_add", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/safe_add.sql", + "original_file_path": "macros/sql/safe_add.sql", + "name": "default__safe_add", + "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4081101, + "supported_languages": null + }, + "macro.dbt_utils.nullcheck": { + "unique_id": "macro.dbt_utils.nullcheck", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/nullcheck.sql", + "original_file_path": "macros/sql/nullcheck.sql", + "name": "nullcheck", + "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__nullcheck"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4084759, + "supported_languages": null + }, + "macro.dbt_utils.default__nullcheck": { + "unique_id": "macro.dbt_utils.default__nullcheck", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/nullcheck.sql", + "original_file_path": "macros/sql/nullcheck.sql", + "name": "default__nullcheck", + "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.408771, + "supported_languages": null + }, + "macro.dbt_utils.get_tables_by_pattern_sql": { + "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "name": "get_tables_by_pattern_sql", + "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4102662, + "supported_languages": null + }, + "macro.dbt_utils.default__get_tables_by_pattern_sql": { + "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "name": "default__get_tables_by_pattern_sql", + "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.get_table_types_sql"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.410592, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": { + "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "name": "bigquery__get_tables_by_pattern_sql", + "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._bigquery__get_matching_schemata", + "macro.dbt_utils.get_table_types_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.411437, + "supported_languages": null + }, + "macro.dbt_utils._bigquery__get_matching_schemata": { + "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "name": "_bigquery__get_matching_schemata", + "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.run_query"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4118888, + "supported_languages": null + }, + "macro.dbt_utils.get_column_values": { + "unique_id": "macro.dbt_utils.get_column_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_column_values.sql", + "original_file_path": "macros/sql/get_column_values.sql", + "name": "get_column_values", + "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_column_values"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4129212, + "supported_languages": null + }, + "macro.dbt_utils.default__get_column_values": { + "unique_id": "macro.dbt_utils.default__get_column_values", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_column_values.sql", + "original_file_path": "macros/sql/get_column_values.sql", + "name": "default__get_column_values", + "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_ephemeral", + "macro.dbt.load_relation", + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.414268, + "supported_languages": null + }, + "macro.dbt_utils.pivot": { + "unique_id": "macro.dbt_utils.pivot", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/pivot.sql", + "original_file_path": "macros/sql/pivot.sql", + "name": "pivot", + "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__pivot"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.415263, + "supported_languages": null + }, + "macro.dbt_utils.default__pivot": { + "unique_id": "macro.dbt_utils.default__pivot", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/pivot.sql", + "original_file_path": "macros/sql/pivot.sql", + "name": "default__pivot", + "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.416003, + "supported_languages": null + }, + "macro.dbt_utils.get_filtered_columns_in_relation": { + "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_filtered_columns_in_relation.sql", + "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", + "name": "get_filtered_columns_in_relation", + "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.416487, + "supported_languages": null + }, + "macro.dbt_utils.default__get_filtered_columns_in_relation": { + "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_filtered_columns_in_relation.sql", + "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", + "name": "default__get_filtered_columns_in_relation", + "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.417129, + "supported_languages": null + }, + "macro.dbt_utils.width_bucket": { + "unique_id": "macro.dbt_utils.width_bucket", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "name": "width_bucket", + "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.snowflake__width_bucket"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.418448, + "supported_languages": null + }, + "macro.dbt_utils.default__width_bucket": { + "unique_id": "macro.dbt_utils.default__width_bucket", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "name": "default__width_bucket", + "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.418854, + "supported_languages": null + }, + "macro.dbt_utils.redshift__width_bucket": { + "unique_id": "macro.dbt_utils.redshift__width_bucket", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "name": "redshift__width_bucket", + "macro_sql": "{% macro redshift__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is exactly at the bucket edge\n case\n when\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }} %\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.419262, + "supported_languages": null + }, + "macro.dbt_utils.snowflake__width_bucket": { + "unique_id": "macro.dbt_utils.snowflake__width_bucket", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "name": "snowflake__width_bucket", + "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.419429, + "supported_languages": null + }, + "macro.dbt_utils.get_query_results_as_dict": { + "unique_id": "macro.dbt_utils.get_query_results_as_dict", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_query_results_as_dict.sql", + "original_file_path": "macros/sql/get_query_results_as_dict.sql", + "name": "get_query_results_as_dict", + "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_query_results_as_dict"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.419848, + "supported_languages": null + }, + "macro.dbt_utils.default__get_query_results_as_dict": { + "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_query_results_as_dict.sql", + "original_file_path": "macros/sql/get_query_results_as_dict.sql", + "name": "default__get_query_results_as_dict", + "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.420377, + "supported_languages": null + }, + "macro.dbt_utils.generate_surrogate_key": { + "unique_id": "macro.dbt_utils.generate_surrogate_key", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_surrogate_key.sql", + "original_file_path": "macros/sql/generate_surrogate_key.sql", + "name": "generate_surrogate_key", + "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__generate_surrogate_key"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.420844, + "supported_languages": null + }, + "macro.dbt_utils.default__generate_surrogate_key": { + "unique_id": "macro.dbt_utils.default__generate_surrogate_key", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/generate_surrogate_key.sql", + "original_file_path": "macros/sql/generate_surrogate_key.sql", + "name": "default__generate_surrogate_key", + "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{% if var('surrogate_key_treat_nulls_as_empty_strings', False) %}\n {% set default_null_value = \"\" %}\n{% else %}\n {% set default_null_value = '_dbt_utils_surrogate_key_null_'%}\n{% endif %}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.type_string", + "macro.dbt.hash", + "macro.dbt.concat" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4214232, + "supported_languages": null + }, + "macro.dbt_utils.get_table_types_sql": { + "unique_id": "macro.dbt_utils.get_table_types_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "name": "get_table_types_sql", + "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__get_table_types_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4218292, + "supported_languages": null + }, + "macro.dbt_utils.default__get_table_types_sql": { + "unique_id": "macro.dbt_utils.default__get_table_types_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "name": "default__get_table_types_sql", + "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.421955, + "supported_languages": null + }, + "macro.dbt_utils.postgres__get_table_types_sql": { + "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "name": "postgres__get_table_types_sql", + "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.422082, + "supported_languages": null + }, + "macro.dbt_utils.get_single_value": { + "unique_id": "macro.dbt_utils.get_single_value", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_single_value.sql", + "original_file_path": "macros/sql/get_single_value.sql", + "name": "get_single_value", + "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.default__get_single_value"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.422582, + "supported_languages": null + }, + "macro.dbt_utils.default__get_single_value": { + "unique_id": "macro.dbt_utils.default__get_single_value", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/get_single_value.sql", + "original_file_path": "macros/sql/get_single_value.sql", + "name": "default__get_single_value", + "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.447829, + "supported_languages": null + }, + "macro.dbt_utils.degrees_to_radians": { + "unique_id": "macro.dbt_utils.degrees_to_radians", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "name": "degrees_to_radians", + "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4489868, + "supported_languages": null + }, + "macro.dbt_utils.haversine_distance": { + "unique_id": "macro.dbt_utils.haversine_distance", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "name": "haversine_distance", + "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_utils.default__haversine_distance"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.449245, + "supported_languages": null + }, + "macro.dbt_utils.default__haversine_distance": { + "unique_id": "macro.dbt_utils.default__haversine_distance", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "name": "default__haversine_distance", + "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4497669, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__haversine_distance": { + "unique_id": "macro.dbt_utils.bigquery__haversine_distance", + "package_name": "dbt_utils", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "name": "bigquery__haversine_distance", + "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_utils.degrees_to_radians"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.450482, + "supported_languages": null + }, + "macro.dbt_date.get_date_dimension": { + "unique_id": "macro.dbt_date.get_date_dimension", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_date_dimension.sql", + "original_file_path": "macros/get_date_dimension.sql", + "name": "get_date_dimension", + "macro_sql": "{% macro get_date_dimension(start_date, end_date) %}\n {{ adapter.dispatch('get_date_dimension', 'dbt_date') (start_date, end_date) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.default__get_date_dimension"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4585989, + "supported_languages": null + }, + "macro.dbt_date.default__get_date_dimension": { + "unique_id": "macro.dbt_date.default__get_date_dimension", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_date_dimension.sql", + "original_file_path": "macros/get_date_dimension.sql", + "name": "default__get_date_dimension", + "macro_sql": "{% macro default__get_date_dimension(start_date, end_date) %}\nwith base_dates as (\n {{ dbt_date.get_base_dates(start_date, end_date) }}\n),\ndates_with_prior_year_dates as (\n\n select\n cast(d.date_day as date) as date_day,\n cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day,\n cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day\n from\n \tbase_dates d\n\n)\nselect\n d.date_day,\n {{ dbt_date.yesterday('d.date_day') }} as prior_date_day,\n {{ dbt_date.tomorrow('d.date_day') }} as next_date_day,\n d.prior_year_date_day as prior_year_date_day,\n d.prior_year_over_year_date_day,\n {{ dbt_date.day_of_week('d.date_day', isoweek=false) }} as day_of_week,\n {{ dbt_date.day_of_week('d.date_day', isoweek=true) }} as day_of_week_iso,\n {{ dbt_date.day_name('d.date_day', short=false) }} as day_of_week_name,\n {{ dbt_date.day_name('d.date_day', short=true) }} as day_of_week_name_short,\n {{ dbt_date.day_of_month('d.date_day') }} as day_of_month,\n {{ dbt_date.day_of_year('d.date_day') }} as day_of_year,\n\n {{ dbt_date.week_start('d.date_day') }} as week_start_date,\n {{ dbt_date.week_end('d.date_day') }} as week_end_date,\n {{ dbt_date.week_start('d.prior_year_over_year_date_day') }} as prior_year_week_start_date,\n {{ dbt_date.week_end('d.prior_year_over_year_date_day') }} as prior_year_week_end_date,\n {{ dbt_date.week_of_year('d.date_day') }} as week_of_year,\n\n {{ dbt_date.iso_week_start('d.date_day') }} as iso_week_start_date,\n {{ dbt_date.iso_week_end('d.date_day') }} as iso_week_end_date,\n {{ dbt_date.iso_week_start('d.prior_year_over_year_date_day') }} as prior_year_iso_week_start_date,\n {{ dbt_date.iso_week_end('d.prior_year_over_year_date_day') }} as prior_year_iso_week_end_date,\n {{ dbt_date.iso_week_of_year('d.date_day') }} as iso_week_of_year,\n\n {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year,\n {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year,\n\n cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year,\n {{ dbt_date.month_name('d.date_day', short=false) }} as month_name,\n {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short,\n\n cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date,\n cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date,\n\n cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date,\n cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date,\n\n cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year,\n cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date,\n cast({{ last_day('d.date_day', 'quarter') }} as date) as quarter_end_date,\n\n cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number,\n cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date,\n cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date\nfrom\n dates_with_prior_year_dates d\norder by 1\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.get_base_dates", + "macro.dbt.dateadd", + "macro.dbt_date.yesterday", + "macro.dbt_date.tomorrow", + "macro.dbt_date.day_of_week", + "macro.dbt_date.day_name", + "macro.dbt_date.day_of_month", + "macro.dbt_date.day_of_year", + "macro.dbt_date.week_start", + "macro.dbt_date.week_end", + "macro.dbt_date.week_of_year", + "macro.dbt_date.iso_week_start", + "macro.dbt_date.iso_week_end", + "macro.dbt_date.iso_week_of_year", + "macro.dbt_date.date_part", + "macro.dbt.type_int", + "macro.dbt_date.month_name", + "macro.dbt.date_trunc", + "macro.dbt.last_day" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.460624, + "supported_languages": null + }, + "macro.dbt_date.postgres__get_date_dimension": { + "unique_id": "macro.dbt_date.postgres__get_date_dimension", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_date_dimension.sql", + "original_file_path": "macros/get_date_dimension.sql", + "name": "postgres__get_date_dimension", + "macro_sql": "{% macro postgres__get_date_dimension(start_date, end_date) %}\nwith base_dates as (\n {{ dbt_date.get_base_dates(start_date, end_date) }}\n),\ndates_with_prior_year_dates as (\n\n select\n cast(d.date_day as date) as date_day,\n cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day,\n cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day\n from\n \tbase_dates d\n\n)\nselect\n d.date_day,\n {{ dbt_date.yesterday('d.date_day') }} as prior_date_day,\n {{ dbt_date.tomorrow('d.date_day') }} as next_date_day,\n d.prior_year_date_day as prior_year_date_day,\n d.prior_year_over_year_date_day,\n {{ dbt_date.day_of_week('d.date_day', isoweek=true) }} as day_of_week,\n\n {{ dbt_date.day_name('d.date_day', short=false) }} as day_of_week_name,\n {{ dbt_date.day_name('d.date_day', short=true) }} as day_of_week_name_short,\n {{ dbt_date.day_of_month('d.date_day') }} as day_of_month,\n {{ dbt_date.day_of_year('d.date_day') }} as day_of_year,\n\n {{ dbt_date.week_start('d.date_day') }} as week_start_date,\n {{ dbt_date.week_end('d.date_day') }} as week_end_date,\n {{ dbt_date.week_start('d.prior_year_over_year_date_day') }} as prior_year_week_start_date,\n {{ dbt_date.week_end('d.prior_year_over_year_date_day') }} as prior_year_week_end_date,\n {{ dbt_date.week_of_year('d.date_day') }} as week_of_year,\n\n {{ dbt_date.iso_week_start('d.date_day') }} as iso_week_start_date,\n {{ dbt_date.iso_week_end('d.date_day') }} as iso_week_end_date,\n {{ dbt_date.iso_week_start('d.prior_year_over_year_date_day') }} as prior_year_iso_week_start_date,\n {{ dbt_date.iso_week_end('d.prior_year_over_year_date_day') }} as prior_year_iso_week_end_date,\n {{ dbt_date.iso_week_of_year('d.date_day') }} as iso_week_of_year,\n\n {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year,\n {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year,\n\n cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year,\n {{ dbt_date.month_name('d.date_day', short=false) }} as month_name,\n {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short,\n\n cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date,\n cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date,\n\n cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date,\n cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date,\n\n cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year,\n cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date,\n {# last_day does not support quarter because postgresql does not support quarter interval. #}\n cast({{dbt.dateadd('day', '-1', dbt.dateadd('month', '3', dbt.date_trunc('quarter', 'd.date_day')))}} as date) as quarter_end_date,\n\n cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number,\n cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date,\n cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date\nfrom\n dates_with_prior_year_dates d\norder by 1\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.get_base_dates", + "macro.dbt.dateadd", + "macro.dbt_date.yesterday", + "macro.dbt_date.tomorrow", + "macro.dbt_date.day_of_week", + "macro.dbt_date.day_name", + "macro.dbt_date.day_of_month", + "macro.dbt_date.day_of_year", + "macro.dbt_date.week_start", + "macro.dbt_date.week_end", + "macro.dbt_date.week_of_year", + "macro.dbt_date.iso_week_start", + "macro.dbt_date.iso_week_end", + "macro.dbt_date.iso_week_of_year", + "macro.dbt_date.date_part", + "macro.dbt.type_int", + "macro.dbt_date.month_name", + "macro.dbt.date_trunc", + "macro.dbt.last_day" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4626582, + "supported_languages": null + }, + "macro.dbt_date.get_base_dates": { + "unique_id": "macro.dbt_date.get_base_dates", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_base_dates.sql", + "original_file_path": "macros/get_base_dates.sql", + "name": "get_base_dates", + "macro_sql": "{% macro get_base_dates(start_date=None, end_date=None, n_dateparts=None, datepart=\"day\") %}\n {{ adapter.dispatch('get_base_dates', 'dbt_date') (start_date, end_date, n_dateparts, datepart) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__get_base_dates"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4636312, + "supported_languages": null + }, + "macro.dbt_date.default__get_base_dates": { + "unique_id": "macro.dbt_date.default__get_base_dates", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_base_dates.sql", + "original_file_path": "macros/get_base_dates.sql", + "name": "default__get_base_dates", + "macro_sql": "{% macro default__get_base_dates(start_date, end_date, n_dateparts, datepart) %}\n\n{%- if start_date and end_date -%}\n{%- set start_date=\"cast('\" ~ start_date ~ \"' as \" ~ dbt.type_timestamp() ~ \")\" -%}\n{%- set end_date=\"cast('\" ~ end_date ~ \"' as \" ~ dbt.type_timestamp() ~ \")\" -%}\n\n{%- elif n_dateparts and datepart -%}\n\n{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%}\n{%- set end_date = dbt_date.tomorrow() -%}\n{%- endif -%}\n\nwith date_spine as\n(\n\n {{ dbt_date.date_spine(\n datepart=datepart,\n start_date=start_date,\n end_date=end_date,\n )\n }}\n\n)\nselect\n cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }}\nfrom\n date_spine d\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.type_timestamp", + "macro.dbt.dateadd", + "macro.dbt_date.today", + "macro.dbt_date.tomorrow", + "macro.dbt_date.date_spine" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.464303, + "supported_languages": null + }, + "macro.dbt_date.bigquery__get_base_dates": { + "unique_id": "macro.dbt_date.bigquery__get_base_dates", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/get_base_dates.sql", + "original_file_path": "macros/get_base_dates.sql", + "name": "bigquery__get_base_dates", + "macro_sql": "{% macro bigquery__get_base_dates(start_date, end_date, n_dateparts, datepart) %}\n\n{%- if start_date and end_date -%}\n{%- set start_date=\"cast('\" ~ start_date ~ \"' as date )\" -%}\n{%- set end_date=\"cast('\" ~ end_date ~ \"' as date )\" -%}\n\n{%- elif n_dateparts and datepart -%}\n\n{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%}\n{%- set end_date = dbt_date.tomorrow() -%}\n{%- endif -%}\n\nwith date_spine as\n(\n\n {{ dbt_date.date_spine(\n datepart=datepart,\n start_date=start_date,\n end_date=end_date,\n )\n }}\n\n)\nselect\n cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }}\nfrom\n date_spine d\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.dateadd", + "macro.dbt_date.today", + "macro.dbt_date.tomorrow", + "macro.dbt_date.date_spine", + "macro.dbt.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.464916, + "supported_languages": null + }, + "macro.dbt_date.get_intervals_between": { + "unique_id": "macro.dbt_date.get_intervals_between", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/date_spine.sql", + "original_file_path": "macros/_utils/date_spine.sql", + "name": "get_intervals_between", + "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_date')(start_date, end_date, datepart)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.default__get_intervals_between"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.465622, + "supported_languages": null + }, + "macro.dbt_date.default__get_intervals_between": { + "unique_id": "macro.dbt_date.default__get_intervals_between", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/date_spine.sql", + "original_file_path": "macros/_utils/date_spine.sql", + "name": "default__get_intervals_between", + "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement", "macro.dbt.datediff"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.466151, + "supported_languages": null + }, + "macro.dbt_date.date_spine": { + "unique_id": "macro.dbt_date.date_spine", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/date_spine.sql", + "original_file_path": "macros/_utils/date_spine.sql", + "name": "date_spine", + "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_date')(datepart, start_date, end_date)) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__date_spine"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.466361, + "supported_languages": null + }, + "macro.dbt_date.default__date_spine": { + "unique_id": "macro.dbt_date.default__date_spine", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/date_spine.sql", + "original_file_path": "macros/_utils/date_spine.sql", + "name": "default__date_spine", + "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{\n dbt_date.generate_series(\n dbt_date.get_intervals_between(start_date, end_date, datepart)\n )\n }}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.generate_series", + "macro.dbt_date.get_intervals_between", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.46669, + "supported_languages": null + }, + "macro.dbt_date.get_powers_of_two": { + "unique_id": "macro.dbt_date.get_powers_of_two", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/generate_series.sql", + "original_file_path": "macros/_utils/generate_series.sql", + "name": "get_powers_of_two", + "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_date')(upper_bound)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__get_powers_of_two"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.46749, + "supported_languages": null + }, + "macro.dbt_date.default__get_powers_of_two": { + "unique_id": "macro.dbt_date.default__get_powers_of_two", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/generate_series.sql", + "original_file_path": "macros/_utils/generate_series.sql", + "name": "default__get_powers_of_two", + "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.467856, + "supported_languages": null + }, + "macro.dbt_date.generate_series": { + "unique_id": "macro.dbt_date.generate_series", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/generate_series.sql", + "original_file_path": "macros/_utils/generate_series.sql", + "name": "generate_series", + "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_date')(upper_bound)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__generate_series"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.468025, + "supported_languages": null + }, + "macro.dbt_date.default__generate_series": { + "unique_id": "macro.dbt_date.default__generate_series", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/_utils/generate_series.sql", + "original_file_path": "macros/_utils/generate_series.sql", + "name": "default__generate_series", + "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_date.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.get_powers_of_two"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.468481, + "supported_languages": null + }, + "macro.dbt_date.get_fiscal_year_dates": { + "unique_id": "macro.dbt_date.get_fiscal_year_dates", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/fiscal_date/get_fiscal_year_dates.sql", + "original_file_path": "macros/fiscal_date/get_fiscal_year_dates.sql", + "name": "get_fiscal_year_dates", + "macro_sql": "{% macro get_fiscal_year_dates(dates, year_end_month=12, week_start_day=1, shift_year=1) %}\n{{ adapter.dispatch('get_fiscal_year_dates', 'dbt_date') (dates, year_end_month, week_start_day, shift_year) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.default__get_fiscal_year_dates"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4700959, + "supported_languages": null + }, + "macro.dbt_date.default__get_fiscal_year_dates": { + "unique_id": "macro.dbt_date.default__get_fiscal_year_dates", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/fiscal_date/get_fiscal_year_dates.sql", + "original_file_path": "macros/fiscal_date/get_fiscal_year_dates.sql", + "name": "default__get_fiscal_year_dates", + "macro_sql": "{% macro default__get_fiscal_year_dates(dates, year_end_month, week_start_day, shift_year) %}\n-- this gets all the dates within a fiscal year\n-- determined by the given year-end-month\n-- ending on the saturday closest to that month's end date\nwith date_dimension as (\n select * from {{ dates }}\n),\nyear_month_end as (\n\n select\n d.year_number - {{ shift_year }} as fiscal_year_number,\n d.month_end_date\n from\n date_dimension d\n where\n d.month_of_year = {{ year_end_month }}\n group by 1,2\n\n),\nweeks as (\n\n select\n d.year_number,\n d.month_of_year,\n d.date_day as week_start_date,\n cast({{ dbt.dateadd('day', 6, 'd.date_day') }} as date) as week_end_date\n from\n date_dimension d\n where\n d.day_of_week = {{ week_start_day }}\n\n),\n-- get all the weeks that start in the month the year ends\nyear_week_ends as (\n\n select\n d.year_number - {{ shift_year }} as fiscal_year_number,\n d.week_end_date\n from\n weeks d\n where\n d.month_of_year = {{ year_end_month }}\n group by\n 1,2\n\n),\n-- then calculate which Saturday is closest to month end\nweeks_at_month_end as (\n\n select\n d.fiscal_year_number,\n d.week_end_date,\n m.month_end_date,\n rank() over\n (partition by d.fiscal_year_number\n order by\n abs({{ dbt.datediff('d.week_end_date', 'm.month_end_date', 'day') }})\n\n ) as closest_to_month_end\n from\n year_week_ends d\n join\n year_month_end m on d.fiscal_year_number = m.fiscal_year_number\n),\nfiscal_year_range as (\n\n select\n w.fiscal_year_number,\n cast(\n {{ dbt.dateadd('day', 1,\n 'lag(w.week_end_date) over(order by w.week_end_date)') }}\n as date) as fiscal_year_start_date,\n w.week_end_date as fiscal_year_end_date\n from\n weeks_at_month_end w\n where\n w.closest_to_month_end = 1\n\n),\nfiscal_year_dates as (\n\n select\n d.date_day,\n m.fiscal_year_number,\n m.fiscal_year_start_date,\n m.fiscal_year_end_date,\n w.week_start_date,\n w.week_end_date,\n -- we reset the weeks of the year starting with the merch year start date\n dense_rank()\n over(\n partition by m.fiscal_year_number\n order by w.week_start_date\n ) as fiscal_week_of_year\n from\n date_dimension d\n join\n fiscal_year_range m on d.date_day between m.fiscal_year_start_date and m.fiscal_year_end_date\n join\n weeks w on d.date_day between w.week_start_date and w.week_end_date\n\n)\nselect * from fiscal_year_dates order by 1\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.dateadd", "macro.dbt.datediff"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.470626, + "supported_languages": null + }, + "macro.dbt_date.get_fiscal_periods": { + "unique_id": "macro.dbt_date.get_fiscal_periods", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/fiscal_date/get_fiscal_periods.sql", + "original_file_path": "macros/fiscal_date/get_fiscal_periods.sql", + "name": "get_fiscal_periods", + "macro_sql": "{% macro get_fiscal_periods(dates, year_end_month, week_start_day, shift_year=1) %}\n{#\nThis macro requires you to pass in a ref to a date dimension, created via\ndbt_date.get_date_dimension()s\n#}\nwith fscl_year_dates_for_periods as (\n {{ dbt_date.get_fiscal_year_dates(dates, year_end_month, week_start_day, shift_year) }}\n),\nfscl_year_w13 as (\n\n select\n f.*,\n -- We count the weeks in a 13 week period\n -- and separate the 4-5-4 week sequences\n mod(cast(\n (f.fiscal_week_of_year-1) as {{ dbt.type_int() }}\n ), 13) as w13_number,\n -- Chop weeks into 13 week merch quarters\n cast(\n least(\n floor((f.fiscal_week_of_year-1)/13.0)\n , 3)\n as {{ dbt.type_int() }}) as quarter_number\n from\n fscl_year_dates_for_periods f\n\n),\nfscl_periods as (\n\n select\n f.date_day,\n f.fiscal_year_number,\n f.week_start_date,\n f.week_end_date,\n f.fiscal_week_of_year,\n case\n -- we move week 53 into the 3rd period of the quarter\n when f.fiscal_week_of_year = 53 then 3\n when f.w13_number between 0 and 3 then 1\n when f.w13_number between 4 and 8 then 2\n when f.w13_number between 9 and 12 then 3\n end as period_of_quarter,\n f.quarter_number\n from\n fscl_year_w13 f\n\n),\nfscl_periods_quarters as (\n\n select\n f.*,\n cast((\n (f.quarter_number * 3) + f.period_of_quarter\n ) as {{ dbt.type_int() }}) as fiscal_period_number\n from\n fscl_periods f\n\n)\nselect\n date_day,\n fiscal_year_number,\n week_start_date,\n week_end_date,\n fiscal_week_of_year,\n dense_rank() over(partition by fiscal_period_number order by fiscal_week_of_year) as fiscal_week_of_period,\n fiscal_period_number,\n quarter_number+1 as fiscal_quarter_number,\n period_of_quarter as fiscal_period_of_quarter\nfrom\n fscl_periods_quarters\norder by 1,2\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.get_fiscal_year_dates", "macro.dbt.type_int"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.471539, + "supported_languages": null + }, + "macro.dbt_date.tomorrow": { + "unique_id": "macro.dbt_date.tomorrow", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/tomorrow.sql", + "original_file_path": "macros/calendar_date/tomorrow.sql", + "name": "tomorrow", + "macro_sql": "{%- macro tomorrow(date=None, tz=None) -%}\n{{ dbt_date.n_days_away(1, date, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_days_away"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.471798, + "supported_languages": null + }, + "macro.dbt_date.next_week": { + "unique_id": "macro.dbt_date.next_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/next_week.sql", + "original_file_path": "macros/calendar_date/next_week.sql", + "name": "next_week", + "macro_sql": "{%- macro next_week(tz=None) -%}\n{{ dbt_date.n_weeks_away(1, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_weeks_away"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.47202, + "supported_languages": null + }, + "macro.dbt_date.next_month_name": { + "unique_id": "macro.dbt_date.next_month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/next_month_name.sql", + "original_file_path": "macros/calendar_date/next_month_name.sql", + "name": "next_month_name", + "macro_sql": "{%- macro next_month_name(short=True, tz=None) -%}\n{{ dbt_date.month_name(dbt_date.next_month(tz), short=short) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.month_name", "macro.dbt_date.next_month"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.47229, + "supported_languages": null + }, + "macro.dbt_date.next_month": { + "unique_id": "macro.dbt_date.next_month", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/next_month.sql", + "original_file_path": "macros/calendar_date/next_month.sql", + "name": "next_month", + "macro_sql": "{%- macro next_month(tz=None) -%}\n{{ dbt_date.n_months_away(1, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_months_away"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.472516, + "supported_languages": null + }, + "macro.dbt_date.day_name": { + "unique_id": "macro.dbt_date.day_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_name.sql", + "original_file_path": "macros/calendar_date/day_name.sql", + "name": "day_name", + "macro_sql": "{%- macro day_name(date, short=True) -%}\n {{ adapter.dispatch('day_name', 'dbt_date') (date, short) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.snowflake__day_name"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.47312, + "supported_languages": null + }, + "macro.dbt_date.default__day_name": { + "unique_id": "macro.dbt_date.default__day_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_name.sql", + "original_file_path": "macros/calendar_date/day_name.sql", + "name": "default__day_name", + "macro_sql": "\n\n{%- macro default__day_name(date, short) -%}\n{%- set f = 'Dy' if short else 'Day' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.473362, + "supported_languages": null + }, + "macro.dbt_date.snowflake__day_name": { + "unique_id": "macro.dbt_date.snowflake__day_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_name.sql", + "original_file_path": "macros/calendar_date/day_name.sql", + "name": "snowflake__day_name", + "macro_sql": "\n\n{%- macro snowflake__day_name(date, short) -%}\n {%- if short -%}\n dayname({{ date }})\n {%- else -%}\n -- long version not implemented on Snowflake so we're doing it manually :/\n case dayname({{ date }})\n when 'Mon' then 'Monday'\n when 'Tue' then 'Tuesday'\n when 'Wed' then 'Wednesday'\n when 'Thu' then 'Thursday'\n when 'Fri' then 'Friday'\n when 'Sat' then 'Saturday'\n when 'Sun' then 'Sunday'\n end\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.473547, + "supported_languages": null + }, + "macro.dbt_date.bigquery__day_name": { + "unique_id": "macro.dbt_date.bigquery__day_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_name.sql", + "original_file_path": "macros/calendar_date/day_name.sql", + "name": "bigquery__day_name", + "macro_sql": "\n\n{%- macro bigquery__day_name(date, short) -%}\n{%- set f = '%a' if short else '%A' -%}\n format_date('{{ f }}', cast({{ date }} as date))\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.473726, + "supported_languages": null + }, + "macro.dbt_date.postgres__day_name": { + "unique_id": "macro.dbt_date.postgres__day_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_name.sql", + "original_file_path": "macros/calendar_date/day_name.sql", + "name": "postgres__day_name", + "macro_sql": "\n\n{%- macro postgres__day_name(date, short) -%}\n{# FM = Fill mode, which suppresses padding blanks #}\n{%- set f = 'FMDy' if short else 'FMDay' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4739048, + "supported_languages": null + }, + "macro.dbt_date.to_unixtimestamp": { + "unique_id": "macro.dbt_date.to_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/to_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", + "name": "to_unixtimestamp", + "macro_sql": "{%- macro to_unixtimestamp(timestamp) -%}\n {{ adapter.dispatch('to_unixtimestamp', 'dbt_date') (timestamp) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.snowflake__to_unixtimestamp"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4742432, + "supported_languages": null + }, + "macro.dbt_date.default__to_unixtimestamp": { + "unique_id": "macro.dbt_date.default__to_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/to_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", + "name": "default__to_unixtimestamp", + "macro_sql": "\n\n{%- macro default__to_unixtimestamp(timestamp) -%}\n {{ dbt_date.date_part('epoch', timestamp) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.474366, + "supported_languages": null + }, + "macro.dbt_date.snowflake__to_unixtimestamp": { + "unique_id": "macro.dbt_date.snowflake__to_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/to_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", + "name": "snowflake__to_unixtimestamp", + "macro_sql": "\n\n{%- macro snowflake__to_unixtimestamp(timestamp) -%}\n {{ dbt_date.date_part('epoch_seconds', timestamp) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.474489, + "supported_languages": null + }, + "macro.dbt_date.bigquery__to_unixtimestamp": { + "unique_id": "macro.dbt_date.bigquery__to_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/to_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/to_unixtimestamp.sql", + "name": "bigquery__to_unixtimestamp", + "macro_sql": "\n\n{%- macro bigquery__to_unixtimestamp(timestamp) -%}\n unix_seconds({{ timestamp }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.474578, + "supported_languages": null + }, + "macro.dbt_date.n_days_away": { + "unique_id": "macro.dbt_date.n_days_away", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_days_away.sql", + "original_file_path": "macros/calendar_date/n_days_away.sql", + "name": "n_days_away", + "macro_sql": "{%- macro n_days_away(n, date=None, tz=None) -%}\n{{ dbt_date.n_days_ago(-1 * n, date, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_days_ago"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4748569, + "supported_languages": null + }, + "macro.dbt_date.week_start": { + "unique_id": "macro.dbt_date.week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_start.sql", + "original_file_path": "macros/calendar_date/week_start.sql", + "name": "week_start", + "macro_sql": "{%- macro week_start(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_start', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.today", + "macro.dbt_date.snowflake__week_start" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4753358, + "supported_languages": null + }, + "macro.dbt_date.default__week_start": { + "unique_id": "macro.dbt_date.default__week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_start.sql", + "original_file_path": "macros/calendar_date/week_start.sql", + "name": "default__week_start", + "macro_sql": "{%- macro default__week_start(date) -%}\ncast({{ dbt.date_trunc('week', date) }} as date)\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.date_trunc"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.475467, + "supported_languages": null + }, + "macro.dbt_date.snowflake__week_start": { + "unique_id": "macro.dbt_date.snowflake__week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_start.sql", + "original_file_path": "macros/calendar_date/week_start.sql", + "name": "snowflake__week_start", + "macro_sql": "\n\n{%- macro snowflake__week_start(date) -%}\n {#\n Get the day of week offset: e.g. if the date is a Sunday,\n dbt_date.day_of_week returns 1, so we subtract 1 to get a 0 offset\n #}\n {% set off_set = dbt_date.day_of_week(date, isoweek=False) ~ \" - 1\" %}\n cast({{ dbt.dateadd(\"day\", \"-1 * (\" ~ off_set ~ \")\", date) }} as date)\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.day_of_week", "macro.dbt.dateadd"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.475729, + "supported_languages": null + }, + "macro.dbt_date.postgres__week_start": { + "unique_id": "macro.dbt_date.postgres__week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_start.sql", + "original_file_path": "macros/calendar_date/week_start.sql", + "name": "postgres__week_start", + "macro_sql": "\n\n{%- macro postgres__week_start(date) -%}\n-- Sunday as week start date\ncast({{ dbt.dateadd('day', -1, dbt.date_trunc('week', dbt.dateadd('day', 1, date))) }} as date)\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.47596, + "supported_languages": null + }, + "macro.dbt_date.iso_week_start": { + "unique_id": "macro.dbt_date.iso_week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_start.sql", + "original_file_path": "macros/calendar_date/iso_week_start.sql", + "name": "iso_week_start", + "macro_sql": "{%- macro iso_week_start(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_start', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.today", + "macro.dbt_date.snowflake__iso_week_start" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.476455, + "supported_languages": null + }, + "macro.dbt_date._iso_week_start": { + "unique_id": "macro.dbt_date._iso_week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_start.sql", + "original_file_path": "macros/calendar_date/iso_week_start.sql", + "name": "_iso_week_start", + "macro_sql": "{%- macro _iso_week_start(date, week_type) -%}\ncast({{ dbt.date_trunc(week_type, date) }} as date)\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.date_trunc"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.476594, + "supported_languages": null + }, + "macro.dbt_date.default__iso_week_start": { + "unique_id": "macro.dbt_date.default__iso_week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_start.sql", + "original_file_path": "macros/calendar_date/iso_week_start.sql", + "name": "default__iso_week_start", + "macro_sql": "\n\n{%- macro default__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'isoweek') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_start"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.476717, + "supported_languages": null + }, + "macro.dbt_date.snowflake__iso_week_start": { + "unique_id": "macro.dbt_date.snowflake__iso_week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_start.sql", + "original_file_path": "macros/calendar_date/iso_week_start.sql", + "name": "snowflake__iso_week_start", + "macro_sql": "\n\n{%- macro snowflake__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'week') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_start"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4768388, + "supported_languages": null + }, + "macro.dbt_date.postgres__iso_week_start": { + "unique_id": "macro.dbt_date.postgres__iso_week_start", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_start.sql", + "original_file_path": "macros/calendar_date/iso_week_start.sql", + "name": "postgres__iso_week_start", + "macro_sql": "\n\n{%- macro postgres__iso_week_start(date) -%}\n{{ dbt_date._iso_week_start(date, 'week') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_start"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4769568, + "supported_languages": null + }, + "macro.dbt_date.n_days_ago": { + "unique_id": "macro.dbt_date.n_days_ago", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_days_ago.sql", + "original_file_path": "macros/calendar_date/n_days_ago.sql", + "name": "n_days_ago", + "macro_sql": "{%- macro n_days_ago(n, date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{%- set n = n|int -%}\ncast({{ dbt.dateadd('day', -1 * n, dt) }} as date)\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.today", "macro.dbt.dateadd"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.477376, + "supported_languages": null + }, + "macro.dbt_date.last_week": { + "unique_id": "macro.dbt_date.last_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/last_week.sql", + "original_file_path": "macros/calendar_date/last_week.sql", + "name": "last_week", + "macro_sql": "{%- macro last_week(tz=None) -%}\n{{ dbt_date.n_weeks_ago(1, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_weeks_ago"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4775949, + "supported_languages": null + }, + "macro.dbt_date.now": { + "unique_id": "macro.dbt_date.now", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/now.sql", + "original_file_path": "macros/calendar_date/now.sql", + "name": "now", + "macro_sql": "{%- macro now(tz=None) -%}\n{{ dbt_date.convert_timezone(dbt.current_timestamp(), tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.convert_timezone", + "macro.dbt.current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.477835, + "supported_languages": null + }, + "macro.dbt_date.periods_since": { + "unique_id": "macro.dbt_date.periods_since", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/periods_since.sql", + "original_file_path": "macros/calendar_date/periods_since.sql", + "name": "periods_since", + "macro_sql": "{%- macro periods_since(date_col, period_name='day', tz=None) -%}\n{{ dbt.datediff(date_col, dbt_date.now(tz), period_name) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.datediff", "macro.dbt_date.now"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4781928, + "supported_languages": null + }, + "macro.dbt_date.today": { + "unique_id": "macro.dbt_date.today", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/today.sql", + "original_file_path": "macros/calendar_date/today.sql", + "name": "today", + "macro_sql": "{%- macro today(tz=None) -%}\ncast({{ dbt_date.now(tz) }} as date)\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.now"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.478407, + "supported_languages": null + }, + "macro.dbt_date.last_month": { + "unique_id": "macro.dbt_date.last_month", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/last_month.sql", + "original_file_path": "macros/calendar_date/last_month.sql", + "name": "last_month", + "macro_sql": "{%- macro last_month(tz=None) -%}\n{{ dbt_date.n_months_ago(1, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_months_ago"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.478626, + "supported_languages": null + }, + "macro.dbt_date.day_of_year": { + "unique_id": "macro.dbt_date.day_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_year.sql", + "original_file_path": "macros/calendar_date/day_of_year.sql", + "name": "day_of_year", + "macro_sql": "{%- macro day_of_year(date) -%}\n{{ adapter.dispatch('day_of_year', 'dbt_date') (date) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__day_of_year"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.478961, + "supported_languages": null + }, + "macro.dbt_date.default__day_of_year": { + "unique_id": "macro.dbt_date.default__day_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_year.sql", + "original_file_path": "macros/calendar_date/day_of_year.sql", + "name": "default__day_of_year", + "macro_sql": "\n\n{%- macro default__day_of_year(date) -%}\n {{ dbt_date.date_part('dayofyear', date) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4790819, + "supported_languages": null + }, + "macro.dbt_date.postgres__day_of_year": { + "unique_id": "macro.dbt_date.postgres__day_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_year.sql", + "original_file_path": "macros/calendar_date/day_of_year.sql", + "name": "postgres__day_of_year", + "macro_sql": "\n\n{%- macro postgres__day_of_year(date) -%}\n {{ dbt_date.date_part('doy', date) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4792051, + "supported_languages": null + }, + "macro.dbt_date.redshift__day_of_year": { + "unique_id": "macro.dbt_date.redshift__day_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_year.sql", + "original_file_path": "macros/calendar_date/day_of_year.sql", + "name": "redshift__day_of_year", + "macro_sql": "\n\n{%- macro redshift__day_of_year(date) -%}\n cast({{ dbt_date.date_part('dayofyear', date) }} as {{ dbt.type_bigint() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4793658, + "supported_languages": null + }, + "macro.dbt_date.round_timestamp": { + "unique_id": "macro.dbt_date.round_timestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/round_timestamp.sql", + "original_file_path": "macros/calendar_date/round_timestamp.sql", + "name": "round_timestamp", + "macro_sql": "{% macro round_timestamp(timestamp) %}\n {{ dbt.date_trunc(\"day\", dbt.dateadd(\"hour\", 12, timestamp)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.date_trunc", "macro.dbt.dateadd"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.479635, + "supported_languages": null + }, + "macro.dbt_date.from_unixtimestamp": { + "unique_id": "macro.dbt_date.from_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/from_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", + "name": "from_unixtimestamp", + "macro_sql": "{%- macro from_unixtimestamp(epochs, format=\"seconds\") -%}\n {{ adapter.dispatch('from_unixtimestamp', 'dbt_date') (epochs, format) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.snowflake__from_unixtimestamp"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.480735, + "supported_languages": null + }, + "macro.dbt_date.default__from_unixtimestamp": { + "unique_id": "macro.dbt_date.default__from_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/from_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", + "name": "default__from_unixtimestamp", + "macro_sql": "\n\n{%- macro default__from_unixtimestamp(epochs, format=\"seconds\") -%}\n {%- if format != \"seconds\" -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n to_timestamp({{ epochs }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.480972, + "supported_languages": null + }, + "macro.dbt_date.postgres__from_unixtimestamp": { + "unique_id": "macro.dbt_date.postgres__from_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/from_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", + "name": "postgres__from_unixtimestamp", + "macro_sql": "\n\n{%- macro postgres__from_unixtimestamp(epochs, format=\"seconds\") -%}\n {%- if format != \"seconds\" -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n cast(to_timestamp({{ epochs }}) at time zone 'UTC' as timestamp)\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.481205, + "supported_languages": null + }, + "macro.dbt_date.snowflake__from_unixtimestamp": { + "unique_id": "macro.dbt_date.snowflake__from_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/from_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", + "name": "snowflake__from_unixtimestamp", + "macro_sql": "\n\n{%- macro snowflake__from_unixtimestamp(epochs, format) -%}\n {%- if format == \"seconds\" -%}\n {%- set scale = 0 -%}\n {%- elif format == \"milliseconds\" -%}\n {%- set scale = 3 -%}\n {%- elif format == \"microseconds\" -%}\n {%- set scale = 6 -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n to_timestamp_ntz({{ epochs }}, {{ scale }})\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.481615, + "supported_languages": null + }, + "macro.dbt_date.bigquery__from_unixtimestamp": { + "unique_id": "macro.dbt_date.bigquery__from_unixtimestamp", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/from_unixtimestamp.sql", + "original_file_path": "macros/calendar_date/from_unixtimestamp.sql", + "name": "bigquery__from_unixtimestamp", + "macro_sql": "\n\n{%- macro bigquery__from_unixtimestamp(epochs, format) -%}\n {%- if format == \"seconds\" -%}\n timestamp_seconds({{ epochs }})\n {%- elif format == \"milliseconds\" -%}\n timestamp_millis({{ epochs }})\n {%- elif format == \"microseconds\" -%}\n timestamp_micros({{ epochs }})\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"value \" ~ format ~ \" for `format` for from_unixtimestamp is not supported.\"\n )\n }}\n {% endif -%}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4819598, + "supported_languages": null + }, + "macro.dbt_date.n_months_ago": { + "unique_id": "macro.dbt_date.n_months_ago", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_months_ago.sql", + "original_file_path": "macros/calendar_date/n_months_ago.sql", + "name": "n_months_ago", + "macro_sql": "{%- macro n_months_ago(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('month',\n dbt.dateadd('month', -1 * n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.date_trunc", + "macro.dbt.dateadd", + "macro.dbt_date.today" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.48235, + "supported_languages": null + }, + "macro.dbt_date.date_part": { + "unique_id": "macro.dbt_date.date_part", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/date_part.sql", + "original_file_path": "macros/calendar_date/date_part.sql", + "name": "date_part", + "macro_sql": "{% macro date_part(datepart, date) -%}\n {{ adapter.dispatch('date_part', 'dbt_date') (datepart, date) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.482671, + "supported_languages": null + }, + "macro.dbt_date.default__date_part": { + "unique_id": "macro.dbt_date.default__date_part", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/date_part.sql", + "original_file_path": "macros/calendar_date/date_part.sql", + "name": "default__date_part", + "macro_sql": "{% macro default__date_part(datepart, date) -%}\n date_part('{{ datepart }}', {{ date }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4827871, + "supported_languages": null + }, + "macro.dbt_date.bigquery__date_part": { + "unique_id": "macro.dbt_date.bigquery__date_part", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/date_part.sql", + "original_file_path": "macros/calendar_date/date_part.sql", + "name": "bigquery__date_part", + "macro_sql": "{% macro bigquery__date_part(datepart, date) -%}\n extract({{ datepart }} from {{ date }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.482903, + "supported_languages": null + }, + "macro.dbt_date.n_weeks_away": { + "unique_id": "macro.dbt_date.n_weeks_away", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_weeks_away.sql", + "original_file_path": "macros/calendar_date/n_weeks_away.sql", + "name": "n_weeks_away", + "macro_sql": "{%- macro n_weeks_away(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('week',\n dbt.dateadd('week', n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.date_trunc", + "macro.dbt.dateadd", + "macro.dbt_date.today" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.48327, + "supported_languages": null + }, + "macro.dbt_date.day_of_month": { + "unique_id": "macro.dbt_date.day_of_month", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_month.sql", + "original_file_path": "macros/calendar_date/day_of_month.sql", + "name": "day_of_month", + "macro_sql": "{%- macro day_of_month(date) -%}\n{{ dbt_date.date_part('day', date) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.483518, + "supported_languages": null + }, + "macro.dbt_date.redshift__day_of_month": { + "unique_id": "macro.dbt_date.redshift__day_of_month", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_month.sql", + "original_file_path": "macros/calendar_date/day_of_month.sql", + "name": "redshift__day_of_month", + "macro_sql": "\n\n{%- macro redshift__day_of_month(date) -%}\ncast({{ dbt_date.date_part('day', date) }} as {{ dbt.type_bigint() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.483743, + "supported_languages": null + }, + "macro.dbt_date.yesterday": { + "unique_id": "macro.dbt_date.yesterday", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/yesterday.sql", + "original_file_path": "macros/calendar_date/yesterday.sql", + "name": "yesterday", + "macro_sql": "{%- macro yesterday(date=None, tz=None) -%}\n{{ dbt_date.n_days_ago(1, date, tz) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.n_days_ago"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.484002, + "supported_languages": null + }, + "macro.dbt_date.day_of_week": { + "unique_id": "macro.dbt_date.day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "day_of_week", + "macro_sql": "{%- macro day_of_week(date, isoweek=true) -%}\n{{ adapter.dispatch('day_of_week', 'dbt_date') (date, isoweek) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.snowflake__day_of_week"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.485564, + "supported_languages": null + }, + "macro.dbt_date.default__day_of_week": { + "unique_id": "macro.dbt_date.default__day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "default__day_of_week", + "macro_sql": "\n\n{%- macro default__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (0) to Monday (1)\n when {{ dow }} = 0 then 7\n else {{ dow }}\n end\n {%- else -%}\n {{ dow }} + 1\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.485824, + "supported_languages": null + }, + "macro.dbt_date.snowflake__day_of_week": { + "unique_id": "macro.dbt_date.snowflake__day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "snowflake__day_of_week", + "macro_sql": "\n\n{%- macro snowflake__day_of_week(date, isoweek) -%}\n\n {%- if isoweek -%}\n {%- set dow_part = 'dayofweekiso' -%}\n {{ dbt_date.date_part(dow_part, date) }}\n {%- else -%}\n {%- set dow_part = 'dayofweek' -%}\n case\n when {{ dbt_date.date_part(dow_part, date) }} = 7 then 1\n else {{ dbt_date.date_part(dow_part, date) }} + 1\n end\n {%- endif -%}\n\n\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.486185, + "supported_languages": null + }, + "macro.dbt_date.bigquery__day_of_week": { + "unique_id": "macro.dbt_date.bigquery__day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "bigquery__day_of_week", + "macro_sql": "\n\n{%- macro bigquery__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (1) to Monday (2)\n when {{ dow }} = 1 then 7\n else {{ dow }} - 1\n end\n {%- else -%}\n {{ dow }}\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.date_part"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.486441, + "supported_languages": null + }, + "macro.dbt_date.postgres__day_of_week": { + "unique_id": "macro.dbt_date.postgres__day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "postgres__day_of_week", + "macro_sql": "\n\n\n{%- macro postgres__day_of_week(date, isoweek) -%}\n\n {%- if isoweek -%}\n {%- set dow_part = 'isodow' -%}\n -- Monday(1) to Sunday (7)\n cast({{ dbt_date.date_part(dow_part, date) }} as {{ dbt.type_int() }})\n {%- else -%}\n {%- set dow_part = 'dow' -%}\n -- Sunday(1) to Saturday (7)\n cast({{ dbt_date.date_part(dow_part, date) }} + 1 as {{ dbt.type_int() }})\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.486822, + "supported_languages": null + }, + "macro.dbt_date.redshift__day_of_week": { + "unique_id": "macro.dbt_date.redshift__day_of_week", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/day_of_week.sql", + "original_file_path": "macros/calendar_date/day_of_week.sql", + "name": "redshift__day_of_week", + "macro_sql": "\n\n\n{%- macro redshift__day_of_week(date, isoweek) -%}\n\n {%- set dow = dbt_date.date_part('dayofweek', date) -%}\n\n {%- if isoweek -%}\n case\n -- Shift start of week from Sunday (0) to Monday (1)\n when {{ dow }} = 0 then 7\n else cast({{ dow }} as {{ dbt.type_bigint() }})\n end\n {%- else -%}\n cast({{ dow }} + 1 as {{ dbt.type_bigint() }})\n {%- endif -%}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_bigint"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.487146, + "supported_languages": null + }, + "macro.dbt_date.iso_week_end": { + "unique_id": "macro.dbt_date.iso_week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_end.sql", + "original_file_path": "macros/calendar_date/iso_week_end.sql", + "name": "iso_week_end", + "macro_sql": "{%- macro iso_week_end(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_end', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.today", + "macro.dbt_date.snowflake__iso_week_end" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.487617, + "supported_languages": null + }, + "macro.dbt_date._iso_week_end": { + "unique_id": "macro.dbt_date._iso_week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_end.sql", + "original_file_path": "macros/calendar_date/iso_week_end.sql", + "name": "_iso_week_end", + "macro_sql": "{%- macro _iso_week_end(date, week_type) -%}\n{%- set dt = dbt_date.iso_week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.iso_week_start", + "macro.dbt_date.n_days_away" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.487803, + "supported_languages": null + }, + "macro.dbt_date.default__iso_week_end": { + "unique_id": "macro.dbt_date.default__iso_week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_end.sql", + "original_file_path": "macros/calendar_date/iso_week_end.sql", + "name": "default__iso_week_end", + "macro_sql": "\n\n{%- macro default__iso_week_end(date) -%}\n{{ dbt_date._iso_week_end(date, 'isoweek') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_end"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.487923, + "supported_languages": null + }, + "macro.dbt_date.snowflake__iso_week_end": { + "unique_id": "macro.dbt_date.snowflake__iso_week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_end.sql", + "original_file_path": "macros/calendar_date/iso_week_end.sql", + "name": "snowflake__iso_week_end", + "macro_sql": "\n\n{%- macro snowflake__iso_week_end(date) -%}\n{{ dbt_date._iso_week_end(date, 'weekiso') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_end"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4880419, + "supported_languages": null + }, + "macro.dbt_date.n_weeks_ago": { + "unique_id": "macro.dbt_date.n_weeks_ago", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_weeks_ago.sql", + "original_file_path": "macros/calendar_date/n_weeks_ago.sql", + "name": "n_weeks_ago", + "macro_sql": "{%- macro n_weeks_ago(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('week',\n dbt.dateadd('week', -1 * n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.date_trunc", + "macro.dbt.dateadd", + "macro.dbt_date.today" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.488433, + "supported_languages": null + }, + "macro.dbt_date.month_name": { + "unique_id": "macro.dbt_date.month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/month_name.sql", + "original_file_path": "macros/calendar_date/month_name.sql", + "name": "month_name", + "macro_sql": "{%- macro month_name(date, short=True) -%}\n {{ adapter.dispatch('month_name', 'dbt_date') (date, short) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.snowflake__month_name"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4889128, + "supported_languages": null + }, + "macro.dbt_date.default__month_name": { + "unique_id": "macro.dbt_date.default__month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/month_name.sql", + "original_file_path": "macros/calendar_date/month_name.sql", + "name": "default__month_name", + "macro_sql": "\n\n{%- macro default__month_name(date, short) -%}\n{%- set f = 'MON' if short else 'MONTH' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.489092, + "supported_languages": null + }, + "macro.dbt_date.bigquery__month_name": { + "unique_id": "macro.dbt_date.bigquery__month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/month_name.sql", + "original_file_path": "macros/calendar_date/month_name.sql", + "name": "bigquery__month_name", + "macro_sql": "\n\n{%- macro bigquery__month_name(date, short) -%}\n{%- set f = '%b' if short else '%B' -%}\n format_date('{{ f }}', cast({{ date }} as date))\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.489274, + "supported_languages": null + }, + "macro.dbt_date.snowflake__month_name": { + "unique_id": "macro.dbt_date.snowflake__month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/month_name.sql", + "original_file_path": "macros/calendar_date/month_name.sql", + "name": "snowflake__month_name", + "macro_sql": "\n\n{%- macro snowflake__month_name(date, short) -%}\n{%- set f = 'MON' if short else 'MMMM' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4894469, + "supported_languages": null + }, + "macro.dbt_date.postgres__month_name": { + "unique_id": "macro.dbt_date.postgres__month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/month_name.sql", + "original_file_path": "macros/calendar_date/month_name.sql", + "name": "postgres__month_name", + "macro_sql": "\n\n{%- macro postgres__month_name(date, short) -%}\n{# FM = Fill mode, which suppresses padding blanks #}\n{%- set f = 'FMMon' if short else 'FMMonth' -%}\n to_char({{ date }}, '{{ f }}')\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.489629, + "supported_languages": null + }, + "macro.dbt_date.last_month_name": { + "unique_id": "macro.dbt_date.last_month_name", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/last_month_name.sql", + "original_file_path": "macros/calendar_date/last_month_name.sql", + "name": "last_month_name", + "macro_sql": "{%- macro last_month_name(short=True, tz=None) -%}\n{{ dbt_date.month_name(dbt_date.last_month(tz), short=short) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.month_name", "macro.dbt_date.last_month"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.489913, + "supported_languages": null + }, + "macro.dbt_date.week_of_year": { + "unique_id": "macro.dbt_date.week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_of_year.sql", + "original_file_path": "macros/calendar_date/week_of_year.sql", + "name": "week_of_year", + "macro_sql": "{%- macro week_of_year(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_of_year', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.today", + "macro.dbt_date.default__week_of_year" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.490412, + "supported_languages": null + }, + "macro.dbt_date.default__week_of_year": { + "unique_id": "macro.dbt_date.default__week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_of_year.sql", + "original_file_path": "macros/calendar_date/week_of_year.sql", + "name": "default__week_of_year", + "macro_sql": "{%- macro default__week_of_year(date) -%}\ncast({{ dbt_date.date_part('week', date) }} as {{ dbt.type_int() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.49058, + "supported_languages": null + }, + "macro.dbt_date.postgres__week_of_year": { + "unique_id": "macro.dbt_date.postgres__week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_of_year.sql", + "original_file_path": "macros/calendar_date/week_of_year.sql", + "name": "postgres__week_of_year", + "macro_sql": "\n\n{%- macro postgres__week_of_year(date) -%}\n{# postgresql 'week' returns isoweek. Use to_char instead.\n WW = the first week starts on the first day of the year #}\ncast(to_char({{ date }}, 'WW') as {{ dbt.type_int() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_int"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.490711, + "supported_languages": null + }, + "macro.dbt_date.convert_timezone": { + "unique_id": "macro.dbt_date.convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "convert_timezone", + "macro_sql": "{%- macro convert_timezone(column, target_tz=None, source_tz=None) -%}\n{%- set source_tz = \"UTC\" if not source_tz else source_tz -%}\n{%- set target_tz = var(\"dbt_date:time_zone\") if not target_tz else target_tz -%}\n{{ adapter.dispatch('convert_timezone', 'dbt_date') (column, target_tz, source_tz) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__convert_timezone"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.491602, + "supported_languages": null + }, + "macro.dbt_date.default__convert_timezone": { + "unique_id": "macro.dbt_date.default__convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "default__convert_timezone", + "macro_sql": "{% macro default__convert_timezone(column, target_tz, source_tz) -%}\nconvert_timezone('{{ source_tz }}', '{{ target_tz }}',\n cast({{ column }} as {{ dbt.type_timestamp() }})\n)\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.491783, + "supported_languages": null + }, + "macro.dbt_date.bigquery__convert_timezone": { + "unique_id": "macro.dbt_date.bigquery__convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "bigquery__convert_timezone", + "macro_sql": "{%- macro bigquery__convert_timezone(column, target_tz, source_tz=None) -%}\ntimestamp(datetime({{ column }}, '{{ target_tz}}'))\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.491916, + "supported_languages": null + }, + "macro.dbt_date.spark__convert_timezone": { + "unique_id": "macro.dbt_date.spark__convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "spark__convert_timezone", + "macro_sql": "{%- macro spark__convert_timezone(column, target_tz, source_tz) -%}\nfrom_utc_timestamp(\n to_utc_timestamp({{ column }}, '{{ source_tz }}'),\n '{{ target_tz }}'\n )\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.492057, + "supported_languages": null + }, + "macro.dbt_date.postgres__convert_timezone": { + "unique_id": "macro.dbt_date.postgres__convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "postgres__convert_timezone", + "macro_sql": "{% macro postgres__convert_timezone(column, target_tz, source_tz) -%}\ncast(\n cast({{ column }} as {{ dbt.type_timestamp() }})\n at time zone '{{ source_tz }}' at time zone '{{ target_tz }}' as {{ dbt.type_timestamp() }}\n)\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_timestamp"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.492269, + "supported_languages": null + }, + "macro.dbt_date.redshift__convert_timezone": { + "unique_id": "macro.dbt_date.redshift__convert_timezone", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/convert_timezone.sql", + "original_file_path": "macros/calendar_date/convert_timezone.sql", + "name": "redshift__convert_timezone", + "macro_sql": "{%- macro redshift__convert_timezone(column, target_tz, source_tz) -%}\n{{ return(dbt_date.default__convert_timezone(column, target_tz, source_tz)) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date.default__convert_timezone"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4924428, + "supported_languages": null + }, + "macro.dbt_date.n_months_away": { + "unique_id": "macro.dbt_date.n_months_away", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/n_months_away.sql", + "original_file_path": "macros/calendar_date/n_months_away.sql", + "name": "n_months_away", + "macro_sql": "{%- macro n_months_away(n, tz=None) -%}\n{%- set n = n|int -%}\n{{ dbt.date_trunc('month',\n dbt.dateadd('month', n,\n dbt_date.today(tz)\n )\n ) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.date_trunc", + "macro.dbt.dateadd", + "macro.dbt_date.today" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4928231, + "supported_languages": null + }, + "macro.dbt_date.iso_week_of_year": { + "unique_id": "macro.dbt_date.iso_week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_of_year.sql", + "original_file_path": "macros/calendar_date/iso_week_of_year.sql", + "name": "iso_week_of_year", + "macro_sql": "{%- macro iso_week_of_year(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('iso_week_of_year', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_date.today", + "macro.dbt_date.snowflake__iso_week_of_year" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.493365, + "supported_languages": null + }, + "macro.dbt_date._iso_week_of_year": { + "unique_id": "macro.dbt_date._iso_week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_of_year.sql", + "original_file_path": "macros/calendar_date/iso_week_of_year.sql", + "name": "_iso_week_of_year", + "macro_sql": "{%- macro _iso_week_of_year(date, week_type) -%}\ncast({{ dbt_date.date_part(week_type, date) }} as {{ dbt.type_int() }})\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt.type_int"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.493539, + "supported_languages": null + }, + "macro.dbt_date.default__iso_week_of_year": { + "unique_id": "macro.dbt_date.default__iso_week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_of_year.sql", + "original_file_path": "macros/calendar_date/iso_week_of_year.sql", + "name": "default__iso_week_of_year", + "macro_sql": "\n\n{%- macro default__iso_week_of_year(date) -%}\n{{ dbt_date._iso_week_of_year(date, 'isoweek') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_of_year"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.493663, + "supported_languages": null + }, + "macro.dbt_date.snowflake__iso_week_of_year": { + "unique_id": "macro.dbt_date.snowflake__iso_week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_of_year.sql", + "original_file_path": "macros/calendar_date/iso_week_of_year.sql", + "name": "snowflake__iso_week_of_year", + "macro_sql": "\n\n{%- macro snowflake__iso_week_of_year(date) -%}\n{{ dbt_date._iso_week_of_year(date, 'weekiso') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_of_year"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4937851, + "supported_languages": null + }, + "macro.dbt_date.postgres__iso_week_of_year": { + "unique_id": "macro.dbt_date.postgres__iso_week_of_year", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/iso_week_of_year.sql", + "original_file_path": "macros/calendar_date/iso_week_of_year.sql", + "name": "postgres__iso_week_of_year", + "macro_sql": "\n\n{%- macro postgres__iso_week_of_year(date) -%}\n-- postgresql week is isoweek, the first week of a year containing January 4 of that year.\n{{ dbt_date._iso_week_of_year(date, 'week') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_date._iso_week_of_year"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4939141, + "supported_languages": null + }, + "macro.dbt_date.week_end": { + "unique_id": "macro.dbt_date.week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_end.sql", + "original_file_path": "macros/calendar_date/week_end.sql", + "name": "week_end", + "macro_sql": "{%- macro week_end(date=None, tz=None) -%}\n{%-set dt = date if date else dbt_date.today(tz) -%}\n{{ adapter.dispatch('week_end', 'dbt_date') (dt) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.today", "macro.dbt_date.snowflake__week_end"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.49439, + "supported_languages": null + }, + "macro.dbt_date.default__week_end": { + "unique_id": "macro.dbt_date.default__week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_end.sql", + "original_file_path": "macros/calendar_date/week_end.sql", + "name": "default__week_end", + "macro_sql": "{%- macro default__week_end(date) -%}\n{{ last_day(date, 'week') }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.last_day"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.494515, + "supported_languages": null + }, + "macro.dbt_date.snowflake__week_end": { + "unique_id": "macro.dbt_date.snowflake__week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_end.sql", + "original_file_path": "macros/calendar_date/week_end.sql", + "name": "snowflake__week_end", + "macro_sql": "\n\n{%- macro snowflake__week_end(date) -%}\n{%- set dt = dbt_date.week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.week_start", "macro.dbt_date.n_days_away"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.49469, + "supported_languages": null + }, + "macro.dbt_date.postgres__week_end": { + "unique_id": "macro.dbt_date.postgres__week_end", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/week_end.sql", + "original_file_path": "macros/calendar_date/week_end.sql", + "name": "postgres__week_end", + "macro_sql": "\n\n{%- macro postgres__week_end(date) -%}\n{%- set dt = dbt_date.week_start(date) -%}\n{{ dbt_date.n_days_away(6, dt) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.week_start", "macro.dbt_date.n_days_away"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.49487, + "supported_languages": null + }, + "macro.dbt_date.next_month_number": { + "unique_id": "macro.dbt_date.next_month_number", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/next_month_number.sql", + "original_file_path": "macros/calendar_date/next_month_number.sql", + "name": "next_month_number", + "macro_sql": "{%- macro next_month_number(tz=None) -%}\n{{ dbt_date.date_part('month', dbt_date.next_month(tz)) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt_date.next_month"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.4951239, + "supported_languages": null + }, + "macro.dbt_date.last_month_number": { + "unique_id": "macro.dbt_date.last_month_number", + "package_name": "dbt_date", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_date", + "path": "macros/calendar_date/last_month_number.sql", + "original_file_path": "macros/calendar_date/last_month_number.sql", + "name": "last_month_number", + "macro_sql": "{%- macro last_month_number(tz=None) -%}\n{{ dbt_date.date_part('month', dbt_date.last_month(tz)) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_date.date_part", "macro.dbt_date.last_month"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.495372, + "supported_languages": null + }, + "macro.dbt_external_tables.bigquery__create_external_table": { + "unique_id": "macro.dbt_external_tables.bigquery__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/bigquery/create_external_table.sql", + "original_file_path": "macros/plugins/bigquery/create_external_table.sql", + "name": "bigquery__create_external_table", + "macro_sql": "{% macro bigquery__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n {%- set options = external.options -%}\n \n {%- set uris = [] -%}\n {%- if options is mapping and options.get('uris', none) -%}\n {%- set uris = external.options.get('uris') -%}\n {%- else -%}\n {%- set uris = [external.location] -%}\n {%- endif -%}\n\n create or replace external table {{source(source_node.source_name, source_node.name)}}\n {%- if columns -%}(\n {% for column in columns %}\n {%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %}\n {{column_quoted}} {{column.data_type}} {{- ',' if not loop.last -}}\n {%- endfor -%}\n )\n {% endif %}\n {% if options and options.get('hive_partition_uri_prefix', none) %}\n with partition columns {%- if partitions %} (\n {%- for partition in partitions %}\n {{partition.name}} {{partition.data_type}}{{',' if not loop.last}}\n {%- endfor -%}\n ) {% endif -%}\n {% endif %}\n options (\n uris = [{%- for uri in uris -%} '{{uri}}' {{- \",\" if not loop.last}} {%- endfor -%}]\n {%- if options is mapping -%}\n {%- for key, value in options.items() if key != 'uris' %}\n {%- if value is string -%}\n , {{key}} = '{{value}}'\n {%- else -%}\n , {{key}} = {{value}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.498086, + "supported_languages": null + }, + "macro.dbt_external_tables.bigquery__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.bigquery__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/bigquery/get_external_build_plan.sql", + "original_file_path": "macros/plugins/bigquery/get_external_build_plan.sql", + "name": "bigquery__get_external_build_plan", + "macro_sql": "{% macro bigquery__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n \n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [dbt_external_tables.create_external_table(source_node)] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.create_external_table", + "macro.dbt_external_tables.refresh_external_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.498924, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake__create_external_table": { + "unique_id": "macro.dbt_external_tables.snowflake__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/create_external_table.sql", + "original_file_path": "macros/plugins/snowflake/create_external_table.sql", + "name": "snowflake__create_external_table", + "macro_sql": "{% macro snowflake__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n\n {%- set is_csv = dbt_external_tables.is_csv(external.file_format) -%}\n\n{# https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html #}\n{# This assumes you have already created an external stage #}\n create or replace external table {{source(source_node.source_name, source_node.name)}}\n {%- if columns or partitions -%}\n (\n {%- if partitions -%}{%- for partition in partitions %}\n {{partition.name}} {{partition.data_type}} as {{partition.expression}}{{- ',' if not loop.last or columns|length > 0 -}}\n {%- endfor -%}{%- endif -%}\n {%- for column in columns %}\n {%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %}\n {%- set col_expression -%}\n {%- set col_id = 'value:c' ~ loop.index if is_csv else 'value:' ~ column_quoted -%}\n (case when is_null_value({{col_id}}) or lower({{col_id}}) = 'null' then null else {{col_id}} end)\n {%- endset %}\n {{column_quoted}} {{column.data_type}} as ({{col_expression}}::{{column.data_type}})\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n {%- endif -%}\n {% if partitions %} partition by ({{partitions|map(attribute='name')|join(', ')}}) {% endif %}\n location = {{external.location}} {# stage #}\n {% if external.auto_refresh in (true, false) -%}\n auto_refresh = {{external.auto_refresh}}\n {%- endif %}\n {% if external.pattern -%} pattern = '{{external.pattern}}' {%- endif %}\n {% if external.integration -%} integration = '{{external.integration}}' {%- endif %}\n file_format = {{external.file_format}}\n {% if external.table_format -%} table_format = '{{external.table_format}}' {%- endif %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_external_tables.is_csv"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.501194, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake__refresh_external_table": { + "unique_id": "macro.dbt_external_tables.snowflake__refresh_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/refresh_external_table.sql", + "original_file_path": "macros/plugins/snowflake/refresh_external_table.sql", + "name": "snowflake__refresh_external_table", + "macro_sql": "{% macro snowflake__refresh_external_table(source_node) %}\n\n {% set external = source_node.external %}\n {% set snowpipe = source_node.external.get('snowpipe', none) %}\n \n {% set auto_refresh = external.get('auto_refresh', false) %}\n {% set partitions = external.get('partitions', none) %}\n \n {% set manual_refresh = (partitions and not auto_refresh) %}\n \n {% if manual_refresh %}\n\n {% set ddl %}\n begin;\n alter external table {{source(source_node.source_name, source_node.name)}} refresh;\n commit;\n {% endset %}\n \n {% do return([ddl]) %}\n \n {% else %}\n \n {% do return([]) %}\n \n {% endif %}\n \n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.502136, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.snowflake__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/get_external_build_plan.sql", + "original_file_path": "macros/plugins/snowflake/get_external_build_plan.sql", + "name": "snowflake__get_external_build_plan", + "macro_sql": "{% macro snowflake__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n \n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if source_node.external.get('snowpipe', none) is not none %}\n \n {% if create_or_replace %}\n {% set build_plan = build_plan + [\n dbt_external_tables.snowflake_create_empty_table(source_node),\n dbt_external_tables.snowflake_get_copy_sql(source_node, explicit_transaction=true),\n dbt_external_tables.snowflake_create_snowpipe(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.snowflake_refresh_snowpipe(source_node) %}\n {% endif %}\n \n {% else %}\n \n {% if create_or_replace %}\n {% set build_plan = build_plan + [dbt_external_tables.create_external_table(source_node)] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n \n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.snowflake_create_empty_table", + "macro.dbt_external_tables.snowflake_get_copy_sql", + "macro.dbt_external_tables.snowflake_create_snowpipe", + "macro.dbt_external_tables.snowflake_refresh_snowpipe", + "macro.dbt_external_tables.create_external_table", + "macro.dbt_external_tables.refresh_external_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.503582, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake_create_snowpipe": { + "unique_id": "macro.dbt_external_tables.snowflake_create_snowpipe", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/snowpipe/create_snowpipe.sql", + "original_file_path": "macros/plugins/snowflake/snowpipe/create_snowpipe.sql", + "name": "snowflake_create_snowpipe", + "macro_sql": "{% macro snowflake_create_snowpipe(source_node) %}\n\n {%- set external = source_node.external -%}\n {%- set snowpipe = external.snowpipe -%}\n\n{# https://docs.snowflake.com/en/sql-reference/sql/create-pipe.html #}\n create or replace pipe {{source(source_node.source_name, source_node.name)}}\n {% if snowpipe.auto_ingest -%} auto_ingest = {{snowpipe.auto_ingest}} {%- endif %}\n {% if snowpipe.aws_sns_topic -%} aws_sns_topic = '{{snowpipe.aws_sns_topic}}' {%- endif %}\n {% if snowpipe.integration -%} integration = '{{snowpipe.integration}}' {%- endif %}\n {% if snowpipe.error_integration -%} error_integration = '{{snowpipe.error_integration}}' {%- endif %}\n as {{ dbt_external_tables.snowflake_get_copy_sql(source_node) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_external_tables.snowflake_get_copy_sql"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5043871, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake_create_empty_table": { + "unique_id": "macro.dbt_external_tables.snowflake_create_empty_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/snowpipe/create_empty_table.sql", + "original_file_path": "macros/plugins/snowflake/snowpipe/create_empty_table.sql", + "name": "snowflake_create_empty_table", + "macro_sql": "{% macro snowflake_create_empty_table(source_node) %}\n\n {%- set columns = source_node.columns.values() %}\n\n create or replace table {{source(source_node.source_name, source_node.name)}} (\n {% if columns|length == 0 %}\n value variant,\n {% else -%}\n {%- for column in columns -%}\n {{column.name}} {{column.data_type}},\n {% endfor -%}\n {% endif %}\n metadata_filename varchar,\n metadata_file_row_number bigint,\n _dbt_copied_at timestamp\n );\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.504964, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake_refresh_snowpipe": { + "unique_id": "macro.dbt_external_tables.snowflake_refresh_snowpipe", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/snowpipe/refresh_snowpipe.sql", + "original_file_path": "macros/plugins/snowflake/snowpipe/refresh_snowpipe.sql", + "name": "snowflake_refresh_snowpipe", + "macro_sql": "{% macro snowflake_refresh_snowpipe(source_node) %}\n\n {% set snowpipe = source_node.external.snowpipe %}\n {% set auto_ingest = snowpipe.get('auto_ingest', false) if snowpipe is mapping %}\n \n {% if auto_ingest is true %}\n \n {% do return([]) %}\n \n {% else %}\n \n {% set ddl %}\n alter pipe {{source(source_node.source_name, source_node.name)}} refresh\n {% endset %}\n \n {{ return([ddl]) }}\n \n {% endif %}\n \n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5056498, + "supported_languages": null + }, + "macro.dbt_external_tables.snowflake_get_copy_sql": { + "unique_id": "macro.dbt_external_tables.snowflake_get_copy_sql", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/snowpipe/get_copy_sql.sql", + "original_file_path": "macros/plugins/snowflake/snowpipe/get_copy_sql.sql", + "name": "snowflake_get_copy_sql", + "macro_sql": "{% macro snowflake_get_copy_sql(source_node, explicit_transaction=false) %}\n{# This assumes you have already created an external stage #}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set is_csv = dbt_external_tables.is_csv(external.file_format) %}\n {%- set copy_options = external.snowpipe.get('copy_options', none) -%}\n \n {%- if explicit_transaction -%} begin; {%- endif %}\n \n copy into {{source(source_node.source_name, source_node.name)}}\n from ( \n select\n {% if columns|length == 0 %}\n $1::variant as value,\n {% else -%}\n {%- for column in columns -%}\n {%- set col_expression -%}\n {%- if is_csv -%}nullif(${{loop.index}},''){# special case: get columns by ordinal position #}\n {%- else -%}nullif($1:{{column.name}},''){# standard behavior: get columns by name #}\n {%- endif -%}\n {%- endset -%}\n {{col_expression}}::{{column.data_type}} as {{column.name}},\n {% endfor -%}\n {% endif %}\n metadata$filename::varchar as metadata_filename,\n metadata$file_row_number::bigint as metadata_file_row_number,\n current_timestamp::timestamp as _dbt_copied_at\n from {{external.location}} {# stage #}\n )\n file_format = {{external.file_format}}\n {% if external.pattern -%} pattern = '{{external.pattern}}' {%- endif %}\n {% if copy_options %} {{copy_options}} {% endif %};\n \n {% if explicit_transaction -%} commit; {%- endif -%}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_external_tables.is_csv"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.507071, + "supported_languages": null + }, + "macro.dbt_external_tables.is_csv": { + "unique_id": "macro.dbt_external_tables.is_csv", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/snowflake/helpers/is_csv.sql", + "original_file_path": "macros/plugins/snowflake/helpers/is_csv.sql", + "name": "is_csv", + "macro_sql": "{% macro is_csv(file_format) %}\n\n{# From https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html:\n\nImportant: The external table does not inherit the file format, if any, in the \nstage definition. You must explicitly specify any file format options for the \nexternal table using the FILE_FORMAT parameter.\n\nNote: FORMAT_NAME and TYPE are mutually exclusive; to avoid unintended behavior, \nyou should only specify one or the other when creating an external table.\n\n#}\n\n {% set ff_ltrimmed = file_format|lower|replace(' ','') %}\n\n {% if 'type=' in ff_ltrimmed %}\n \n {% if 'type=csv' in ff_ltrimmed %}\n\n {{return(true)}}\n\n {% else %}\n\n {{return(false)}}\n \n {% endif %}\n \n {% else %}\n \n {% set ff_standardized = ff_ltrimmed\n | replace('(','') | replace(')','')\n | replace('format_name=','') %}\n {% set fqn = ff_standardized.split('.') %}\n \n {% if fqn | length == 3 %}\n {% set ff_database, ff_schema, ff_identifier = fqn[0], fqn[1], fqn[2] %}\n {% elif fqn | length == 2 %}\n {% set ff_database, ff_schema, ff_identifier = target.database, fqn[0], fqn[1] %}\n {% else %}\n {% set ff_database, ff_schema, ff_identifier = target.database, target.schema, fqn[0] %}\n {% endif %}\n \n {% call statement('get_file_format', fetch_result = True) %}\n show file formats in {{ff_database}}.{{ff_schema}}\n {% endcall %}\n \n {% set ffs = load_result('get_file_format').table %}\n \n {% for ff in ffs %}\n \n {% if ff['name']|lower == ff_identifier and ff['type']|lower == 'csv' %}\n \n {{return(true)}}\n \n {% endif %}\n \n {% endfor %}\n \n {{return(false)}} \n \n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.statement"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.509557, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift__create_external_table": { + "unique_id": "macro.dbt_external_tables.redshift__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/create_external_table.sql", + "original_file_path": "macros/plugins/redshift/create_external_table.sql", + "name": "redshift__create_external_table", + "macro_sql": "{% macro redshift__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n\n{# https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_TABLE.html #}\n{# This assumes you have already created an external schema #}\n\n create external table {{source(source_node.source_name, source_node.name)}} (\n {% for column in columns %}\n {{adapter.quote(column.name)}} {{column.data_type}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n {% if partitions -%} partitioned by (\n {%- for partition in partitions -%}\n {{adapter.quote(partition.name)}} {{partition.data_type}}{{', ' if not loop.last}}\n {%- endfor -%}\n ) {%- endif %}\n {% if external.row_format -%} row format {{external.row_format}} {%- endif %}\n {% if external.file_format -%} stored as {{external.file_format}} {%- endif %}\n {% if external.location -%} location '{{external.location}}' {%- endif %}\n {% if external.table_properties -%} table properties {{external.table_properties}} {%- endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.510957, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift__refresh_external_table": { + "unique_id": "macro.dbt_external_tables.redshift__refresh_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/refresh_external_table.sql", + "original_file_path": "macros/plugins/redshift/refresh_external_table.sql", + "name": "redshift__refresh_external_table", + "macro_sql": "{% macro redshift__refresh_external_table(source_node) %}\n\n {%- set partitions = source_node.external.get('partitions',[]) -%}\n\n {%- if partitions -%}\n \n {%- set part_len = partitions|length -%}\n \n {%- set get_partitions_sql -%}\n \n select * from\n \n {%- for partition in partitions %} (\n \n {%- set part_num = loop.index -%}\n \n {%- if partition.vals.macro -%}\n {%- set vals = dbt_external_tables.render_from_context(partition.vals.macro, **partition.vals.args) -%}\n {%- elif partition.vals is string -%}\n {%- set vals = [partition.vals] -%}\n {%- else -%}\n {%- set vals = partition.vals -%}\n {%- endif -%}\n \n {%- for val in vals %}\n \n select\n '\"{{ partition.name }}\"' as name_{{ part_num }},\n '\"{{ val }}\"' as val_{{ part_num }},\n '\"{{ dbt_external_tables.render_from_context(partition.path_macro, partition.name, val) }}\"' as path_{{ part_num }}\n \n {{ 'union all' if not loop.last else ') ' }}\n \n {%- endfor -%}\n \n {{ 'cross join' if not loop.last }}\n \n {%- endfor -%}\n \n {%- endset -%}\n \n {%- set finals = [] -%}\n \n {%- if execute -%}\n {%- set results = run_query(get_partitions_sql) -%}\n {%- for row in results -%}\n \n {%- set partition_parts = [] -%}\n {%- set path_parts = [] -%}\n \n {%- for i in range(0, part_len) -%}\n {%- do partition_parts.append({\n 'name': row[i * 3][1:-1],\n 'value': row[i * 3 + 1][1:-1]\n }) -%}\n {%- do path_parts.append(row[i * 3 + 2][1:-1]) -%}\n {%- endfor -%}\n \n {%- set construct = {\n 'partition_by': partition_parts,\n 'path': path_parts | join('/')\n } -%}\n \n {% do finals.append(construct) %}\n {%- endfor -%}\n {%- endif -%}\n \n {%- set ddl = dbt_external_tables.redshift_alter_table_add_partitions(source_node, finals) -%}\n {{ return(ddl) }}\n \n {% else %}\n \n {% do return([]) %}\n \n {% endif %}\n \n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.render_from_context", + "macro.dbt.run_query", + "macro.dbt_external_tables.redshift_alter_table_add_partitions" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.515245, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.redshift__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/get_external_build_plan.sql", + "original_file_path": "macros/plugins/redshift/get_external_build_plan.sql", + "name": "redshift__get_external_build_plan", + "macro_sql": "{% macro redshift__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n \n {% set create_or_replace = (var('ext_full_refresh', false) or not redshift_is_ext_tbl(source_node)) %}\n \n {% if create_or_replace %}\n\n {% set build_plan = [\n dbt_external_tables.dropif(source_node),\n dbt_external_tables.create_external_table(source_node)\n ] + dbt_external_tables.refresh_external_table(source_node) \n %}\n \n {% else %}\n \n {% set build_plan = dbt_external_tables.refresh_external_table(source_node) %}\n \n {% endif %}\n \n {% do return(build_plan) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.redshift_is_ext_tbl", + "macro.dbt_external_tables.dropif", + "macro.dbt_external_tables.create_external_table", + "macro.dbt_external_tables.refresh_external_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5159948, + "supported_languages": null + }, + "macro.dbt_external_tables.render_from_context": { + "unique_id": "macro.dbt_external_tables.render_from_context", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/render_macro.sql", + "original_file_path": "macros/plugins/redshift/helpers/render_macro.sql", + "name": "render_from_context", + "macro_sql": "{% macro render_from_context(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called by macro '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n \n {{ return(package_context[name](*varargs, **kwargs)) }}\n\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.517011, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift__dropif": { + "unique_id": "macro.dbt_external_tables.redshift__dropif", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/dropif.sql", + "original_file_path": "macros/plugins/redshift/helpers/dropif.sql", + "name": "redshift__dropif", + "macro_sql": "{% macro redshift__dropif(node) %}\n \n {% set ddl %}\n drop table if exists {{source(node.source_name, node.name)}} cascade\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5173419, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift_alter_table_add_partitions": { + "unique_id": "macro.dbt_external_tables.redshift_alter_table_add_partitions", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/add_partitions.sql", + "original_file_path": "macros/plugins/redshift/helpers/add_partitions.sql", + "name": "redshift_alter_table_add_partitions", + "macro_sql": "{% macro redshift_alter_table_add_partitions(source_node, partitions) %}\n\n {{ log(\"Generating ADD PARTITION statement for partition set between \" \n ~ partitions[0]['path'] ~ \" and \" ~ (partitions|last)['path']) }}\n\n {% set ddl = [] %}\n \n {% if partitions|length > 0 %}\n \n {% set alter_table_add %}\n alter table {{source(source_node.source_name, source_node.name)}} add if not exists \n {% endset %}\n \n {%- set alters -%}\n\n {{ alter_table_add }}\n\n {%- for partition in partitions -%}\n\n {%- if loop.index0 != 0 and loop.index0 % 100 == 0 -%}\n\n ; {{ alter_table_add }}\n\n {%- endif -%}\n\n partition ({%- for part in partition.partition_by -%}{{ part.name }}='{{ part.value }}'{{', ' if not loop.last}}{%- endfor -%})\n location '{{ source_node.external.location }}/{{ partition.path }}/'\n\n {% endfor -%}\n \n {%- endset -%}\n \n {% set ddl = ddl + alters.split(';') %}\n\n {% else %}\n\n {{ log(\"No partitions to be added\") }}\n\n {% endif %}\n \n {% do return(ddl) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.518868, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift__exit_transaction": { + "unique_id": "macro.dbt_external_tables.redshift__exit_transaction", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/transaction.sql", + "original_file_path": "macros/plugins/redshift/helpers/transaction.sql", + "name": "redshift__exit_transaction", + "macro_sql": "{% macro redshift__exit_transaction() %}\n {{ return('begin; commit;') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.519074, + "supported_languages": null + }, + "macro.dbt_external_tables.year_month_day": { + "unique_id": "macro.dbt_external_tables.year_month_day", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/paths.sql", + "original_file_path": "macros/plugins/redshift/helpers/paths.sql", + "name": "year_month_day", + "macro_sql": "{% macro year_month_day(name, value) %}\n {% set path = value.replace('-','/') %}\n {{return(path)}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.replace"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.519433, + "supported_languages": null + }, + "macro.dbt_external_tables.key_value": { + "unique_id": "macro.dbt_external_tables.key_value", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/paths.sql", + "original_file_path": "macros/plugins/redshift/helpers/paths.sql", + "name": "key_value", + "macro_sql": "{% macro key_value(name, value) %}\n {% set path = name ~ '=' ~ value %}\n {{return(path)}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.519607, + "supported_languages": null + }, + "macro.dbt_external_tables.value_only": { + "unique_id": "macro.dbt_external_tables.value_only", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/paths.sql", + "original_file_path": "macros/plugins/redshift/helpers/paths.sql", + "name": "value_only", + "macro_sql": "{% macro value_only(name, value) %}\n {% set path = value %}\n {{return(path)}}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.519756, + "supported_languages": null + }, + "macro.dbt_external_tables.redshift_is_ext_tbl": { + "unique_id": "macro.dbt_external_tables.redshift_is_ext_tbl", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/redshift/helpers/is_ext_tbl.sql", + "original_file_path": "macros/plugins/redshift/helpers/is_ext_tbl.sql", + "name": "redshift_is_ext_tbl", + "macro_sql": "{% macro redshift_is_ext_tbl(node) %}\n\n {% set existing_relation = load_relation(node) %}\n \n {# external tables don't appear in information_schema.tables,\n so dbt doesn't cache them #}\n {% if existing_relation is none %}\n\n {% set find_ext_tbl %}\n \n select count(*) from svv_external_tables\n where schemaname = '{{node.schema}}'\n and tablename = '{{node.identifier}}'\n \n {% endset %}\n \n {% if execute %}\n {% set result = run_query(find_ext_tbl)[0][0] %}\n {% else %}\n {% set result = 0 %}\n {% endif %}\n\n {% set is_ext_tbl = (result > 0) %}\n {% do return(is_ext_tbl) %}\n \n {% else %}\n \n {% do return(false) %}\n \n {% endif %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt.load_relation", "macro.dbt.run_query"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.520683, + "supported_languages": null + }, + "macro.dbt_external_tables.sqlserver__create_external_table": { + "unique_id": "macro.dbt_external_tables.sqlserver__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/sqlserver/create_external_table.sql", + "original_file_path": "macros/plugins/sqlserver/create_external_table.sql", + "name": "sqlserver__create_external_table", + "macro_sql": "{% macro sqlserver__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n\n {% if external.ansi_nulls is true -%} SET ANSI_NULLS ON; {%- endif %}\n {% if external.quoted_identifier is true -%} SET QUOTED_IDENTIFIER ON; {%- endif %}\n\n create external table {{source(source_node.source_name, source_node.name)}} (\n {% for column in columns %}\n {# TODO set nullity based on schema tests?? #}\n {%- set nullity = 'NOT NULL' if 'not_null' in columns.tests else 'NULL'-%}\n {{adapter.quote(column.name)}} {{column.data_type}} {{nullity}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n )\n WITH (\n {# remove keys that are None (i.e. not defined for a given source) #}\n {%- for key, value in external.items() if value is not none and key not in ['ansi_nulls', 'quoted_identifier'] -%}\n {{key}} = \n {%- if key in [\"location\", \"schema_name\", \"object_name\"] -%}\n '{{value}}'\n {% elif key in [\"data_source\",\"file_format\"] -%}\n [{{value}}]\n {% else -%}\n {{value}}\n {%- endif -%}\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n )\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5221262, + "supported_languages": null + }, + "macro.dbt_external_tables.sqlserver__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.sqlserver__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/sqlserver/get_external_build_plan.sql", + "original_file_path": "macros/plugins/sqlserver/get_external_build_plan.sql", + "name": "sqlserver__get_external_build_plan", + "macro_sql": "{% macro sqlserver__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n\n {% set old_relation = adapter.get_relation(\n database = source_node.database,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n\n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [ \n dbt_external_tables.dropif(source_node), \n dbt_external_tables.create_external_table(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n {% do return(build_plan) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.dropif", + "macro.dbt_external_tables.create_external_table", + "macro.dbt_external_tables.refresh_external_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.522979, + "supported_languages": null + }, + "macro.dbt_external_tables.sqlserver__dropif": { + "unique_id": "macro.dbt_external_tables.sqlserver__dropif", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/sqlserver/helpers/dropif.sql", + "original_file_path": "macros/plugins/sqlserver/helpers/dropif.sql", + "name": "sqlserver__dropif", + "macro_sql": "{% macro sqlserver__dropif(node) %}\n \n {% set ddl %}\n if object_id ('{{source(node.source_name, node.name)}}') is not null\n begin\n drop external table {{source(node.source_name, node.name)}}\n end\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.523391, + "supported_languages": null + }, + "macro.dbt_external_tables.spark__create_external_table": { + "unique_id": "macro.dbt_external_tables.spark__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/create_external_table.sql", + "original_file_path": "macros/plugins/spark/create_external_table.sql", + "name": "spark__create_external_table", + "macro_sql": "{% macro spark__create_external_table(source_node) %}\n\n {%- set columns = source_node.columns.values() -%}\n {%- set external = source_node.external -%}\n {%- set partitions = external.partitions -%}\n {%- set options = external.options -%}\n\n{# https://spark.apache.org/docs/latest/sql-data-sources-hive-tables.html #}\n create table {{source(source_node.source_name, source_node.name)}} \n {%- if columns|length > 0 %} (\n {% for column in columns %}\n {{column.name}} {{column.data_type}}\n {{- ',' if not loop.last -}}\n {% endfor %}\n ) {% endif -%}\n {% if external.using %} using {{external.using}} {%- endif %}\n {% if options -%} options (\n {%- for key, value in options.items() -%}\n '{{ key }}' = '{{value}}' {{- ', \\n' if not loop.last -}}\n {%- endfor -%}\n ) {%- endif %}\n {% if partitions -%} partitioned by (\n {%- for partition in partitions -%}\n {{partition.name}} {{partition.data_type}}{{', ' if not loop.last}}\n {%- endfor -%}\n ) {%- endif %}\n {% if external.row_format -%} row format {{external.row_format}} {%- endif %}\n {% if external.file_format -%} stored as {{external.file_format}} {%- endif %}\n {% if external.location -%} location '{{external.location}}' {%- endif %}\n {% if external.table_properties -%} tblproperties {{ external.table_properties }} {%- endif -%}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.525358, + "supported_languages": null + }, + "macro.dbt_external_tables.spark__refresh_external_table": { + "unique_id": "macro.dbt_external_tables.spark__refresh_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/refresh_external_table.sql", + "original_file_path": "macros/plugins/spark/refresh_external_table.sql", + "name": "spark__refresh_external_table", + "macro_sql": "{% macro spark__refresh_external_table(source_node) %}\n \n {% set refresh %}\n refresh table {{source(source_node.source_name, source_node.name)}}\n {% endset %}\n \n {% do return([refresh]) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.525719, + "supported_languages": null + }, + "macro.dbt_external_tables.spark__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.spark__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/get_external_build_plan.sql", + "original_file_path": "macros/plugins/spark/get_external_build_plan.sql", + "name": "spark__get_external_build_plan", + "macro_sql": "{% macro spark__get_external_build_plan(source_node) %}\n\n {% set build_plan = [] %}\n\n {% set old_relation = adapter.get_relation(\n database = none,\n schema = source_node.schema,\n identifier = source_node.identifier\n ) %}\n\n {% set create_or_replace = (old_relation is none or var('ext_full_refresh', false)) %}\n\n {% if create_or_replace %}\n {% set build_plan = build_plan + [\n dbt_external_tables.dropif(source_node), \n dbt_external_tables.create_external_table(source_node)\n ] %}\n {% else %}\n {% set build_plan = build_plan + dbt_external_tables.refresh_external_table(source_node) %}\n {% endif %}\n\n {% set recover_partitions = dbt_external_tables.recover_partitions(source_node) %}\n {% if recover_partitions %}\n {% set build_plan = build_plan + [\n recover_partitions\n ] %}\n {% endif %}\n\n {% do return(build_plan) %}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.dropif", + "macro.dbt_external_tables.create_external_table", + "macro.dbt_external_tables.refresh_external_table", + "macro.dbt_external_tables.recover_partitions" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5267892, + "supported_languages": null + }, + "macro.dbt_external_tables.spark__recover_partitions": { + "unique_id": "macro.dbt_external_tables.spark__recover_partitions", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/helpers/recover_partitions.sql", + "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", + "name": "spark__recover_partitions", + "macro_sql": "{% macro spark__recover_partitions(source_node) %}\n {# https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-alter-table.html #}\n\n {%- if source_node.external.partitions and source_node.external.using and source_node.external.using|lower != 'delta' -%}\n {% set ddl %}\n ALTER TABLE {{ source(source_node.source_name, source_node.name) }} RECOVER PARTITIONS\n {% endset %}\n {%- else -%}\n {% set ddl = none %}\n {%- endif -%}\n\n {{return(ddl)}}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.527437, + "supported_languages": null + }, + "macro.dbt_external_tables.recover_partitions": { + "unique_id": "macro.dbt_external_tables.recover_partitions", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/helpers/recover_partitions.sql", + "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", + "name": "recover_partitions", + "macro_sql": "{% macro recover_partitions(source_node) %}\n {{ return(adapter.dispatch('recover_partitions', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_external_tables.default__recover_partitions"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5276082, + "supported_languages": null + }, + "macro.dbt_external_tables.default__recover_partitions": { + "unique_id": "macro.dbt_external_tables.default__recover_partitions", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/helpers/recover_partitions.sql", + "original_file_path": "macros/plugins/spark/helpers/recover_partitions.sql", + "name": "default__recover_partitions", + "macro_sql": "{% macro default__recover_partitions(source_node) %}\n /*{# \n We're dispatching this macro so that users can override it if required on other adapters\n but this will work for spark/databricks. \n #}*/\n\n {{ exceptions.raise_not_implemented('recover_partitions macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.527763, + "supported_languages": null + }, + "macro.dbt_external_tables.spark__dropif": { + "unique_id": "macro.dbt_external_tables.spark__dropif", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/plugins/spark/helpers/dropif.sql", + "original_file_path": "macros/plugins/spark/helpers/dropif.sql", + "name": "spark__dropif", + "macro_sql": "{% macro spark__dropif(node) %}\n \n {% set ddl %}\n drop table if exists {{source(node.source_name, node.name)}}\n {% endset %}\n \n {{return(ddl)}}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.528088, + "supported_languages": null + }, + "macro.dbt_external_tables.create_external_table": { + "unique_id": "macro.dbt_external_tables.create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/create_external_table.sql", + "original_file_path": "macros/common/create_external_table.sql", + "name": "create_external_table", + "macro_sql": "{% macro create_external_table(source_node) %}\n {{ adapter.dispatch('create_external_table', 'dbt_external_tables')(source_node) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_external_tables.snowflake__create_external_table"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5283651, + "supported_languages": null + }, + "macro.dbt_external_tables.default__create_external_table": { + "unique_id": "macro.dbt_external_tables.default__create_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/create_external_table.sql", + "original_file_path": "macros/common/create_external_table.sql", + "name": "default__create_external_table", + "macro_sql": "{% macro default__create_external_table(source_node) %}\n {{ exceptions.raise_compiler_error(\"External table creation is not implemented for the default adapter\") }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5284832, + "supported_languages": null + }, + "macro.dbt_external_tables.refresh_external_table": { + "unique_id": "macro.dbt_external_tables.refresh_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/refresh_external_table.sql", + "original_file_path": "macros/common/refresh_external_table.sql", + "name": "refresh_external_table", + "macro_sql": "{% macro refresh_external_table(source_node) %}\n {{ return(adapter.dispatch('refresh_external_table', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.snowflake__refresh_external_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.528766, + "supported_languages": null + }, + "macro.dbt_external_tables.default__refresh_external_table": { + "unique_id": "macro.dbt_external_tables.default__refresh_external_table", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/refresh_external_table.sql", + "original_file_path": "macros/common/refresh_external_table.sql", + "name": "default__refresh_external_table", + "macro_sql": "{% macro default__refresh_external_table(source_node) %}\n {% do return([]) %}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.528888, + "supported_languages": null + }, + "macro.dbt_external_tables.get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/get_external_build_plan.sql", + "original_file_path": "macros/common/get_external_build_plan.sql", + "name": "get_external_build_plan", + "macro_sql": "{% macro get_external_build_plan(source_node) %}\n {{ return(adapter.dispatch('get_external_build_plan', 'dbt_external_tables')(source_node)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.snowflake__get_external_build_plan" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.529182, + "supported_languages": null + }, + "macro.dbt_external_tables.default__get_external_build_plan": { + "unique_id": "macro.dbt_external_tables.default__get_external_build_plan", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/get_external_build_plan.sql", + "original_file_path": "macros/common/get_external_build_plan.sql", + "name": "default__get_external_build_plan", + "macro_sql": "{% macro default__get_external_build_plan(source_node) %}\n {{ exceptions.raise_compiler_error(\"Staging external sources is not implemented for the default adapter\") }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.529304, + "supported_languages": null + }, + "macro.dbt_external_tables.stage_external_sources": { + "unique_id": "macro.dbt_external_tables.stage_external_sources", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/stage_external_sources.sql", + "original_file_path": "macros/common/stage_external_sources.sql", + "name": "stage_external_sources", + "macro_sql": "{% macro stage_external_sources(select=none) %}\n\n {% set sources_to_stage = [] %}\n \n {% set source_nodes = graph.sources.values() if graph.sources else [] %}\n \n {% for node in source_nodes %}\n {% if node.external %}\n \n {% if select %}\n \n {% for src in select.split(' ') %}\n \n {% if '.' in src %}\n {% set src_s = src.split('.') %}\n {% if src_s[0] == node.source_name and src_s[1] == node.name %}\n {% do sources_to_stage.append(node) %}\n {% endif %}\n {% else %}\n {% if src == node.source_name %}\n {% do sources_to_stage.append(node) %}\n {% endif %}\n {% endif %}\n \n {% endfor %}\n \n {% else %}\n \n {% do sources_to_stage.append(node) %}\n \n {% endif %}\n {% endif %}\n \n {% endfor %}\n \n {% if sources_to_stage|length == 0 %}\n {% do log('No external sources selected', info = true) %}\n {% endif %}\n \n {% for node in sources_to_stage %}\n\n {% set loop_label = loop.index ~ ' of ' ~ loop.length %}\n\n {% do log(loop_label ~ ' START external source ' ~ node.schema ~ '.' ~ node.identifier, info = true) -%}\n \n {% set run_queue = dbt_external_tables.get_external_build_plan(node) %}\n \n {% do log(loop_label ~ ' SKIP', info = true) if run_queue == [] %}\n {% set width = flags.PRINTER_WIDTH %}\n \n {% for q in run_queue %}\n \n {% set q_msg = q|replace('\\n','')|replace('begin;','')|trim %}\n {% set q_log = q_msg[:width] ~ '... ' if q_msg|length > width else q_msg %}\n \n {% do log(loop_label ~ ' (' ~ loop.index ~ ') ' ~ q_log, info = true) %}\n {% set exit_txn = dbt_external_tables.exit_transaction() %}\n \n {% call statement('runner', fetch_result = True, auto_begin = False) %}\n {{ exit_txn }} {{ q }}\n {% endcall %}\n \n {% set runner = load_result('runner') %}\n {% set log_msg = runner['response'] if 'response' in runner.keys() else runner['status'] %}\n {% do log(loop_label ~ ' (' ~ loop.index ~ ') ' ~ log_msg, info = true) %}\n \n {% endfor %}\n \n {% endfor %}\n \n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_external_tables.get_external_build_plan", + "macro.dbt_external_tables.exit_transaction", + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5339992, + "supported_languages": null + }, + "macro.dbt_external_tables.dropif": { + "unique_id": "macro.dbt_external_tables.dropif", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/helpers/dropif.sql", + "original_file_path": "macros/common/helpers/dropif.sql", + "name": "dropif", + "macro_sql": "{% macro dropif(node) %}\n {{ adapter.dispatch('dropif', 'dbt_external_tables')(node) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_external_tables.default__dropif"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5343099, + "supported_languages": null + }, + "macro.dbt_external_tables.default__dropif": { + "unique_id": "macro.dbt_external_tables.default__dropif", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/helpers/dropif.sql", + "original_file_path": "macros/common/helpers/dropif.sql", + "name": "default__dropif", + "macro_sql": "{% macro default__dropif() %}\n {{ exceptions.raise_compiler_error(\n \"Dropping external tables is not implemented for the default adapter\"\n ) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.534424, + "supported_languages": null + }, + "macro.dbt_external_tables.exit_transaction": { + "unique_id": "macro.dbt_external_tables.exit_transaction", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/helpers/transaction.sql", + "original_file_path": "macros/common/helpers/transaction.sql", + "name": "exit_transaction", + "macro_sql": "{% macro exit_transaction() %}\n {{ return(adapter.dispatch('exit_transaction', 'dbt_external_tables')()) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_external_tables.default__exit_transaction"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.534693, + "supported_languages": null + }, + "macro.dbt_external_tables.default__exit_transaction": { + "unique_id": "macro.dbt_external_tables.default__exit_transaction", + "package_name": "dbt_external_tables", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_external_tables", + "path": "macros/common/helpers/transaction.sql", + "original_file_path": "macros/common/helpers/transaction.sql", + "name": "default__exit_transaction", + "macro_sql": "{% macro default__exit_transaction() %}\n {{ return('') }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.534794, + "supported_languages": null + }, + "macro.dbt_expectations.type_timestamp": { + "unique_id": "macro.dbt_expectations.type_timestamp", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "type_timestamp", + "macro_sql": "\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt_expectations')()) }}\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.snowflake__type_timestamp"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5351932, + "supported_languages": null + }, + "macro.dbt_expectations.default__type_timestamp": { + "unique_id": "macro.dbt_expectations.default__type_timestamp", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "default__type_timestamp", + "macro_sql": "{% macro default__type_timestamp() -%}\n timestamp\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5352588, + "supported_languages": null + }, + "macro.dbt_expectations.snowflake__type_timestamp": { + "unique_id": "macro.dbt_expectations.snowflake__type_timestamp", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "snowflake__type_timestamp", + "macro_sql": "{% macro snowflake__type_timestamp() -%}\n timestamp_ntz\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5353248, + "supported_languages": null + }, + "macro.dbt_expectations.postgres__type_timestamp": { + "unique_id": "macro.dbt_expectations.postgres__type_timestamp", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "postgres__type_timestamp", + "macro_sql": "{% macro postgres__type_timestamp() -%}\n timestamp without time zone\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5353868, + "supported_languages": null + }, + "macro.dbt_expectations.type_datetime": { + "unique_id": "macro.dbt_expectations.type_datetime", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "type_datetime", + "macro_sql": "{% macro type_datetime() -%}\n {{ return(adapter.dispatch('type_datetime', 'dbt_expectations')()) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.snowflake__type_datetime"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5355258, + "supported_languages": null + }, + "macro.dbt_expectations.default__type_datetime": { + "unique_id": "macro.dbt_expectations.default__type_datetime", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "default__type_datetime", + "macro_sql": "{% macro default__type_datetime() -%}\n datetime\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.535591, + "supported_languages": null + }, + "macro.dbt_expectations.snowflake__type_datetime": { + "unique_id": "macro.dbt_expectations.snowflake__type_datetime", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "snowflake__type_datetime", + "macro_sql": "{% macro snowflake__type_datetime() -%}\n timestamp_ntz\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5356522, + "supported_languages": null + }, + "macro.dbt_expectations.postgres__type_datetime": { + "unique_id": "macro.dbt_expectations.postgres__type_datetime", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/datatypes.sql", + "original_file_path": "macros/utils/datatypes.sql", + "name": "postgres__type_datetime", + "macro_sql": "{% macro postgres__type_datetime() -%}\n timestamp without time zone\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.535712, + "supported_languages": null + }, + "macro.dbt_expectations.group_by": { + "unique_id": "macro.dbt_expectations.group_by", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/groupby.sql", + "original_file_path": "macros/utils/groupby.sql", + "name": "group_by", + "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_expectations')(n)) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.default__group_by"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.536022, + "supported_languages": null + }, + "macro.dbt_expectations.default__group_by": { + "unique_id": "macro.dbt_expectations.default__group_by", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/utils/groupby.sql", + "original_file_path": "macros/utils/groupby.sql", + "name": "default__group_by", + "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }}\n {%- endfor -%}\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.536243, + "supported_languages": null + }, + "macro.dbt_expectations.regexp_instr": { + "unique_id": "macro.dbt_expectations.regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "regexp_instr", + "macro_sql": "{% macro regexp_instr(source_value, regexp, position=1, occurrence=1, is_raw=False) %}\n\n {{ adapter.dispatch('regexp_instr', 'dbt_expectations')(\n source_value, regexp, position, occurrence, is_raw\n ) }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.snowflake__regexp_instr"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.536854, + "supported_languages": null + }, + "macro.dbt_expectations.default__regexp_instr": { + "unique_id": "macro.dbt_expectations.default__regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "default__regexp_instr", + "macro_sql": "{% macro default__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\nregexp_instr({{ source_value }}, '{{ regexp }}', {{ position }}, {{ occurrence }})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5370262, + "supported_languages": null + }, + "macro.dbt_expectations.snowflake__regexp_instr": { + "unique_id": "macro.dbt_expectations.snowflake__regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "snowflake__regexp_instr", + "macro_sql": "{% macro snowflake__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\n{%- set regexp = \"$$\" ~ regexp ~ \"$$\" if is_raw else \"'\" ~ regexp ~ \"'\" -%}\nregexp_instr({{ source_value }}, {{ regexp }}, {{ position }}, {{ occurrence }})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.537292, + "supported_languages": null + }, + "macro.dbt_expectations.bigquery__regexp_instr": { + "unique_id": "macro.dbt_expectations.bigquery__regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "bigquery__regexp_instr", + "macro_sql": "{% macro bigquery__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\n{%- set regexp = \"r'\" ~ regexp ~ \"'\" if is_raw else \"'\" ~ regexp ~ \"'\" -%}\nregexp_instr({{ source_value }}, {{ regexp }}, {{ position }}, {{ occurrence }})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.53762, + "supported_languages": null + }, + "macro.dbt_expectations.postgres__regexp_instr": { + "unique_id": "macro.dbt_expectations.postgres__regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "postgres__regexp_instr", + "macro_sql": "{% macro postgres__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\narray_length((select regexp_matches({{ source_value }}, '{{ regexp }}')), 1)\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.537765, + "supported_languages": null + }, + "macro.dbt_expectations.redshift__regexp_instr": { + "unique_id": "macro.dbt_expectations.redshift__regexp_instr", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/regex/regexp_instr.sql", + "original_file_path": "macros/regex/regexp_instr.sql", + "name": "redshift__regexp_instr", + "macro_sql": "{% macro redshift__regexp_instr(source_value, regexp, position, occurrence, is_raw) %}\nregexp_instr({{ source_value }}, '{{ regexp }}', {{ position }}, {{ occurrence }})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5379379, + "supported_languages": null + }, + "macro.dbt_expectations.log_natural": { + "unique_id": "macro.dbt_expectations.log_natural", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/log_natural.sql", + "original_file_path": "macros/math/log_natural.sql", + "name": "log_natural", + "macro_sql": "{% macro log_natural(x) -%}\n {{ adapter.dispatch('log_natural', 'dbt_expectations') (x) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.snowflake__log_natural"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.538249, + "supported_languages": null + }, + "macro.dbt_expectations.default__log_natural": { + "unique_id": "macro.dbt_expectations.default__log_natural", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/log_natural.sql", + "original_file_path": "macros/math/log_natural.sql", + "name": "default__log_natural", + "macro_sql": "{% macro default__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.538338, + "supported_languages": null + }, + "macro.dbt_expectations.bigquery__log_natural": { + "unique_id": "macro.dbt_expectations.bigquery__log_natural", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/log_natural.sql", + "original_file_path": "macros/math/log_natural.sql", + "name": "bigquery__log_natural", + "macro_sql": "{% macro bigquery__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5384252, + "supported_languages": null + }, + "macro.dbt_expectations.snowflake__log_natural": { + "unique_id": "macro.dbt_expectations.snowflake__log_natural", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/log_natural.sql", + "original_file_path": "macros/math/log_natural.sql", + "name": "snowflake__log_natural", + "macro_sql": "{% macro snowflake__log_natural(x) -%}\n\n ln({{ x }})\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.538511, + "supported_languages": null + }, + "macro.dbt_expectations.rand": { + "unique_id": "macro.dbt_expectations.rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "rand", + "macro_sql": "{% macro rand() -%}\n {{ adapter.dispatch('rand', 'dbt_expectations') () }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.snowflake__rand"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5388339, + "supported_languages": null + }, + "macro.dbt_expectations.default__rand": { + "unique_id": "macro.dbt_expectations.default__rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "default__rand", + "macro_sql": "{% macro default__rand() -%}\n\n rand()\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5389, + "supported_languages": null + }, + "macro.dbt_expectations.bigquery__rand": { + "unique_id": "macro.dbt_expectations.bigquery__rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "bigquery__rand", + "macro_sql": "{% macro bigquery__rand() -%}\n\n rand()\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.538962, + "supported_languages": null + }, + "macro.dbt_expectations.snowflake__rand": { + "unique_id": "macro.dbt_expectations.snowflake__rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "snowflake__rand", + "macro_sql": "{% macro snowflake__rand(seed) -%}\n\n uniform(0::float, 1::float, random())\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.539032, + "supported_languages": null + }, + "macro.dbt_expectations.postgres__rand": { + "unique_id": "macro.dbt_expectations.postgres__rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "postgres__rand", + "macro_sql": "{% macro postgres__rand() -%}\n\n random()\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.539092, + "supported_languages": null + }, + "macro.dbt_expectations.redshift__rand": { + "unique_id": "macro.dbt_expectations.redshift__rand", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/rand.sql", + "original_file_path": "macros/math/rand.sql", + "name": "redshift__rand", + "macro_sql": "{% macro redshift__rand() -%}\n\n random()\n\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.539156, + "supported_languages": null + }, + "macro.dbt_expectations.median": { + "unique_id": "macro.dbt_expectations.median", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/median.sql", + "original_file_path": "macros/math/median.sql", + "name": "median", + "macro_sql": "{% macro median(field) %}\n{{ dbt_expectations.percentile_cont(field, 0.5) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.percentile_cont"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5393898, + "supported_languages": null + }, + "macro.dbt_expectations.percentile_cont": { + "unique_id": "macro.dbt_expectations.percentile_cont", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/percentile_cont.sql", + "original_file_path": "macros/math/percentile_cont.sql", + "name": "percentile_cont", + "macro_sql": "{% macro percentile_cont(field, quantile, partition=None) %}\n {{ adapter.dispatch('quantile', 'dbt_expectations') (field, quantile, partition) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.default__quantile"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.539837, + "supported_languages": null + }, + "macro.dbt_expectations.default__quantile": { + "unique_id": "macro.dbt_expectations.default__quantile", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/percentile_cont.sql", + "original_file_path": "macros/math/percentile_cont.sql", + "name": "default__quantile", + "macro_sql": "{% macro default__quantile(field, quantile, partition) -%}\n percentile_cont({{ quantile }}) within group (order by {{ field }})\n {%- if partition %}over(partition by {{ partition }}){% endif -%}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.540024, + "supported_languages": null + }, + "macro.dbt_expectations.bigquery__quantile": { + "unique_id": "macro.dbt_expectations.bigquery__quantile", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/math/percentile_cont.sql", + "original_file_path": "macros/math/percentile_cont.sql", + "name": "bigquery__quantile", + "macro_sql": "{% macro bigquery__quantile(field, quantile, partition) -%}\n percentile_cont({{ field }}, {{ quantile }})\n over({%- if partition %}partition by {{ partition }}{% endif -%})\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.540208, + "supported_languages": null + }, + "macro.dbt_expectations.ignore_row_if_expression": { + "unique_id": "macro.dbt_expectations.ignore_row_if_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", + "name": "ignore_row_if_expression", + "macro_sql": "{% macro ignore_row_if_expression(ignore_row_if, columns) %}\n {{ adapter.dispatch('ignore_row_if_expression', 'dbt_expectations') (ignore_row_if, columns) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.default__ignore_row_if_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5406668, + "supported_languages": null + }, + "macro.dbt_expectations.default__ignore_row_if_expression": { + "unique_id": "macro.dbt_expectations.default__ignore_row_if_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/_ignore_row_if_expression.sql", + "name": "default__ignore_row_if_expression", + "macro_sql": "{% macro default__ignore_row_if_expression(ignore_row_if, columns) %}\n {%- set ignore_row_if_values = [\"all_values_are_missing\", \"any_value_is_missing\"] -%}\n {% if ignore_row_if not in ignore_row_if_values %}\n {{ exceptions.raise_compiler_error(\n \"`ignore_row_if` must be one of \" ~ (ignore_row_if_values | join(\", \")) ~ \". Got: '\" ~ ignore_row_if ~\"'.'\"\n ) }}\n {% endif %}\n\n {%- set op = \"and\" if ignore_row_if == \"all_values_are_missing\" else \"or\" -%}\n not (\n {% for column in columns -%}\n {{ column }} is null{% if not loop.last %} {{ op }} {% endif %}\n {% endfor %}\n )\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.541265, + "supported_languages": null + }, + "macro.dbt_expectations.test_expression_between": { + "unique_id": "macro.dbt_expectations.test_expression_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/expression_between.sql", + "original_file_path": "macros/schema_tests/_generalized/expression_between.sql", + "name": "test_expression_between", + "macro_sql": "{% test expression_between(model,\n expression,\n min_value=None,\n max_value=None,\n group_by_columns=None,\n row_condition=None,\n strictly=False\n ) %}\n\n {{ dbt_expectations.expression_between(model, expression, min_value, max_value, group_by_columns, row_condition, strictly) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.542332, + "supported_languages": null + }, + "macro.dbt_expectations.expression_between": { + "unique_id": "macro.dbt_expectations.expression_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/expression_between.sql", + "original_file_path": "macros/schema_tests/_generalized/expression_between.sql", + "name": "expression_between", + "macro_sql": "{% macro expression_between(model,\n expression,\n min_value,\n max_value,\n group_by_columns,\n row_condition,\n strictly\n ) %}\n\n{%- if min_value is none and max_value is none -%}\n{{ exceptions.raise_compiler_error(\n \"You have to provide either a min_value, max_value or both.\"\n) }}\n{%- endif -%}\n\n{%- set strict_operator = \"\" if strictly else \"=\" -%}\n\n{% set expression_min_max %}\n( 1=1\n{%- if min_value is not none %} and {{ expression | trim }} >{{ strict_operator }} {{ min_value }}{% endif %}\n{%- if max_value is not none %} and {{ expression | trim }} <{{ strict_operator }} {{ max_value }}{% endif %}\n)\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression_min_max,\n group_by_columns=group_by_columns,\n row_condition=row_condition)\n }}\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.542986, + "supported_languages": null + }, + "macro.dbt_expectations.test_expression_is_true": { + "unique_id": "macro.dbt_expectations.test_expression_is_true", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/expression_is_true.sql", + "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", + "name": "test_expression_is_true", + "macro_sql": "{% test expression_is_true(model,\n expression,\n test_condition=\"= true\",\n group_by_columns=None,\n row_condition=None\n ) %}\n\n {{ dbt_expectations.expression_is_true(model, expression, test_condition, group_by_columns, row_condition) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.543922, + "supported_languages": null + }, + "macro.dbt_expectations.expression_is_true": { + "unique_id": "macro.dbt_expectations.expression_is_true", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/expression_is_true.sql", + "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", + "name": "expression_is_true", + "macro_sql": "{% macro expression_is_true(model,\n expression,\n test_condition=\"= true\",\n group_by_columns=None,\n row_condition=None\n ) %}\n {{ adapter.dispatch('expression_is_true', 'dbt_expectations') (model, expression, test_condition, group_by_columns, row_condition) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.default__expression_is_true"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.544223, + "supported_languages": null + }, + "macro.dbt_expectations.default__expression_is_true": { + "unique_id": "macro.dbt_expectations.default__expression_is_true", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/expression_is_true.sql", + "original_file_path": "macros/schema_tests/_generalized/expression_is_true.sql", + "name": "default__expression_is_true", + "macro_sql": "{% macro default__expression_is_true(model, expression, test_condition, group_by_columns, row_condition) -%}\nwith grouped_expression as (\n select\n {% if group_by_columns %}\n {% for group_by_column in group_by_columns -%}\n {{ group_by_column }} as col_{{ loop.index }},\n {% endfor -%}\n {% endif %}\n {{ dbt_expectations.truth_expression(expression) }}\n from {{ model }}\n {%- if row_condition %}\n where\n {{ row_condition }}\n {% endif %}\n {% if group_by_columns %}\n group by\n {% for group_by_column in group_by_columns -%}\n {{ group_by_column }}{% if not loop.last %},{% endif %}\n {% endfor %}\n {% endif %}\n\n),\nvalidation_errors as (\n\n select\n *\n from\n grouped_expression\n where\n not(expression {{ test_condition }})\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.truth_expression"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.544829, + "supported_languages": null + }, + "macro.dbt_expectations.get_select": { + "unique_id": "macro.dbt_expectations.get_select", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/equal_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", + "name": "get_select", + "macro_sql": "{% macro get_select(model, expression, row_condition, group_by) -%}\n {{ adapter.dispatch('get_select', 'dbt_expectations') (model, expression, row_condition, group_by) }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.default__get_select"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.549419, + "supported_languages": null + }, + "macro.dbt_expectations.default__get_select": { + "unique_id": "macro.dbt_expectations.default__get_select", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/equal_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", + "name": "default__get_select", + "macro_sql": "\n\n{%- macro default__get_select(model, expression, row_condition, group_by) %}\n select\n {% if group_by %}\n {% for g in group_by -%}\n {{ g }} as col_{{ loop.index }},\n {% endfor -%}\n {% endif %}\n {{ expression }} as expression\n from\n {{ model }}\n {%- if row_condition %}\n where\n {{ row_condition }}\n {% endif %}\n {% if group_by %}\n group by\n {% for g in group_by -%}\n {{ loop.index }}{% if not loop.last %},{% endif %}\n {% endfor %}\n {% endif %}\n{% endmacro -%}\n\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.549917, + "supported_languages": null + }, + "macro.dbt_expectations.test_equal_expression": { + "unique_id": "macro.dbt_expectations.test_equal_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/equal_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", + "name": "test_equal_expression", + "macro_sql": "{% test equal_expression(model, expression,\n compare_model=None,\n compare_expression=None,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None,\n tolerance=0.0,\n tolerance_percent=None\n ) -%}\n\n {{ adapter.dispatch('test_equal_expression', 'dbt_expectations') (\n model,\n expression,\n compare_model,\n compare_expression,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition,\n tolerance,\n tolerance_percent) }}\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.default__test_equal_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5503502, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_equal_expression": { + "unique_id": "macro.dbt_expectations.default__test_equal_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/equal_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/equal_expression.sql", + "name": "default__test_equal_expression", + "macro_sql": "\n\n{%- macro default__test_equal_expression(\n model,\n expression,\n compare_model,\n compare_expression,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition,\n tolerance,\n tolerance_percent) -%}\n\n {%- set compare_model = model if not compare_model else compare_model -%}\n {%- set compare_expression = expression if not compare_expression else compare_expression -%}\n {%- set compare_row_condition = row_condition if not compare_row_condition else compare_row_condition -%}\n {%- set compare_group_by = group_by if not compare_group_by else compare_group_by -%}\n\n {%- set n_cols = (group_by|length) if group_by else 0 %}\n with a as (\n {{ dbt_expectations.get_select(model, expression, row_condition, group_by) }}\n ),\n b as (\n {{ dbt_expectations.get_select(compare_model, compare_expression, compare_row_condition, compare_group_by) }}\n ),\n final as (\n\n select\n {% for i in range(1, n_cols + 1) -%}\n coalesce(a.col_{{ i }}, b.col_{{ i }}) as col_{{ i }},\n {% endfor %}\n a.expression,\n b.expression as compare_expression,\n abs(coalesce(a.expression, 0) - coalesce(b.expression, 0)) as expression_difference,\n abs(coalesce(a.expression, 0) - coalesce(b.expression, 0))/\n nullif(a.expression * 1.0, 0) as expression_difference_percent\n from\n {% if n_cols > 0 %}\n a\n full outer join\n b on\n {% for i in range(1, n_cols + 1) -%}\n a.col_{{ i }} = b.col_{{ i }} {% if not loop.last %}and{% endif %}\n {% endfor -%}\n {% else %}\n a cross join b\n {% endif %}\n )\n -- DEBUG:\n -- select * from final\n select\n *\n from final\n where\n {% if tolerance_percent %}\n expression_difference_percent > {{ tolerance_percent }}\n {% else %}\n expression_difference > {{ tolerance }}\n {% endif %}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.get_select"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.551494, + "supported_languages": null + }, + "macro.dbt_expectations.truth_expression": { + "unique_id": "macro.dbt_expectations.truth_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/_truth_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/_truth_expression.sql", + "name": "truth_expression", + "macro_sql": "{% macro truth_expression(expression) %}\n {{ adapter.dispatch('truth_expression', 'dbt_expectations') (expression) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.default__truth_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.551809, + "supported_languages": null + }, + "macro.dbt_expectations.default__truth_expression": { + "unique_id": "macro.dbt_expectations.default__truth_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/_generalized/_truth_expression.sql", + "original_file_path": "macros/schema_tests/_generalized/_truth_expression.sql", + "name": "default__truth_expression", + "macro_sql": "{% macro default__truth_expression(expression) %}\n {{ expression }} as expression\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.551907, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern.sql", + "name": "test_expect_column_values_to_match_like_pattern", + "macro_sql": "{% test expect_column_values_to_match_like_pattern(model, column_name,\n like_pattern,\n row_condition=None\n ) %}\n\n{% set expression = dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=True) %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_like_pattern_expression", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.552447, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern_list": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_like_pattern_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern_list.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_like_pattern_list.sql", + "name": "test_expect_column_values_to_match_like_pattern_list", + "macro_sql": "{% test expect_column_values_to_match_like_pattern_list(model, column_name,\n like_pattern_list,\n match_on=\"any\",\n row_condition=None\n ) %}\n\n{% set expression %}\n {% for like_pattern in like_pattern_list %}\n {{ dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=True) }}\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_like_pattern_expression", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.553396, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_match_regex": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_regex", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex.sql", + "name": "test_expect_column_values_to_match_regex", + "macro_sql": "{% test expect_column_values_to_match_regex(model, column_name,\n regex,\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} > 0\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.regexp_instr", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.554038, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_value_lengths_to_equal": { + "unique_id": "macro.dbt_expectations.test_expect_column_value_lengths_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_equal.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_equal.sql", + "name": "test_expect_column_value_lengths_to_equal", + "macro_sql": "{% test expect_column_value_lengths_to_equal(model, column_name,\n value,\n row_condition=None\n ) %}\n\n{% set expression = length(column_name) ~ \" = \" ~ value %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.length", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.554555, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_value_lengths_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_value_lengths_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_be_between.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_value_lengths_to_be_between.sql", + "name": "test_expect_column_value_lengths_to_be_between", + "macro_sql": "{% test expect_column_value_lengths_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\n{{ length(column_name) }}\n{% endset %}\n\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=None,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.length", + "macro.dbt_expectations.expression_between" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.555298, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_match_regex": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_regex", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex.sql", + "name": "test_expect_column_values_to_not_match_regex", + "macro_sql": "{% test expect_column_values_to_not_match_regex(model, column_name,\n regex,\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} = 0\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.regexp_instr", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5559292, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_match_regex_list": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_regex_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex_list.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_regex_list.sql", + "name": "test_expect_column_values_to_not_match_regex_list", + "macro_sql": "{% test expect_column_values_to_not_match_regex_list(model, column_name,\n regex_list,\n match_on=\"any\",\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n{% for regex in regex_list %}\n{{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} = 0\n{%- if not loop.last %}\n{{ \" and \" if match_on == \"all\" else \" or \"}}\n{% endif -%}\n{% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.regexp_instr", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.55708, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_match_regex_list": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_match_regex_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex_list.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_match_regex_list.sql", + "name": "test_expect_column_values_to_match_regex_list", + "macro_sql": "{% test expect_column_values_to_match_regex_list(model, column_name,\n regex_list,\n match_on=\"any\",\n row_condition=None,\n is_raw=False\n ) %}\n\n{% set expression %}\n {% for regex in regex_list %}\n {{ dbt_expectations.regexp_instr(column_name, regex, is_raw=is_raw) }} > 0\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.regexp_instr", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.558057, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern_list": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern_list.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern_list.sql", + "name": "test_expect_column_values_to_not_match_like_pattern_list", + "macro_sql": "{% test expect_column_values_to_not_match_like_pattern_list(model, column_name,\n like_pattern_list,\n match_on=\"any\",\n row_condition=None\n ) %}\n\n{% set expression %}\n {% for like_pattern in like_pattern_list %}\n {{ dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=False) }}\n {%- if not loop.last %}\n {{ \" and \" if match_on == \"all\" else \" or \"}}\n {% endif -%}\n {% endfor %}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_like_pattern_expression", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.558999, + "supported_languages": null + }, + "macro.dbt_expectations._get_like_pattern_expression": { + "unique_id": "macro.dbt_expectations._get_like_pattern_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/_get_like_pattern_expression.sql", + "original_file_path": "macros/schema_tests/string_matching/_get_like_pattern_expression.sql", + "name": "_get_like_pattern_expression", + "macro_sql": "{% macro _get_like_pattern_expression(column_name, like_pattern, positive) %}\n{{ column_name }} {{ \"not\" if not positive else \"\" }} like '{{ like_pattern }}'\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.559286, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_match_like_pattern", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern.sql", + "original_file_path": "macros/schema_tests/string_matching/expect_column_values_to_not_match_like_pattern.sql", + "name": "test_expect_column_values_to_not_match_like_pattern", + "macro_sql": "{% test expect_column_values_to_not_match_like_pattern(model, column_name,\n like_pattern,\n row_condition=None\n ) %}\n\n{% set expression = dbt_expectations._get_like_pattern_expression(column_name, like_pattern, positive=False) %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_like_pattern_expression", + "macro.dbt_expectations.expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.559818, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_row_values_to_have_recent_data": { + "unique_id": "macro.dbt_expectations.test_expect_row_values_to_have_recent_data", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", + "name": "test_expect_row_values_to_have_recent_data", + "macro_sql": "{% test expect_row_values_to_have_recent_data(model,\n column_name,\n datepart,\n interval,\n row_condition=None) %}\n\n {{ adapter.dispatch('test_expect_row_values_to_have_recent_data', 'dbt_expectations') (model,\n column_name,\n datepart,\n interval,\n row_condition) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.560884, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data": { + "unique_id": "macro.dbt_expectations.default__test_expect_row_values_to_have_recent_data", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_row_values_to_have_recent_data.sql", + "name": "default__test_expect_row_values_to_have_recent_data", + "macro_sql": "{% macro default__test_expect_row_values_to_have_recent_data(model, column_name, datepart, interval, row_condition) %}\n{%- set default_start_date = '1970-01-01' -%}\nwith max_recency as (\n\n select max(cast({{ column_name }} as {{ dbt_expectations.type_timestamp() }})) as max_timestamp\n from\n {{ model }}\n where\n -- to exclude erroneous future dates\n cast({{ column_name }} as {{ dbt_expectations.type_timestamp() }}) <= {{ dbt_date.now() }}\n {% if row_condition %}\n and {{ row_condition }}\n {% endif %}\n)\nselect\n *\nfrom\n max_recency\nwhere\n -- if the row_condition excludes all rows, we need to compare against a default date\n -- to avoid false negatives\n coalesce(max_timestamp, cast('{{ default_start_date }}' as {{ dbt_expectations.type_timestamp() }}))\n <\n cast({{ dbt.dateadd(datepart, interval * -1, dbt_date.now()) }} as {{ dbt_expectations.type_timestamp() }})\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.type_timestamp", + "macro.dbt_date.now", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.561444, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_columns_to_contain_set": { + "unique_id": "macro.dbt_expectations.test_expect_table_columns_to_contain_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_columns_to_contain_set.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_contain_set.sql", + "name": "test_expect_table_columns_to_contain_set", + "macro_sql": "{%- test expect_table_columns_to_contain_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n input_columns i\n left join\n relation_columns r on r.relation_column = i.input_column\n where\n -- catch any column in input list that is not in the list of table columns\n r.relation_column is null\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_column_list", + "macro.dbt_expectations._list_intersect", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.562541, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table": { + "unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", + "name": "test_expect_table_row_count_to_equal_other_table", + "macro_sql": "{%- test expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by=None,\n compare_group_by=None,\n factor=1,\n row_condition=None,\n compare_row_condition=None\n ) -%}\n\n {{ adapter.dispatch('test_expect_table_row_count_to_equal_other_table',\n 'dbt_expectations') (model,\n compare_model,\n group_by,\n compare_group_by,\n factor,\n row_condition,\n compare_row_condition\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.563467, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table": { + "unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table.sql", + "name": "default__test_expect_table_row_count_to_equal_other_table", + "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by,\n compare_group_by,\n factor,\n row_condition,\n compare_row_condition\n ) -%}\n{{ dbt_expectations.test_equal_expression(model, \"count(*)\",\n compare_model=compare_model,\n compare_expression=\"count(*) * \" + factor|string,\n group_by=group_by,\n compare_group_by=compare_group_by,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.test_equal_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.563796, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_columns_to_not_contain_set": { + "unique_id": "macro.dbt_expectations.test_expect_table_columns_to_not_contain_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_columns_to_not_contain_set.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_not_contain_set.sql", + "name": "test_expect_table_columns_to_not_contain_set", + "macro_sql": "{%- test expect_table_columns_to_not_contain_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n -- catch any column in input list that is in the list of table columns\n select *\n from\n input_columns i\n inner join\n relation_columns r on r.relation_column = i.input_column\n\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_column_list", + "macro.dbt_expectations._list_intersect", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.564859, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_grouped_row_values_to_have_recent_data": { + "unique_id": "macro.dbt_expectations.test_expect_grouped_row_values_to_have_recent_data", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", + "name": "test_expect_grouped_row_values_to_have_recent_data", + "macro_sql": "{% test expect_grouped_row_values_to_have_recent_data(model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition=None) %}\n\n {{ adapter.dispatch('test_expect_grouped_row_values_to_have_recent_data', 'dbt_expectations') (model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.566947, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data": { + "unique_id": "macro.dbt_expectations.default__test_expect_grouped_row_values_to_have_recent_data", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_grouped_row_values_to_have_recent_data.sql", + "name": "default__test_expect_grouped_row_values_to_have_recent_data", + "macro_sql": "{% macro default__test_expect_grouped_row_values_to_have_recent_data(model,\n group_by,\n timestamp_column,\n datepart,\n interval,\n row_condition) %}\nwith latest_grouped_timestamps as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n max(1) as join_key,\n max(cast({{ timestamp_column }} as {{ dbt_expectations.type_timestamp() }})) as latest_timestamp_column\n from\n {{ model }}\n where\n -- to exclude erroneous future dates\n cast({{ timestamp_column }} as {{ dbt_expectations.type_timestamp() }}) <= {{ dbt_date.now() }}\n {% if row_condition %}\n and {{ row_condition }}\n {% endif %}\n\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n),\ntotal_row_counts as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n max(1) as join_key,\n count(*) as row_count\n from\n latest_grouped_timestamps\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n\n\n),\noutdated_grouped_timestamps as (\n\n select *\n from\n latest_grouped_timestamps\n where\n -- are the max timestamps per group older than the specified cutoff?\n latest_timestamp_column <\n cast(\n {{ dbt.dateadd(datepart, interval * -1, dbt_date.now()) }}\n as {{ dbt_expectations.type_timestamp() }}\n )\n\n),\nvalidation_errors as (\n\n select\n r.row_count,\n t.*\n from\n total_row_counts r\n left join\n outdated_grouped_timestamps t\n on\n {% for g in group_by %}\n r.{{ g }} = t.{{ g }} and\n {% endfor %}\n r.join_key = t.join_key\n where\n -- fail if either no rows were returned due to row_condition,\n -- or the recency test returned failed rows\n r.row_count = 0\n or\n t.join_key is not null\n\n)\nselect * from validation_errors\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.type_timestamp", + "macro.dbt_date.now", + "macro.dbt_expectations.group_by", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.567868, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_to_exist": { + "unique_id": "macro.dbt_expectations.test_expect_column_to_exist", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_column_to_exist.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_column_to_exist.sql", + "name": "test_expect_column_to_exist", + "macro_sql": "{%- test expect_column_to_exist(model, column_name, column_index=None, transform=\"upper\") -%}\n{%- if execute -%}\n\n {%- set column_name = column_name | map(transform) | join -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n\n {%- set matching_column_index = relation_column_names.index(column_name) if column_name in relation_column_names else -1 %}\n\n {%- if column_index -%}\n\n {%- set column_index_0 = column_index - 1 if column_index > 0 else 0 -%}\n\n {%- set column_index_matches = true if matching_column_index == column_index_0 else false %}\n\n {%- else -%}\n\n {%- set column_index_matches = true -%}\n\n {%- endif %}\n\n with test_data as (\n\n select\n cast('{{ column_name }}' as {{ dbt.type_string() }}) as column_name,\n {{ matching_column_index }} as matching_column_index,\n {{ column_index_matches }} as column_index_matches\n\n )\n select *\n from test_data\n where\n not(matching_column_index >= 0 and column_index_matches)\n\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_column_list", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.568991, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_row_count_to_equal": { + "unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", + "name": "test_expect_table_row_count_to_equal", + "macro_sql": "{%- test expect_table_row_count_to_equal(model,\n value,\n group_by=None,\n row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_equal',\n 'dbt_expectations') (model,\n value,\n group_by,\n row_condition\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5696452, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal": { + "unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal.sql", + "name": "default__test_expect_table_row_count_to_equal", + "macro_sql": "\n\n\n\n{%- macro default__test_expect_table_row_count_to_equal(model,\n value,\n group_by,\n row_condition\n ) -%}\n{% set expression %}\ncount(*) = {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5699, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_row_count_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", + "name": "test_expect_table_row_count_to_be_between", + "macro_sql": "{%- test expect_table_row_count_to_be_between(model,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_be_between',\n 'dbt_expectations') (model,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_table_row_count_to_be_between" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.570776, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_table_row_count_to_be_between": { + "unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_be_between.sql", + "name": "default__test_expect_table_row_count_to_be_between", + "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_be_between(model,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) -%}\n{% set expression %}\ncount(*)\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.571151, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table_times_factor": { + "unique_id": "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table_times_factor", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", + "name": "test_expect_table_row_count_to_equal_other_table_times_factor", + "macro_sql": "{%- test expect_table_row_count_to_equal_other_table_times_factor(model,\n compare_model,\n factor,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_table_row_count_to_equal_other_table_times_factor',\n 'dbt_expectations') (model,\n compare_model,\n factor,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.572184, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor": { + "unique_id": "macro.dbt_expectations.default__test_expect_table_row_count_to_equal_other_table_times_factor", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_row_count_to_equal_other_table_times_factor.sql", + "name": "default__test_expect_table_row_count_to_equal_other_table_times_factor", + "macro_sql": "\n\n{%- macro default__test_expect_table_row_count_to_equal_other_table_times_factor(model,\n compare_model,\n factor,\n group_by,\n compare_group_by,\n row_condition,\n compare_row_condition\n ) -%}\n\n{{ dbt_expectations.test_expect_table_row_count_to_equal_other_table(model,\n compare_model,\n group_by=group_by,\n compare_group_by=compare_group_by,\n factor=factor,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.test_expect_table_row_count_to_equal_other_table" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5724611, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_columns_to_match_set": { + "unique_id": "macro.dbt_expectations.test_expect_table_columns_to_match_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_columns_to_match_set.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_match_set.sql", + "name": "test_expect_table_columns_to_match_set", + "macro_sql": "{%- test expect_table_columns_to_match_set(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n relation_columns r\n full outer join\n input_columns i on r.relation_column = i.input_column\n where\n -- catch any column in input list that is not in the list of table columns\n -- or any table column that is not in the input list\n r.relation_column is null or\n i.input_column is null\n\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_column_list", + "macro.dbt_expectations._list_intersect", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5736089, + "supported_languages": null + }, + "macro.dbt_expectations._get_column_list": { + "unique_id": "macro.dbt_expectations._get_column_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/_get_column_list.sql", + "original_file_path": "macros/schema_tests/table_shape/_get_column_list.sql", + "name": "_get_column_list", + "macro_sql": "{%- macro _get_column_list(model, transform=\"upper\") -%}\n{%- set relation_columns = adapter.get_columns_in_relation(model) -%}\n{%- set relation_column_names = relation_columns | map(attribute=\"name\") | map(transform) | list -%}\n{%- do return(relation_column_names) -%}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.574019, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_columns_to_match_ordered_list": { + "unique_id": "macro.dbt_expectations.test_expect_table_columns_to_match_ordered_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_columns_to_match_ordered_list.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_columns_to_match_ordered_list.sql", + "name": "test_expect_table_columns_to_match_ordered_list", + "macro_sql": "{%- test expect_table_columns_to_match_ordered_list(model, column_list, transform=\"upper\") -%}\n{%- if execute -%}\n {%- set column_list = column_list | map(transform) | list -%}\n {%- set relation_column_names = dbt_expectations._get_column_list(model, transform) -%}\n {%- set matching_columns = dbt_expectations._list_intersect(column_list, relation_column_names) -%}\n with relation_columns as (\n\n {% for col_name in relation_column_names %}\n select\n {{ loop.index }} as relation_column_idx,\n cast('{{ col_name }}' as {{ dbt.type_string() }}) as relation_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n input_columns as (\n\n {% for col_name in column_list %}\n select\n {{ loop.index }} as input_column_idx,\n cast('{{ col_name }}' as {{ dbt.type_string() }}) as input_column\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n )\n select *\n from\n relation_columns r\n full outer join\n input_columns i on r.relation_column = i.input_column and r.relation_column_idx = i.input_column_idx\n where\n -- catch any column in input list that is not in the sequence of table columns\n -- or any table column that is not in the input sequence\n r.relation_column is null or\n i.input_column is null\n\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations._get_column_list", + "macro.dbt_expectations._list_intersect", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.575304, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_aggregation_to_equal_other_table": { + "unique_id": "macro.dbt_expectations.test_expect_table_aggregation_to_equal_other_table", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_aggregation_to_equal_other_table.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_aggregation_to_equal_other_table.sql", + "name": "test_expect_table_aggregation_to_equal_other_table", + "macro_sql": "{%- test expect_table_aggregation_to_equal_other_table(model,\n expression,\n compare_model,\n compare_expression=None,\n group_by=None,\n compare_group_by=None,\n row_condition=None,\n compare_row_condition=None,\n tolerance=0.0,\n tolerance_percent=None\n ) -%}\n\n\n{{ dbt_expectations.test_equal_expression(\n model,\n expression=expression,\n compare_model=compare_model,\n compare_expression=compare_expression,\n group_by=group_by,\n compare_group_by=compare_group_by,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition,\n tolerance=tolerance,\n tolerance_percent=tolerance_percent\n) }}\n\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.test_equal_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.57592, + "supported_languages": null + }, + "macro.dbt_expectations._list_intersect": { + "unique_id": "macro.dbt_expectations._list_intersect", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/_list_intersect.sql", + "original_file_path": "macros/schema_tests/table_shape/_list_intersect.sql", + "name": "_list_intersect", + "macro_sql": "{%- macro _list_intersect(list1, list2) -%}\n{%- set matching_items = [] -%}\n{%- for itm in list1 -%}\n {%- if itm in list2 -%}\n {%- do matching_items.append(itm) -%}\n {%- endif -%}\n{%- endfor -%}\n{%- do return(matching_items) -%}\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5763462, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_column_count_to_equal_other_table": { + "unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_equal_other_table", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal_other_table.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal_other_table.sql", + "name": "test_expect_table_column_count_to_equal_other_table", + "macro_sql": "{%- test expect_table_column_count_to_equal_other_table(model, compare_model) -%}\n{%- if execute -%}\n{%- set number_columns = (adapter.get_columns_in_relation(model) | length) -%}\n{%- set compare_number_columns = (adapter.get_columns_in_relation(compare_model) | length) -%}\nwith test_data as (\n\n select\n {{ number_columns }} as number_columns,\n {{ compare_number_columns }} as compare_number_columns\n\n)\nselect *\nfrom test_data\nwhere\n number_columns != compare_number_columns\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.576833, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_column_count_to_equal": { + "unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_equal.sql", + "name": "test_expect_table_column_count_to_equal", + "macro_sql": "{%- test expect_table_column_count_to_equal(model, value) -%}\n{%- if execute -%}\n{%- set number_actual_columns = (adapter.get_columns_in_relation(model) | length) -%}\nwith test_data as (\n\n select\n {{ number_actual_columns }} as number_actual_columns,\n {{ value }} as value\n\n)\nselect *\nfrom test_data\nwhere\n number_actual_columns != value\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5772219, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_table_column_count_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_table_column_count_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/table_shape/expect_table_column_count_to_be_between.sql", + "original_file_path": "macros/schema_tests/table_shape/expect_table_column_count_to_be_between.sql", + "name": "test_expect_table_column_count_to_be_between", + "macro_sql": "{%- test expect_table_column_count_to_be_between(model,\n min_value=None,\n max_value=None\n ) -%}\n{%- if min_value is none and max_value is none -%}\n{{ exceptions.raise_compiler_error(\n \"You have to provide either a min_value, max_value or both.\"\n) }}\n{%- endif -%}\n{%- if execute -%}\n{%- set number_actual_columns = (adapter.get_columns_in_relation(model) | length) -%}\n\n{%- set expression %}\n( 1=1\n{%- if min_value %} and number_actual_columns >= min_value{% endif %}\n{%- if max_value %} and number_actual_columns <= max_value{% endif %}\n)\n{% endset -%}\n\nwith test_data as (\n\n select\n {{ number_actual_columns }} as number_actual_columns,\n {{ min_value if min_value else 0 }} as min_value,\n {{ max_value if max_value else 0 }} as max_value\n\n)\nselect *\nfrom test_data\nwhere\n not {{ expression }}\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.578149, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_be_in_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_in_set.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_in_set.sql", + "name": "test_expect_column_values_to_not_be_in_set", + "macro_sql": "{% test expect_column_values_to_not_be_in_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n cast('{{ value }}' as {{ dbt.type_string() }})\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n -- values from the model that match the set\n select\n v.value_field\n from\n all_values v\n join\n set_values s on v.value_field = s.value_field\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_string"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5789819, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_in_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_set.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_set.sql", + "name": "test_expect_column_values_to_be_in_set", + "macro_sql": "{% test expect_column_values_to_be_in_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n cast('{{ value }}' as {{ dbt.type_string() }})\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n v.value_field\n from\n all_values v\n left join\n set_values s on v.value_field = s.value_field\n where\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_string"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.57984, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_increasing": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_increasing", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_increasing.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_increasing.sql", + "name": "test_expect_column_values_to_be_increasing", + "macro_sql": "{% test expect_column_values_to_be_increasing(model, column_name,\n sort_column=None,\n strictly=True,\n row_condition=None,\n group_by=None) %}\n\n{%- set sort_column = column_name if not sort_column else sort_column -%}\n{%- set operator = \">\" if strictly else \">=\" -%}\nwith all_values as (\n\n select\n {{ sort_column }} as sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n {{ column_name }} as value_field\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nadd_lag_values as (\n\n select\n sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n value_field,\n lag(value_field) over\n {%- if not group_by -%}\n (order by sort_column)\n {%- else -%}\n (partition by {{ group_by | join(\", \") }} order by sort_column)\n {%- endif %} as value_field_lag\n from\n all_values\n\n),\nvalidation_errors as (\n select\n *\n from\n add_lag_values\n where\n value_field_lag is not null\n and\n not (value_field {{ operator }} value_field_lag)\n\n)\nselect *\nfrom validation_errors\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.581088, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_null": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_null", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_null.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_null.sql", + "name": "test_expect_column_values_to_be_null", + "macro_sql": "{% test expect_column_values_to_be_null(model, column_name, row_condition=None) %}\n\n{% set expression = column_name ~ \" is null\" %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5815601, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_unique": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_unique", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_unique.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_unique.sql", + "name": "test_expect_column_values_to_be_unique", + "macro_sql": "{% test expect_column_values_to_be_unique(model, column_name, row_condition=None) %}\n{{ dbt_expectations.test_expect_compound_columns_to_be_unique(model, [column_name], row_condition=row_condition) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.test_expect_compound_columns_to_be_unique" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.581853, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_between.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_between.sql", + "name": "test_expect_column_values_to_be_between", + "macro_sql": "{% test expect_column_values_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ column_name }}\n{% endset %}\n\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=None,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.582569, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_decreasing": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_decreasing", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_decreasing.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_decreasing.sql", + "name": "test_expect_column_values_to_be_decreasing", + "macro_sql": "{% test expect_column_values_to_be_decreasing(model, column_name,\n sort_column=None,\n strictly=True,\n row_condition=None,\n group_by=None) %}\n\n{%- set sort_column = column_name if not sort_column else sort_column -%}\n{%- set operator = \"<\" if strictly else \"<=\" %}\nwith all_values as (\n\n select\n {{ sort_column }} as sort_column,\n {%- if group_by -%}\n {{ group_by | join(\", \") }},\n {%- endif %}\n {{ column_name }} as value_field\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nadd_lag_values as (\n\n select\n sort_column,\n value_field,\n lag(value_field) over\n {%- if not group_by -%}\n (order by sort_column)\n {%- else -%}\n (partition by {{ group_by | join(\", \") }} order by sort_column)\n {%- endif %} as value_field_lag\n from\n all_values\n\n),\nvalidation_errors as (\n\n select\n *\n from\n add_lag_values\n where\n value_field_lag is not null\n and\n not (value_field {{ operator }} value_field_lag)\n\n)\nselect *\nfrom validation_errors\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.58374, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_in_type_list": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_in_type_list", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_type_list.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_in_type_list.sql", + "name": "test_expect_column_values_to_be_in_type_list", + "macro_sql": "{%- test expect_column_values_to_be_in_type_list(model, column_name, column_type_list) -%}\n{%- if execute -%}\n\n {%- set column_name = column_name | upper -%}\n {%- set columns_in_relation = adapter.get_columns_in_relation(model) -%}\n {%- set column_type_list = column_type_list| map(\"upper\") | list -%}\n with relation_columns as (\n\n {% for column in columns_in_relation %}\n select\n cast('{{ column.name | upper }}' as {{ dbt.type_string() }}) as relation_column,\n cast('{{ column.dtype | upper }}' as {{ dbt.type_string() }}) as relation_column_type\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n ),\n test_data as (\n\n select\n *\n from\n relation_columns\n where\n relation_column = '{{ column_name }}'\n and\n relation_column_type not in ('{{ column_type_list | join(\"', '\") }}')\n\n )\n select *\n from test_data\n\n{%- endif -%}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt.type_string"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.584741, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_of_type": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_of_type", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_of_type.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_be_of_type.sql", + "name": "test_expect_column_values_to_be_of_type", + "macro_sql": "{%- test expect_column_values_to_be_of_type(model, column_name, column_type) -%}\n{{ dbt_expectations.test_expect_column_values_to_be_in_type_list(model, column_name, [column_type]) }}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.test_expect_column_values_to_be_in_type_list" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5850081, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_have_consistent_casing": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_have_consistent_casing", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_have_consistent_casing.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_have_consistent_casing.sql", + "name": "test_expect_column_values_to_have_consistent_casing", + "macro_sql": "{% test expect_column_values_to_have_consistent_casing(model, column_name, display_inconsistent_columns=False) %}\n\nwith test_data as (\n\n select\n distinct {{ column_name }} as distinct_values\n from\n {{ model }}\n\n ),\n {% if display_inconsistent_columns %}\n validation_errors as (\n\n select\n lower(distinct_values) as inconsistent_columns,\n count(distinct_values) as set_count_case_insensitive\n from\n test_data\n group by 1\n having\n count(distinct_values) > 1\n\n )\n select * from validation_errors\n {% else %}\n validation_errors as (\n\n select\n count(1) as set_count,\n count(distinct lower(distinct_values)) as set_count_case_insensitive\n from\n test_data\n\n )\n select *\n from\n validation_errors\n where\n set_count != set_count_case_insensitive\n {% endif %}\n {%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5854578, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_not_be_null": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_not_be_null", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_null.sql", + "original_file_path": "macros/schema_tests/column_values_basic/expect_column_values_to_not_be_null.sql", + "name": "test_expect_column_values_to_not_be_null", + "macro_sql": "{% test expect_column_values_to_not_be_null(model, column_name, row_condition=None) %}\n\n{% set expression = column_name ~ \" is not null\" %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5859141, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_min_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_min_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_min_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_min_to_be_between.sql", + "name": "test_expect_column_min_to_be_between", + "macro_sql": "{% test expect_column_min_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nmin({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.586655, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_unique_value_count_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_unique_value_count_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_unique_value_count_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_unique_value_count_to_be_between.sql", + "name": "test_expect_column_unique_value_count_to_be_between", + "macro_sql": "{% test expect_column_unique_value_count_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.587415, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_quantile_values_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_quantile_values_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_quantile_values_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_quantile_values_to_be_between.sql", + "name": "test_expect_column_quantile_values_to_be_between", + "macro_sql": "{% test expect_column_quantile_values_to_be_between(model, column_name,\n quantile,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.percentile_cont(column_name, quantile) }}\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.percentile_cont", + "macro.dbt_expectations.expression_between" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.588223, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_median_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_median_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_median_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_median_to_be_between.sql", + "name": "test_expect_column_median_to_be_between", + "macro_sql": "{% test expect_column_median_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n\n{% set expression %}\n{{ dbt_expectations.median(column_name) }}\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.median", + "macro.dbt_expectations.expression_between" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5889878, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_proportion_of_unique_values_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_proportion_of_unique_values_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_proportion_of_unique_values_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_proportion_of_unique_values_to_be_between.sql", + "name": "test_expect_column_proportion_of_unique_values_to_be_between", + "macro_sql": "{% test expect_column_proportion_of_unique_values_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }})/count({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.589798, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_values_to_equal_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_equal_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_equal_set.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_equal_set.sql", + "name": "test_expect_column_distinct_values_to_equal_set", + "macro_sql": "{% test expect_column_distinct_values_to_equal_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as column_value\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n\n select\n *\n from\n all_values v\n full outer join\n unique_set_values s on v.column_value = s.value_field\n where\n v.column_value is null or\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5906339, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_most_common_value_to_be_in_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_most_common_value_to_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", + "name": "test_expect_column_most_common_value_to_be_in_set", + "macro_sql": "{% test expect_column_most_common_value_to_be_in_set(model,\n column_name,\n value_set,\n top_n,\n quote_values=True,\n data_type=\"decimal\",\n row_condition=None\n ) -%}\n\n {{ adapter.dispatch('test_expect_column_most_common_value_to_be_in_set', 'dbt_expectations') (\n model, column_name, value_set, top_n, quote_values, data_type, row_condition\n ) }}\n\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.592224, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set": { + "unique_id": "macro.dbt_expectations.default__test_expect_column_most_common_value_to_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_most_common_value_to_be_in_set.sql", + "name": "default__test_expect_column_most_common_value_to_be_in_set", + "macro_sql": "{% macro default__test_expect_column_most_common_value_to_be_in_set(model,\n column_name,\n value_set,\n top_n,\n quote_values,\n data_type,\n row_condition\n ) %}\n\nwith value_counts as (\n\n select\n {% if quote_values -%}\n {{ column_name }}\n {%- else -%}\n cast({{ column_name }} as {{ data_type }})\n {%- endif %} as value_field,\n count(*) as value_count\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n group by {% if quote_values -%}\n {{ column_name }}\n {%- else -%}\n cast({{ column_name }} as {{ data_type }})\n {%- endif %}\n\n),\nvalue_counts_ranked as (\n\n select\n *,\n row_number() over(order by value_count desc) as value_count_rank\n from\n value_counts\n\n),\nvalue_count_top_n as (\n\n select\n value_field\n from\n value_counts_ranked\n where\n value_count_rank = {{ top_n }}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n cast({{ value }} as {{ data_type }})\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n value_field\n from\n value_count_top_n\n where\n value_field not in (select value_field from unique_set_values)\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.592923, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_values_to_contain_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_contain_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_contain_set.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_contain_set.sql", + "name": "test_expect_column_distinct_values_to_contain_set", + "macro_sql": "{% test expect_column_distinct_values_to_contain_set(model, column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values in set that are not in the list of values from the model\n select\n s.value_field\n from\n unique_set_values s\n left join\n all_values v on s.value_field = v.value_field\n where\n v.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5937788, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_count_to_equal": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal.sql", + "name": "test_expect_column_distinct_count_to_equal", + "macro_sql": "{% test expect_column_distinct_count_to_equal(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) = {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.594362, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_count_to_be_less_than": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_be_less_than", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_less_than.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_less_than.sql", + "name": "test_expect_column_distinct_count_to_be_less_than", + "macro_sql": "{% test expect_column_distinct_count_to_be_less_than(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) < {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.594951, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_sum_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_sum_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_sum_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_sum_to_be_between.sql", + "name": "test_expect_column_sum_to_be_between", + "macro_sql": "{% test expect_column_sum_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nsum({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.595687, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_stdev_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_stdev_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", + "name": "test_expect_column_stdev_to_be_between", + "macro_sql": "{% test expect_column_stdev_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) -%}\n {{ adapter.dispatch('test_expect_column_stdev_to_be_between', 'dbt_expectations') (\n model, column_name,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) }}\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_column_stdev_to_be_between" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.596888, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_column_stdev_to_be_between": { + "unique_id": "macro.dbt_expectations.default__test_expect_column_stdev_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_stdev_to_be_between.sql", + "name": "default__test_expect_column_stdev_to_be_between", + "macro_sql": "{% macro default__test_expect_column_stdev_to_be_between(\n model, column_name,\n min_value,\n max_value,\n group_by,\n row_condition,\n strictly\n ) %}\n\n{% set expression %}\nstddev({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5972989, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_mean_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_mean_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_mean_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_mean_to_be_between.sql", + "name": "test_expect_column_mean_to_be_between", + "macro_sql": "{% test expect_column_mean_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\navg({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.5980392, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_max_to_be_between": { + "unique_id": "macro.dbt_expectations.test_expect_column_max_to_be_between", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_max_to_be_between.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_max_to_be_between.sql", + "name": "test_expect_column_max_to_be_between", + "macro_sql": "{% test expect_column_max_to_be_between(model, column_name,\n min_value=None,\n max_value=None,\n group_by=None,\n row_condition=None,\n strictly=False\n ) %}\n{% set expression %}\nmax({{ column_name }})\n{% endset %}\n{{ dbt_expectations.expression_between(model,\n expression=expression,\n min_value=min_value,\n max_value=max_value,\n group_by_columns=group_by,\n row_condition=row_condition,\n strictly=strictly\n ) }}\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_between"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.598778, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_count_to_be_greater_than": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_be_greater_than", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_greater_than.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_be_greater_than.sql", + "name": "test_expect_column_distinct_count_to_be_greater_than", + "macro_sql": "{% test expect_column_distinct_count_to_be_greater_than(model,\n column_name,\n value,\n group_by=None,\n row_condition=None\n ) %}\n{% set expression %}\ncount(distinct {{ column_name }}) > {{ value }}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition)\n }}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.599369, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_values_to_be_in_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_values_to_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_be_in_set.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_values_to_be_in_set.sql", + "name": "test_expect_column_distinct_values_to_be_in_set", + "macro_sql": "{% test expect_column_distinct_values_to_be_in_set(model,\n column_name,\n value_set,\n quote_values=True,\n row_condition=None\n ) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n),\nset_values as (\n\n {% for value in value_set -%}\n select\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif %} as value_field\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n\n),\nunique_set_values as (\n\n select distinct value_field\n from\n set_values\n\n),\nvalidation_errors as (\n -- values from the model that are not in the set\n select\n v.value_field\n from\n all_values v\n left join\n unique_set_values s on v.value_field = s.value_field\n where\n s.value_field is null\n\n)\n\nselect *\nfrom validation_errors\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": [] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.600217, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_distinct_count_to_equal_other_table": { + "unique_id": "macro.dbt_expectations.test_expect_column_distinct_count_to_equal_other_table", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal_other_table.sql", + "original_file_path": "macros/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal_other_table.sql", + "name": "test_expect_column_distinct_count_to_equal_other_table", + "macro_sql": "{% test expect_column_distinct_count_to_equal_other_table(model,\n compare_model,\n column_name,\n compare_column_name,\n row_condition=None,\n compare_row_condition=None\n ) %}\n{%- set expression -%}\ncount(distinct {{ column_name }})\n{%- endset -%}\n{%- set compare_expression -%}\n{%- if compare_column_name -%}\ncount(distinct {{ compare_column_name }})\n{%- else -%}\n{{ expression }}\n{%- endif -%}\n{%- endset -%}\n{{ dbt_expectations.test_equal_expression(\n model,\n expression=expression,\n compare_model=compare_model,\n compare_expression=compare_expression,\n row_condition=row_condition,\n compare_row_condition=compare_row_condition\n) }}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.test_equal_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6009421, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_row_values_to_have_data_for_every_n_datepart": { + "unique_id": "macro.dbt_expectations.test_expect_row_values_to_have_data_for_every_n_datepart", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_row_values_to_have_data_for_every_n_datepart.sql", + "original_file_path": "macros/schema_tests/distributional/expect_row_values_to_have_data_for_every_n_datepart.sql", + "name": "test_expect_row_values_to_have_data_for_every_n_datepart", + "macro_sql": "{%- test expect_row_values_to_have_data_for_every_n_datepart(model,\n date_col,\n date_part=\"day\",\n interval=None,\n row_condition=None,\n exclusion_condition=None,\n test_start_date=None,\n test_end_date=None) -%}\n{% if not execute %}\n {{ return('') }}\n{% endif %}\n\n{% if not test_start_date or not test_end_date %}\n {% set sql %}\n\n select\n min({{ date_col }}) as start_{{ date_part }},\n max({{ date_col }}) as end_{{ date_part }}\n from {{ model }}\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n\n {% endset %}\n\n {%- set dr = run_query(sql) -%}\n {%- set db_start_date = dr.columns[0].values()[0].strftime('%Y-%m-%d') -%}\n {%- set db_end_date = dr.columns[1].values()[0].strftime('%Y-%m-%d') -%}\n\n{% endif %}\n\n{% if not test_start_date %}\n{% set start_date = db_start_date %}\n{% else %}\n{% set start_date = test_start_date %}\n{% endif %}\n\n\n{% if not test_end_date %}\n{% set end_date = db_end_date %}\n{% else %}\n{% set end_date = test_end_date %}\n{% endif %}\nwith base_dates as (\n\n {{ dbt_date.get_base_dates(start_date=start_date, end_date=end_date, datepart=date_part) }}\n {% if interval %}\n {#\n Filter the date spine created above down to the interval granularity using a modulo operation.\n The number of date_parts after the start_date divided by the integer interval will produce no remainder for the desired intervals,\n e.g. for 2-day interval from a starting Jan 1, 2020:\n params: start_date = '2020-01-01', date_part = 'day', interval = 2\n date spine created above: [2020-01-01, 2020-01-02, 2020-01-03, 2020-01-04, 2020-01-05, ...]\n The first parameter to the `mod` function would be the number of days between the start_date and the spine date, i.e. [0, 1, 2, 3, 4 ...]\n The second parameter to the `mod` function would be the integer interval, i.e. 2\n This modulo operation produces the following remainders: [0, 1, 0, 1, 0, ...]\n Filtering the spine only where this remainder == 0 will return a spine with every other day as desired, i.e. [2020-01-01, 2020-01-03, 2020-01-05, ...]\n #}\n where mod(\n cast({{ dbt.datediff(\"'\" ~ start_date ~ \"'\", 'date_' ~ date_part, date_part) }} as {{ dbt.type_int() }}),\n cast({{interval}} as {{ dbt.type_int() }})\n ) = 0\n {% endif %}\n\n),\nmodel_data as (\n\n select\n {% if not interval %}\n\n cast({{ dbt.date_trunc(date_part, date_col) }} as {{ dbt_expectations.type_datetime() }}) as date_{{ date_part }},\n\n {% else %}\n {#\n Use a modulo operator to determine the number of intervals that a date_col is away from the interval-date spine\n and subtracts that amount to effectively slice each date_col record into its corresponding spine bucket,\n e.g. given a date_col of with records [2020-01-01, 2020-01-02, 2020-01-03, 2020-01-11, 2020-01-12]\n if we want to slice these dates into their 2-day buckets starting Jan 1, 2020 (start_date = '2020-01-01', date_part='day', interval=2),\n the modulo operation described above will produce these remainders: [0, 1, 0, 0, 1]\n subtracting that number of days from the observations will produce records [2020-01-01, 2020-01-01, 2020-01-03, 2020-01-11, 2020-01-11],\n all of which align with records from the interval-date spine\n #}\n {{ dbt.dateadd(\n date_part,\n \"mod(\n cast(\" ~ dbt.datediff(\"'\" ~ start_date ~ \"'\", date_col, date_part) ~ \" as \" ~ dbt.type_int() ~ \" ),\n cast(\" ~ interval ~ \" as \" ~ dbt.type_int() ~ \" )\n ) * (-1)\",\n \"cast( \" ~ dbt.date_trunc(date_part, date_col) ~ \" as \" ~ dbt_expectations.type_datetime() ~ \")\"\n )}} as date_{{ date_part }},\n\n {% endif %}\n\n count(*) as row_cnt\n from\n {{ model }} f\n {% if row_condition %}\n where {{ row_condition }}\n {% endif %}\n group by\n date_{{date_part}}\n\n),\n\nfinal as (\n\n select\n cast(d.date_{{ date_part }} as {{ dbt_expectations.type_datetime() }}) as date_{{ date_part }},\n case when f.date_{{ date_part }} is null then true else false end as is_missing,\n coalesce(f.row_cnt, 0) as row_cnt\n from\n base_dates d\n left join\n model_data f on cast(d.date_{{ date_part }} as {{ dbt_expectations.type_datetime() }}) = f.date_{{ date_part }}\n)\nselect\n *\nfrom final\nwhere row_cnt = 0\n{% if exclusion_condition %}\n and {{ exclusion_condition }}\n{% endif %}\n{%- endtest -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.run_query", + "macro.dbt_date.get_base_dates", + "macro.dbt.datediff", + "macro.dbt.type_int", + "macro.dbt.date_trunc", + "macro.dbt_expectations.type_datetime", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6045702, + "supported_languages": null + }, + "macro.dbt_expectations._get_metric_expression": { + "unique_id": "macro.dbt_expectations._get_metric_expression", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "name": "_get_metric_expression", + "macro_sql": "{%- macro _get_metric_expression(metric_column, take_logs) -%}\n\n{%- if take_logs %}\n{%- set expr = \"nullif(\" ~ metric_column ~ \", 0)\" -%}\ncoalesce({{ dbt_expectations.log_natural(expr) }}, 0)\n{%- else -%}\ncoalesce({{ metric_column }}, 0)\n{%- endif %}\n\n{%- endmacro -%}\n\n", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.log_natural"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6083379, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_within_n_moving_stdevs": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_within_n_moving_stdevs", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "name": "test_expect_column_values_to_be_within_n_moving_stdevs", + "macro_sql": "{% test expect_column_values_to_be_within_n_moving_stdevs(model,\n column_name,\n date_column_name,\n group_by=None,\n period='day',\n lookback_periods=1,\n trend_periods=7,\n test_periods=14,\n sigma_threshold=3,\n sigma_threshold_upper=None,\n sigma_threshold_lower=None,\n take_diffs=true,\n take_logs=true\n ) -%}\n {{ adapter.dispatch('test_expect_column_values_to_be_within_n_moving_stdevs', 'dbt_expectations') (model,\n column_name,\n date_column_name,\n group_by,\n period,\n lookback_periods,\n trend_periods,\n test_periods,\n sigma_threshold,\n sigma_threshold_upper,\n sigma_threshold_lower,\n take_diffs,\n take_logs\n ) }}\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6088388, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs": { + "unique_id": "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_moving_stdevs", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_moving_stdevs.sql", + "name": "default__test_expect_column_values_to_be_within_n_moving_stdevs", + "macro_sql": "{% macro default__test_expect_column_values_to_be_within_n_moving_stdevs(model,\n column_name,\n date_column_name,\n group_by,\n period,\n lookback_periods,\n trend_periods,\n test_periods,\n sigma_threshold,\n sigma_threshold_upper,\n sigma_threshold_lower,\n take_diffs,\n take_logs\n ) %}\n\n{%- set sigma_threshold_upper = sigma_threshold_upper if sigma_threshold_upper else sigma_threshold -%}\n{%- set sigma_threshold_lower = sigma_threshold_lower if sigma_threshold_lower else -1 * sigma_threshold -%}\n{%- set partition_by = \"partition by \" ~ (group_by | join(\",\")) if group_by -%}\n{%- set group_by_length = (group_by | length ) if group_by else 0 -%}\n\nwith metric_values as (\n\n with grouped_metric_values as (\n\n select\n {{ dbt.date_trunc(period, date_column_name) }} as metric_period,\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n sum({{ column_name }}) as agg_metric_value\n from\n {{ model }}\n {{ dbt_expectations.group_by(1 + group_by_length) }}\n\n )\n {%- if take_diffs %}\n , grouped_metric_values_with_priors as (\n\n select\n *,\n lag(agg_metric_value, {{ lookback_periods }}) over(\n {{ partition_by }}\n order by metric_period) as prior_agg_metric_value\n from\n grouped_metric_values d\n\n )\n select\n *,\n {{ dbt_expectations._get_metric_expression(\"agg_metric_value\", take_logs) }}\n -\n {{ dbt_expectations._get_metric_expression(\"prior_agg_metric_value\", take_logs) }}\n as metric_test_value\n from\n grouped_metric_values_with_priors d\n\n {%- else %}\n\n select\n *,\n {{ dbt_expectations._get_metric_expression(\"agg_metric_value\", take_logs) }}\n as metric_test_value\n from\n grouped_metric_values\n\n {%- endif %}\n\n),\nmetric_moving_calcs as (\n\n select\n *,\n avg(metric_test_value)\n over({{ partition_by }}\n order by metric_period rows\n between {{ trend_periods }} preceding and 1 preceding) as metric_test_rolling_average,\n stddev(metric_test_value)\n over({{ partition_by }}\n order by metric_period rows\n between {{ trend_periods }} preceding and 1 preceding) as metric_test_rolling_stddev\n from\n metric_values\n\n),\nmetric_sigma as (\n\n select\n *,\n (metric_test_value - metric_test_rolling_average) as metric_test_delta,\n (metric_test_value - metric_test_rolling_average)/\n nullif(metric_test_rolling_stddev, 0) as metric_test_sigma\n from\n metric_moving_calcs\n\n)\nselect\n *\nfrom\n metric_sigma\nwhere\n\n metric_period >= cast(\n {{ dbt.dateadd(period, -test_periods, dbt.date_trunc(period, dbt_date.now())) }}\n as {{ dbt_expectations.type_timestamp() }})\n and\n metric_period < {{ dbt.date_trunc(period, dbt_date.now()) }}\n and\n\n not (\n metric_test_sigma >= {{ sigma_threshold_lower }} and\n metric_test_sigma <= {{ sigma_threshold_upper }}\n )\n{%- endmacro -%}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt.date_trunc", + "macro.dbt_expectations.group_by", + "macro.dbt_expectations._get_metric_expression", + "macro.dbt.dateadd", + "macro.dbt_date.now", + "macro.dbt_expectations.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.610208, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_values_to_be_within_n_stdevs": { + "unique_id": "macro.dbt_expectations.test_expect_column_values_to_be_within_n_stdevs", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", + "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", + "name": "test_expect_column_values_to_be_within_n_stdevs", + "macro_sql": "{% test expect_column_values_to_be_within_n_stdevs(model,\n column_name,\n group_by=None,\n sigma_threshold=3\n ) -%}\n {{\n adapter.dispatch('test_expect_column_values_to_be_within_n_stdevs', 'dbt_expectations') (\n model, column_name, group_by, sigma_threshold\n )\n }}\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.611085, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs": { + "unique_id": "macro.dbt_expectations.default__test_expect_column_values_to_be_within_n_stdevs", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", + "original_file_path": "macros/schema_tests/distributional/expect_column_values_to_be_within_n_stdevs.sql", + "name": "default__test_expect_column_values_to_be_within_n_stdevs", + "macro_sql": "{% macro default__test_expect_column_values_to_be_within_n_stdevs(model,\n column_name,\n group_by,\n sigma_threshold\n ) %}\n\nwith metric_values as (\n\n select\n {{ group_by | join(\",\") ~ \",\" if group_by }}\n sum({{ column_name }}) as {{ column_name }}\n from\n {{ model }}\n {% if group_by -%}\n {{ dbt_expectations.group_by(group_by | length) }}\n {%- endif %}\n\n),\nmetric_values_with_statistics as (\n\n select\n *,\n avg({{ column_name }}) over() as {{ column_name }}_average,\n stddev({{ column_name }}) over() as {{ column_name }}_stddev\n from\n metric_values\n\n),\nmetric_values_z_scores as (\n\n select\n *,\n ({{ column_name }} - {{ column_name }}_average)/\n nullif({{ column_name }}_stddev, 0) as {{ column_name }}_sigma\n from\n metric_values_with_statistics\n\n)\nselect\n *\nfrom\n metric_values_z_scores\nwhere\n abs({{ column_name }}_sigma) > {{ sigma_threshold }}\n{%- endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.group_by"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.61159, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_select_column_values_to_be_unique_within_record": { + "unique_id": "macro.dbt_expectations.test_expect_select_column_values_to_be_unique_within_record", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", + "name": "test_expect_select_column_values_to_be_unique_within_record", + "macro_sql": "{% test expect_select_column_values_to_be_unique_within_record(model,\n column_list,\n quote_columns=False,\n ignore_row_if=\"all_values_are_missing\",\n row_condition=None\n ) -%}\n {{ adapter.dispatch('test_expect_select_column_values_to_be_unique_within_record', 'dbt_expectations') (model, column_list, quote_columns, ignore_row_if, row_condition) }}\n{%- endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": [ + "macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record" + ] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.612949, + "supported_languages": null + }, + "macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record": { + "unique_id": "macro.dbt_expectations.default__test_expect_select_column_values_to_be_unique_within_record", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_select_column_values_to_be_unique_within_record.sql", + "name": "default__test_expect_select_column_values_to_be_unique_within_record", + "macro_sql": "{% macro default__test_expect_select_column_values_to_be_unique_within_record(model,\n column_list,\n quote_columns,\n ignore_row_if,\n row_condition\n ) %}\n\n{% if not quote_columns %}\n {%- set columns=column_list %}\n{% elif quote_columns %}\n {%- set columns=[] %}\n {% for column in column_list -%}\n {% set columns = columns.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote_columns ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set row_condition_ext -%}\n\n {%- if row_condition %}\n {{ row_condition }} and\n {% endif -%}\n\n {{ dbt_expectations.ignore_row_if_expression(ignore_row_if, columns) }}\n\n{%- endset -%}\n\nwith column_values as (\n\n select\n row_number() over(order by 1) as row_index,\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n from {{ model }}\n where\n 1=1\n {%- if row_condition_ext %}\n and {{ row_condition_ext }}\n {% endif %}\n\n),\nunpivot_columns as (\n\n {% for column in columns %}\n select row_index, '{{ column }}' as column_name, {{ column }} as column_value from column_values\n {% if not loop.last %}union all{% endif %}\n {% endfor %}\n),\nvalidation_errors as (\n\n select\n row_index,\n count(distinct column_value) as column_values\n from unpivot_columns\n group by 1\n having count(distinct column_value) < {{ columns | length }}\n\n)\nselect * from validation_errors\n{% endmacro %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.ignore_row_if_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6139462, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_compound_columns_to_be_unique": { + "unique_id": "macro.dbt_expectations.test_expect_compound_columns_to_be_unique", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_compound_columns_to_be_unique.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_compound_columns_to_be_unique.sql", + "name": "test_expect_compound_columns_to_be_unique", + "macro_sql": "{% test expect_compound_columns_to_be_unique(model,\n column_list,\n quote_columns=False,\n ignore_row_if=\"all_values_are_missing\",\n row_condition=None\n ) %}\n{% if not column_list %}\n {{ exceptions.raise_compiler_error(\n \"`column_list` must be specified as a list of columns. Got: '\" ~ column_list ~\"'.'\"\n ) }}\n{% endif %}\n\n{% if not quote_columns %}\n {%- set columns=column_list %}\n{% elif quote_columns %}\n {%- set columns=[] %}\n {% for column in column_list -%}\n {% set columns = columns.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for expect_compound_columns_to_be_unique test must be one of [True, False] Got: '\" ~ quote_columns ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set row_condition_ext -%}\n\n {%- if row_condition %}\n {{ row_condition }} and\n {% endif -%}\n\n {{ dbt_expectations.ignore_row_if_expression(ignore_row_if, columns) }}\n\n{%- endset -%}\n\nwith validation_errors as (\n\n select\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n from {{ model }}\n where\n 1=1\n {%- if row_condition_ext %}\n and {{ row_condition_ext }}\n {% endif %}\n group by\n {% for column in columns -%}\n {{ column }}{% if not loop.last %},{% endif %}\n {%- endfor %}\n having count(*) > 1\n\n)\nselect * from validation_errors\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { + "macros": ["macro.dbt_expectations.ignore_row_if_expression"] + }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.6157582, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_multicolumn_sum_to_equal": { + "unique_id": "macro.dbt_expectations.test_expect_multicolumn_sum_to_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_multicolumn_sum_to_equal.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_multicolumn_sum_to_equal.sql", + "name": "test_expect_multicolumn_sum_to_equal", + "macro_sql": "{% test expect_multicolumn_sum_to_equal(model,\n column_list,\n sum_total,\n group_by=None,\n row_condition=None\n ) %}\n\n{% set expression %}\n{% for column in column_list %}\nsum({{ column }}){% if not loop.last %} + {% endif %}\n{% endfor %} = {{ sum_total }}\n{% endset %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=group_by,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.616595, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_pair_values_to_be_equal": { + "unique_id": "macro.dbt_expectations.test_expect_column_pair_values_to_be_equal", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_equal.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_equal.sql", + "name": "test_expect_column_pair_values_to_be_equal", + "macro_sql": "{% test expect_column_pair_values_to_be_equal(model,\n column_A,\n column_B,\n row_condition=None\n ) %}\n\n{% set operator = \"=\" %}\n{% set expression = column_A ~ \" \" ~ operator ~ \" \" ~ column_B %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.617192, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_pair_values_A_to_be_greater_than_B": { + "unique_id": "macro.dbt_expectations.test_expect_column_pair_values_A_to_be_greater_than_B", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_column_pair_values_A_to_be_greater_than_B.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_A_to_be_greater_than_B.sql", + "name": "test_expect_column_pair_values_A_to_be_greater_than_B", + "macro_sql": "{% test expect_column_pair_values_A_to_be_greater_than_B(model,\n column_A,\n column_B,\n or_equal=False,\n row_condition=None\n ) %}\n\n{% set operator = \">=\" if or_equal else \">\" %}\n{% set expression = column_A ~ \" \" ~ operator ~ \" \" ~ column_B %}\n\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.617835, + "supported_languages": null + }, + "macro.dbt_expectations.test_expect_column_pair_values_to_be_in_set": { + "unique_id": "macro.dbt_expectations.test_expect_column_pair_values_to_be_in_set", + "package_name": "dbt_expectations", + "root_path": "/Users/ericlaurello/git/livequery-models/dbt_packages/dbt_expectations", + "path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_in_set.sql", + "original_file_path": "macros/schema_tests/multi-column/expect_column_pair_values_to_be_in_set.sql", + "name": "test_expect_column_pair_values_to_be_in_set", + "macro_sql": "{% test expect_column_pair_values_to_be_in_set(model,\n column_A,\n column_B,\n value_pairs_set,\n row_condition=None\n ) %}\n\n{% set expression %}\n{% for pair in value_pairs_set %}\n{%- if (pair | length) == 2 %}\n({{ column_A }} = {{ pair[0] }} and {{ column_B }} = {{ pair[1] }}){% if not loop.last %} or {% endif %}\n{% else %}\n{{ exceptions.raise_compiler_error(\n \"`value_pairs_set` argument for expect_column_pair_values_to_be_in_set test cannot have more than 2 item per element.\n Got: '\" ~ pair ~ \"'.'\"\n ) }}\n{% endif %}\n{% endfor %}\n{% endset %}\n{{ dbt_expectations.expression_is_true(model,\n expression=expression,\n group_by_columns=None,\n row_condition=row_condition\n )\n }}\n\n{% endtest %}", + "resource_type": "macro", + "tags": [], + "depends_on": { "macros": ["macro.dbt_expectations.expression_is_true"] }, + "description": "", + "meta": {}, + "docs": { "show": true, "node_color": null }, + "patch_path": null, + "arguments": [], + "created_at": 1675954222.619081, + "supported_languages": null + } + }, + "docs": { + "dbt.__overview__": { + "unique_id": "dbt.__overview__", + "package_name": "dbt", + "root_path": "/Users/ericlaurello/dbt-env/lib/python3.10/site-packages/dbt/include/global_project", + "path": "overview.md", + "original_file_path": "docs/overview.md", + "name": "__overview__", + "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion" + } + }, + "exposures": {}, + "metrics": {}, + "selectors": {}, + "disabled": {}, + "parent_map": { + "operation.livequery_models.livequery_models-on-run-start-0": [], + "operation.livequery_models.livequery_models-on-run-end-0": [], + "source.livequery_models.crosschain.dim_date_hours": [] + }, + "child_map": { + "operation.livequery_models.livequery_models-on-run-start-0": [], + "operation.livequery_models.livequery_models-on-run-end-0": [], + "source.livequery_models.crosschain.dim_date_hours": [] + } +} diff --git a/macros/create_sps.sql b/macros/create_sps.sql index 2404546..f4536c6 100644 --- a/macros/create_sps.sql +++ b/macros/create_sps.sql @@ -1,5 +1,5 @@ {% macro create_sps() %} - {% if var("UPDATE_UDFS_AND_SPS") %} + {% if var("LQ_UPDATE_UDFS_AND_SPS") %} {% if target.database == 'LIVEQUERY' %} CREATE schema IF NOT EXISTS _internal; {{ sp_create_prod_clone('_internal') }}; diff --git a/macros/livequery/manage_udfs.sql b/macros/livequery/manage_udfs.sql index b5b656f..fedd21b 100644 --- a/macros/livequery/manage_udfs.sql +++ b/macros/livequery/manage_udfs.sql @@ -152,7 +152,7 @@ This macro is used to deploy functions using ephemeral models. It should only be used within an ephemeral model. #} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {{- crud_udfs(config, this.schema, var("DROP_UDFS_AND_SPS")) -}} {%- endset -%} @@ -174,7 +174,7 @@ {%- set blockchain = this.schema -%} {%- set network = this.identifier -%} {% set schema = blockchain ~ "_" ~ network %} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_chain(config, blockchain, network, var("DROP_UDFS_AND_SPS")) -}} @@ -197,7 +197,7 @@ #} {%- set schema = this.schema -%} {%- set utility_schema = this.identifier -%} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_marketplace(config, schema, utility_schema, var("DROP_UDFS_AND_SPS")) -}} diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 76c990b..e53bb99 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -38,7 +38,7 @@ - [block_id, INTEGER, The start block height to get the blocks from] - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] return_type: - - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result VARIANT, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask VARIANT, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask VARIANT, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" options: | NOT NULL RETURNS NULL ON NULL INPUT @@ -47,5 +47,19 @@ sql: | {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} +- name: {{ schema -}}.tf_fact_blocks_poc + signature: + - [block_id, INTEGER, The start block height to get the blocks from] + - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] + return_type: + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" + options: | + NOT NULL + RETURNS NULL ON NULL INPUT + VOLATILE + COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block_id height is reached.$$ + sql: | + {{ near_live_view_fact_blocks_poc(schema, blockchain, network) | indent(4) -}} + {%- endmacro -%} diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index e23c3dc..dffd8dc 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -122,6 +122,14 @@ SELECT yield from results {% endmacro %} +{% macro generate_spine_cte() %} +WITH spine AS ( + SELECT + block_height + FROM TABLE(FLATTEN(input => PARSE_JSON({% raw %}'{{ block_heights }}'{% endraw %}))) +) +{% endmacro %} + {% macro near_live_view_udf_get_block_data() %} import json from snowflake.snowpark.files import SnowflakeFile @@ -221,13 +229,89 @@ WITH block_urls AS ( GROUP BY s.block_height ) SELECT - u.block_height, - b.block_data + b.block_data:header:height::NUMBER(38,0) as block_id, + md5(cast(coalesce(cast(b.block_data:header:height::NUMBER(38,0) as TEXT), '_dbt_utils_surrogate_key_null_') as TEXT)) as streamline_blocks_id, + TO_TIMESTAMP_NTZ(b.block_data:header:timestamp::STRING) as block_timestamp, + b.block_data:header:hash::STRING as block_hash, + ARRAY_SIZE(b.block_data:chunks)::STRING as tx_count, + b.block_data:author::STRING as block_author, + b.block_data:header:chunks as chunks, + b.block_data:header:epoch_id::STRING as epoch_id, + b.block_data:header:events as events, + b.block_data:header:gas_price::NUMBER(38,0) as gas_price, + b.block_data:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, + b.block_data:header:next_epoch_id::STRING as next_epoch_id, + b.block_data:header:prev_hash::STRING as prev_hash, + b.block_data:header:total_supply::NUMBER(38,0) as total_supply, + b.block_data:header:validator_proposals as validator_proposals, + b.block_data:header:validator_reward::NUMBER(38,0) as validator_reward, + SYSDATE()::TIMESTAMP_NTZ(9) as inserted_timestamp, + SYSDATE()::TIMESTAMP_NTZ(9) as _inserted_timestamp, + SYSDATE()::TIMESTAMP_NTZ(9) as modified_timestamp, + b.block_data as header FROM block_urls u, TABLE({{ schema }}.tf_get_block_data(u.urls)) b {% endmacro %} -- Get Near fact data +{% macro get_fact_blocks_transformations(schema) %} + {% set get_view_sql %} + SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks_poc') + {% endset %} + + {% set results = run_query(get_view_sql) %} + {% set view_ddl = results.rows[0][0] %} + + -- Find the inner SELECT with all the transformations + {% set select_pos = view_ddl.find('SELECT\n block_id') %} + {% set from_pos = view_ddl.find('\nFROM\n blocks') %} + + -- Extract just the transformations part + {% set transformations = view_ddl[select_pos + 6:from_pos].strip() %} + + {% do log("Extracted transformations: " ~ transformations, info=True) %} + + {{ return(transformations) }} +{% endmacro %} +{# {% macro get_fact_blocks_transformations(schema) %} + {% set get_view_sql %} + SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks_poc') + {% endset %} + + {% set results = run_query(get_view_sql) %} + + {% set view_ddl = results.rows[0][0] %} + + -- Find the main SELECT statement (after the CTE) + {% set select_pos = view_ddl.upper().rfind('SELECT') %} + {% set from_pos = view_ddl.upper().rfind('FROM') %} + + -- Extract everything between SELECT and FROM + {% set transformations = view_ddl[select_pos + 6:from_pos].strip() %} + + -- Debug the extracted transformations + {% do log("Extracted transformations: " ~ transformations, info=True) %} + + {{ return(transformations) }} +{% endmacro %} #} + +{% macro near_live_view_fact_blocks_poc(schema, blockchain, network) %} +WITH heights AS ( + {{ near_live_view_latest_block_height() | indent(4) }} +), +spine AS ( + {{ near_live_view_get_spine('heights') | indent(4) }} +), +raw_blocks AS ( + {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} +) +SELECT + {{ get_fact_blocks_transformations(schema) }} +FROM raw_blocks + +{% endmacro %} + + {% macro near_live_view_fact_blocks(schema, blockchain, network) %} {# This macro generates a SQL query to fetch and transform NEAR blockchain block data. @@ -250,43 +334,43 @@ raw_blocks AS ( {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} ) SELECT - block_data:header:height::NUMBER(38,0) as block_id, - TO_TIMESTAMP_NTZ(block_data:header:timestamp::STRING) as block_timestamp, - block_data:header:hash::STRING as block_hash, - ARRAY_SIZE(block_data:chunks)::STRING as tx_count, - block_data:author::STRING as block_author, - block_data:header as header, - block_data:header:challenges_result as block_challenges_result, - block_data:header:challenges_root::STRING as block_challenges_root, - block_data:header:chunk_headers_root::STRING as chunk_headers_root, - block_data:header:chunk_tx_root::STRING as chunk_tx_root, - block_data:header:chunk_mask as chunk_mask, - block_data:header:chunk_receipts_root::STRING as chunk_receipts_root, - block_data:chunks as chunks, - block_data:header:chunks_included::NUMBER(38,0) as chunks_included, - block_data:header:epoch_id::STRING as epoch_id, - block_data:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, - block_data:events as events, - block_data:header:gas_price::NUMBER(38,0) as gas_price, - block_data:header:last_ds_final_block::STRING as last_ds_final_block, - block_data:header:last_final_block::STRING as last_final_block, - block_data:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, - block_data:header:next_bp_hash::STRING as next_bp_hash, - block_data:header:next_epoch_id::STRING as next_epoch_id, - block_data:header:outcome_root::STRING as outcome_root, - block_data:header:prev_hash::STRING as prev_hash, - block_data:header:prev_height::NUMBER(38,0) as prev_height, - block_data:header:prev_state_root::STRING as prev_state_root, - block_data:header:random_value::STRING as random_value, - block_data:header:rent_paid::FLOAT as rent_paid, - block_data:header:signature::STRING as signature, - block_data:header:total_supply::NUMBER(38,0) as total_supply, - block_data:header:validator_proposals as validator_proposals, - block_data:header:validator_reward::NUMBER(38,0) as validator_reward, - MD5(block_data:header:height::STRING)::VARCHAR(32) as fact_blocks_id, + header:header:height::NUMBER(38,0) as block_id, + TO_TIMESTAMP_NTZ(header:header:timestamp::STRING) as block_timestamp, + header:header:hash::STRING as block_hash, + ARRAY_SIZE(header:chunks)::STRING as tx_count, + header:author::STRING as block_author, + header:header as header, + header:header:challenges_result::ARRAY as block_challenges_result, + header:header:challenges_root::STRING as block_challenges_root, + header:header:chunk_headers_root::STRING as chunk_headers_root, + header:header:chunk_tx_root::STRING as chunk_tx_root, + header:header:chunk_mask as chunk_mask, + header:header:chunk_receipts_root::STRING as chunk_receipts_root, + header:chunks as chunks, + header:header:chunks_included::NUMBER(38,0) as chunks_included, + header:header:epoch_id::STRING as epoch_id, + header:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, + header:events as events, + header:header:gas_price::NUMBER(38,0) as gas_price, + header:header:last_ds_final_block::STRING as last_ds_final_block, + header:header:last_final_block::STRING as last_final_block, + header:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, + header:header:next_bp_hash::STRING as next_bp_hash, + header:header:next_epoch_id::STRING as next_epoch_id, + header:header:outcome_root::STRING as outcome_root, + header:header:prev_hash::STRING as prev_hash, + header:header:prev_height::NUMBER(38,0) as prev_height, + header:header:prev_state_root::STRING as prev_state_root, + header:header:random_value::STRING as random_value, + header:header:rent_paid::FLOAT as rent_paid, + header:header:signature::STRING as signature, + header:header:total_supply::NUMBER(38,0) as total_supply, + header:header:validator_proposals as validator_proposals, + header:header:validator_reward::NUMBER(38,0) as validator_reward, + MD5(header:header:height::STRING)::VARCHAR(32) as fact_blocks_id, SYSDATE()::TIMESTAMP_NTZ(9) as inserted_timestamp, SYSDATE()::TIMESTAMP_NTZ(9) as modified_timestamp FROM raw_blocks -WHERE block_data IS NOT NULL +WHERE header IS NOT NULL {% endmacro %} diff --git a/models/deploy/near/near__mainnet.sql b/models/deploy/near/near__mainnet.sql index 78f035d..747ff37 100644 --- a/models/deploy/near/near__mainnet.sql +++ b/models/deploy/near/near__mainnet.sql @@ -1,3 +1,4 @@ + -- depends_on: {{ ref('near_models','core__fact_blocks') }} {%- set configs = [ config_near_high_level_abstractions ] -%} diff --git a/models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql new file mode 100644 index 0000000..f7bd797 --- /dev/null +++ b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql @@ -0,0 +1,6 @@ +-- models/tests/test_fact_blocks_transformations.sql +{{ config( + materialized = 'view' +) }} + +SELECT * FROM {{ ref('near_models','core__fact_blocks')}} \ No newline at end of file diff --git a/models/doc_descriptions/integration/__overview__.md b/models/doc_descriptions/integration/__overview__.md index 9c0c0a1..d2002c7 100644 --- a/models/doc_descriptions/integration/__overview__.md +++ b/models/doc_descriptions/integration/__overview__.md @@ -46,9 +46,9 @@ Within the same directory (`models/deploy/marketplace/`), create a new folder fo Deploy your model following the standard deployment procedures. -- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` +- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` -- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` +- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` #### Additional Tips: diff --git a/models/sources.yml b/models/sources.yml index 9ffdd84..a688666 100644 --- a/models/sources.yml +++ b/models/sources.yml @@ -13,4 +13,9 @@ sources: schema: core tables: - name: fact_event_logs - - name: ez_decoded_event_logs \ No newline at end of file + - name: ez_decoded_event_logs + - name: near_models + database: "{{ 'near' if target.database == 'LIVEQUERY' else 'near_dev' }}" + schema: core + tables: + - name: fact_blocks \ No newline at end of file diff --git a/package-lock.yml b/package-lock.yml new file mode 100644 index 0000000..44a1cd4 --- /dev/null +++ b/package-lock.yml @@ -0,0 +1,12 @@ +packages: +- package: calogica/dbt_expectations + version: 0.8.2 +- package: dbt-labs/dbt_utils + version: 1.0.0 +- git: https://github.com/FlipsideCrypto/near-models-nlq.git + revision: f1edb8a0a851ca6e1b6297405122cc486f5c928b +- package: calogica/dbt_date + version: 0.7.2 +- package: get-select/dbt_snowflake_query_tags + version: 2.5.0 +sha1_hash: 146672df7bff15c1dc58878075c1b99e298ff914 From 606f75da233383ec8e00a18bbd432d64ab6a2739 Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 25 Nov 2024 12:04:47 -0800 Subject: [PATCH 14/18] revert UPDATE_UDFS_AND_SPS envar --- Makefile | 4 ++-- README.md | 8 ++++---- dbt_project.yml | 2 +- docs/manifest.json | 4 ++-- macros/create_sps.sql | 2 +- macros/livequery/manage_udfs.sql | 6 +++--- models/doc_descriptions/integration/__overview__.md | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 59bcc73..7ba261d 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ rm_logs: deploy_near_mainnet_lv: rm_logs dbt run \ -s livequery_models.deploy.near.near__mainnet \ - --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ + --vars '{UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ --target dev @@ -25,7 +25,7 @@ compile_near_mainnet: rm_logs deploy_fact_blocks_poc: rm_logs dbt run \ -s livequery_models.deploy.near.silver.streamline.near_mainnet__fact_blocks_poc \ - --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ + --vars '{UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ --target dev \ No newline at end of file diff --git a/README.md b/README.md index 6306ed4..4e64cd9 100644 --- a/README.md +++ b/README.md @@ -462,20 +462,20 @@ livequery: To control the creation of UDF or SP macros with dbt run: -* LQ_UPDATE_UDFS_AND_SPS +* UPDATE_UDFS_AND_SPS When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal When False, none of the on-run-start macros are executed on model run Default values are False * Usage: -`dbt run --var '{"LQ_UPDATE_UDFS_AND_SPS":True}' -m ...` +`dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...` Dropping and creating udfs can also be done without running a model: ```sh -dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' -dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' +dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' +dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' ``` ## Resources diff --git a/dbt_project.yml b/dbt_project.yml index 12541e7..e62456a 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -81,7 +81,7 @@ vars: UPDATE_UDFS_AND_SPS: false "dbt_date:time_zone": GMT - LQ_UPDATE_UDFS_AND_SPS: false + UPDATE_UDFS_AND_SPS: false DROP_UDFS_AND_SPS: false UPDATE_SNOWFLAKE_TAGS: true STREAMLINE_INVOKE_STREAMS: False diff --git a/docs/manifest.json b/docs/manifest.json index 346af5b..6b813bc 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -189,7 +189,7 @@ "path": "macros/create_sps.sql", "original_file_path": "macros/create_sps.sql", "name": "create_sps", - "macro_sql": "{% macro create_sps() %}\n {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", + "macro_sql": "{% macro create_sps() %}\n {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": { @@ -267,7 +267,7 @@ "path": "macros/create_udfs.sql", "original_file_path": "macros/create_udfs.sql", "name": "create_udfs", - "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", + "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": { "macros": ["macro.dbt.run_query"] }, diff --git a/macros/create_sps.sql b/macros/create_sps.sql index f4536c6..2404546 100644 --- a/macros/create_sps.sql +++ b/macros/create_sps.sql @@ -1,5 +1,5 @@ {% macro create_sps() %} - {% if var("LQ_UPDATE_UDFS_AND_SPS") %} + {% if var("UPDATE_UDFS_AND_SPS") %} {% if target.database == 'LIVEQUERY' %} CREATE schema IF NOT EXISTS _internal; {{ sp_create_prod_clone('_internal') }}; diff --git a/macros/livequery/manage_udfs.sql b/macros/livequery/manage_udfs.sql index fedd21b..b5b656f 100644 --- a/macros/livequery/manage_udfs.sql +++ b/macros/livequery/manage_udfs.sql @@ -152,7 +152,7 @@ This macro is used to deploy functions using ephemeral models. It should only be used within an ephemeral model. #} - {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {{- crud_udfs(config, this.schema, var("DROP_UDFS_AND_SPS")) -}} {%- endset -%} @@ -174,7 +174,7 @@ {%- set blockchain = this.schema -%} {%- set network = this.identifier -%} {% set schema = blockchain ~ "_" ~ network %} - {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_chain(config, blockchain, network, var("DROP_UDFS_AND_SPS")) -}} @@ -197,7 +197,7 @@ #} {%- set schema = this.schema -%} {%- set utility_schema = this.identifier -%} - {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_marketplace(config, schema, utility_schema, var("DROP_UDFS_AND_SPS")) -}} diff --git a/models/doc_descriptions/integration/__overview__.md b/models/doc_descriptions/integration/__overview__.md index d2002c7..9c0c0a1 100644 --- a/models/doc_descriptions/integration/__overview__.md +++ b/models/doc_descriptions/integration/__overview__.md @@ -46,9 +46,9 @@ Within the same directory (`models/deploy/marketplace/`), create a new folder fo Deploy your model following the standard deployment procedures. -- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` +- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` -- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` +- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` #### Additional Tips: From e4db1e06859af32b973f8502ac356544979c8521 Mon Sep 17 00:00:00 2001 From: shah Date: Tue, 26 Nov 2024 16:40:57 -0800 Subject: [PATCH 15/18] finalize udf_get_block_data | update tf_fact_block macros --- Makefile | 8 +- README.md | 8 +- dbt_project.yml | 2 +- docs/manifest.json | 4 +- macros/create_sps.sql | 2 +- macros/livequery/manage_udfs.sql | 6 +- macros/near/near.yaml.sql | 30 +- macros/near/near_live_views.sql | 282 +++--------------- ..._poc.sql => near_mainnet__fact_blocks.sql} | 3 +- .../integration/__overview__.md | 4 +- 10 files changed, 62 insertions(+), 287 deletions(-) rename models/deploy/near/silver/streamline/{near_mainnet__fact_blocks_poc.sql => near_mainnet__fact_blocks.sql} (63%) diff --git a/Makefile b/Makefile index 7ba261d..d4d6b12 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ rm_logs: deploy_near_mainnet_lv: rm_logs dbt run \ -s livequery_models.deploy.near.near__mainnet \ - --vars '{UPDATE_UDFS_AND_SPS: true}' \ + --vars '{LQ_UPDATE_UDFS_AND_SPS: true, UPDATE_UDFS_AND_SPS: false}' \ --profiles-dir ~/.dbt \ --profile livequery \ --target dev @@ -22,10 +22,10 @@ compile_near_mainnet: rm_logs --profile livequery \ --target dev -deploy_fact_blocks_poc: rm_logs +deploy_fact_blocks: rm_logs dbt run \ - -s livequery_models.deploy.near.silver.streamline.near_mainnet__fact_blocks_poc \ - --vars '{UPDATE_UDFS_AND_SPS: true}' \ + -s livequery_models.deploy.near.silver.streamline.near_mainnet__fact_blocks \ + --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ --target dev \ No newline at end of file diff --git a/README.md b/README.md index 4e64cd9..6306ed4 100644 --- a/README.md +++ b/README.md @@ -462,20 +462,20 @@ livequery: To control the creation of UDF or SP macros with dbt run: -* UPDATE_UDFS_AND_SPS +* LQ_UPDATE_UDFS_AND_SPS When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal When False, none of the on-run-start macros are executed on model run Default values are False * Usage: -`dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...` +`dbt run --var '{"LQ_UPDATE_UDFS_AND_SPS":True}' -m ...` Dropping and creating udfs can also be done without running a model: ```sh -dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' -dbt run-operation create_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' +dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":false}' +dbt run-operation create_udfs --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}' --args '{"drop_":true}' ``` ## Resources diff --git a/dbt_project.yml b/dbt_project.yml index e62456a..12541e7 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -81,7 +81,7 @@ vars: UPDATE_UDFS_AND_SPS: false "dbt_date:time_zone": GMT - UPDATE_UDFS_AND_SPS: false + LQ_UPDATE_UDFS_AND_SPS: false DROP_UDFS_AND_SPS: false UPDATE_SNOWFLAKE_TAGS: true STREAMLINE_INVOKE_STREAMS: False diff --git a/docs/manifest.json b/docs/manifest.json index 6b813bc..346af5b 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -189,7 +189,7 @@ "path": "macros/create_sps.sql", "original_file_path": "macros/create_sps.sql", "name": "create_sps", - "macro_sql": "{% macro create_sps() %}\n {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", + "macro_sql": "{% macro create_sps() %}\n {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n {% if target.database == 'LIVEQUERY' %}\n CREATE schema IF NOT EXISTS _internal;\n {{ sp_create_prod_clone('_internal') }};\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": { @@ -267,7 +267,7 @@ "path": "macros/create_udfs.sql", "original_file_path": "macros/create_udfs.sql", "name": "create_udfs", - "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", + "macro_sql": "{% macro create_udfs() %}\n-- {% if var(\"LQ_UPDATE_UDFS_AND_SPS\") %}\n-- {% set sql %}\n-- CREATE schema if NOT EXISTS silver;\n-- {% endset %}\n-- {% do run_query(sql) %}\n-- {% endif %}\n-- {% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": { "macros": ["macro.dbt.run_query"] }, diff --git a/macros/create_sps.sql b/macros/create_sps.sql index 2404546..f4536c6 100644 --- a/macros/create_sps.sql +++ b/macros/create_sps.sql @@ -1,5 +1,5 @@ {% macro create_sps() %} - {% if var("UPDATE_UDFS_AND_SPS") %} + {% if var("LQ_UPDATE_UDFS_AND_SPS") %} {% if target.database == 'LIVEQUERY' %} CREATE schema IF NOT EXISTS _internal; {{ sp_create_prod_clone('_internal') }}; diff --git a/macros/livequery/manage_udfs.sql b/macros/livequery/manage_udfs.sql index b5b656f..fedd21b 100644 --- a/macros/livequery/manage_udfs.sql +++ b/macros/livequery/manage_udfs.sql @@ -152,7 +152,7 @@ This macro is used to deploy functions using ephemeral models. It should only be used within an ephemeral model. #} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {{- crud_udfs(config, this.schema, var("DROP_UDFS_AND_SPS")) -}} {%- endset -%} @@ -174,7 +174,7 @@ {%- set blockchain = this.schema -%} {%- set network = this.identifier -%} {% set schema = blockchain ~ "_" ~ network %} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_chain(config, blockchain, network, var("DROP_UDFS_AND_SPS")) -}} @@ -197,7 +197,7 @@ #} {%- set schema = this.schema -%} {%- set utility_schema = this.identifier -%} - {% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} + {% if execute and (var("LQ_UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %} {% set sql %} {% for config in configs %} {{- crud_udfs_by_marketplace(config, schema, utility_schema, var("DROP_UDFS_AND_SPS")) -}} diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index e53bb99..2fba148 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -9,7 +9,7 @@ signature: - [file_url, STRING, File URL created using BUILD_SCOPED_FILE_URL() snowflake internal function] return_type: - - VARIANT + - STRING options: | LANGUAGE PYTHON RUNTIME_VERSION = '3.11' @@ -19,20 +19,6 @@ sql: | {{ near_live_view_udf_get_block_data() | indent(4) -}} -- name: {{ schema -}}.tf_get_block_data - signature: - - [file_urls, ARRAY, List of stage file URLs created using BUILD_SCOPED_FILE_URL() snowflake internal function] - return_type: - - "TABLE(block_data VARIANT)" - options: | - LANGUAGE PYTHON - RUNTIME_VERSION = '3.11' - PACKAGES = ('snowflake-snowpark-python') - HANDLER = 'GetBlockData' - COMMENT = $$A UDTF to retrieve NEAR block data stored in files from the Near Lake Snowflake External Stage.$$ - sql: | - {{ near_live_view_get_block_data() | indent(4) -}} - - name: {{ schema -}}.tf_fact_blocks signature: - [block_id, INTEGER, The start block height to get the blocks from] @@ -47,19 +33,5 @@ sql: | {{ near_live_view_fact_blocks(schema, blockchain, network) | indent(4) -}} -- name: {{ schema -}}.tf_fact_blocks_poc - signature: - - [block_id, INTEGER, The start block height to get the blocks from] - - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] - return_type: - - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" - options: | - NOT NULL - RETURNS NULL ON NULL INPUT - VOLATILE - COMMENT = $$Returns the block data for a given block height. If to_latest is true, it will continue fetching blocks until the latest block. Otherwise, it will fetch blocks until the block_id height is reached.$$ - sql: | - {{ near_live_view_fact_blocks_poc(schema, blockchain, network) | indent(4) -}} - {%- endmacro -%} diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index dffd8dc..be08daa 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -31,107 +31,20 @@ SELECT ) as max_height {% endmacro %} -{% macro near_live_view_get_block_data() %} - import json - from typing import Iterator, Tuple - from snowflake.snowpark.files import SnowflakeFile - import multiprocessing as mp - from queue import Queue - from threading import Thread - - class GetBlockData: - """ - A class to retrieve and process multiple NEAR block data files from a Snowflake External Stage. - Uses threading from standard library for concurrent processing. - - The implementation uses a thread pool pattern with a work queue for better resource management - and controlled concurrency. - """ - - def __init__(self): - self.num_workers = min(10, mp.cpu_count() * 2) # Number of worker threads - self.chunk_size = 50 # Process files in chunks - - def _process_file(self, file_url: str) -> Tuple[dict]: - """Process a single file from the stage.""" - try: - with SnowflakeFile.open(file_url) as file: - block_data = json.load(file) - return (block_data,) - except json.JSONDecodeError as e: - return ({ - 'error': 'JSONDecodeError', - 'details': f'Invalid JSON data: {str(e)}', - 'url': file_url - },) - except Exception as e: - return ({ - 'error': e.__class__.__name__, - 'details': str(e), - 'url': file_url - },) - - def _worker(self, queue: Queue, results: list): - """Worker thread to process files from the queue.""" - while True: - file_url = queue.get() - if file_url is None: # Poison pill - break - result = self._process_file(file_url) - results.append(result) - queue.task_done() - - def process(self, file_urls: list) -> Iterator[Tuple[dict]]: - """ - Process multiple block data files using a thread pool. - - Args: - file_urls (list): List of stage file URLs to process - - Yields: - Iterator[Tuple[dict]]: Processed block data or error information - """ - # Process files in chunks to manage memory - for i in range(0, len(file_urls), self.chunk_size): - chunk = file_urls[i:i + self.chunk_size] - - # Set up the thread pool - queue = Queue() - results = [] - threads = [] - - # Start worker threads - for _ in range(self.num_workers): - t = Thread(target=self._worker, args=(queue, results)) - t.start() - threads.append(t) - - # Add work to the queue - for url in chunk: - queue.put(url) - - # Add poison pills to stop workers - for _ in range(self.num_workers): - queue.put(None) - - # Wait for all work to complete - for t in threads: - t.join() - - # Yield results - yield from results -{% endmacro %} - -{% macro generate_spine_cte() %} -WITH spine AS ( - SELECT - block_height - FROM TABLE(FLATTEN(input => PARSE_JSON({% raw %}'{{ block_heights }}'{% endraw %}))) -) -{% endmacro %} {% macro near_live_view_udf_get_block_data() %} - import json +{# + This macro generates a Python UDF for reading NEAR block data from Snowflake staged files mapped to the Near Lake. + + Returns: + Python function that reads JSON block data: + - Input: file_url (str) - Scoped file URL to block.json + - Output: dict - Parsed block data + + Dependencies: + - snowflake.snowpark.files + - Stage read permissions +#} from snowflake.snowpark.files import SnowflakeFile def process_file(file_url: str) -> dict: @@ -148,21 +61,9 @@ WITH spine AS ( - File must contain valid NEAR blockchain block data in JSON format - If file fails to process, an error object is returned """ - try: - with SnowflakeFile.open(file_url) as file: - return json.load(file) - except json.JSONDecodeError as e: - return { - 'error': 'JSONDecodeError', - 'details': f'Invalid JSON data: {str(e)}', - 'url': file_url - } - except Exception as e: - return { - 'error': e.__class__.__name__, - 'details': str(e), - 'url': file_url - } + + with SnowflakeFile.open(file_url) as file: + return file.read() {% endmacro %} {% macro near_live_view_get_spine(table_name) %} @@ -179,14 +80,19 @@ WITH spine AS ( #} SELECT - row_number() over (order by null) - 1 + COALESCE(block_id, 0)::integer as block_height, - min_height, - max_height, - latest_block_height -FROM - table(generator(ROWCOUNT => 1000)), - {{ table_name }} - QUALIFY block_height BETWEEN min_height AND max_height + block_height, + ROW_NUMBER() OVER (ORDER BY block_height) - 1 as partition_num +FROM + ( + SELECT + row_number() over (order by seq4()) - 1 + COALESCE(block_height, 0)::integer as block_height, + min_height, + max_height + FROM + table(generator(ROWCOUNT => 1000)), + {{ table_name }} + QUALIFY block_height BETWEEN min_height AND max_height + ) {% endmacro %} @@ -218,45 +124,25 @@ FROM WITH block_urls AS ( SELECT - s.block_height, - ARRAY_AGG( - BUILD_SCOPED_FILE_URL( - '@streamline.bronze.near_lake_data_mainnet', - CONCAT(LPAD(TO_VARCHAR(s.block_height), 12, '0'), '/block.json') - ) - ) as urls - FROM {{ spine_table }} s - GROUP BY s.block_height + partition_num, + BUILD_SCOPED_FILE_URL( + '@streamline.bronze.near_lake_data_mainnet', + CONCAT(LPAD(TO_VARCHAR(block_height), 12, '0'), '/block.json') + ) as url + FROM {{spine_table}} ) SELECT - b.block_data:header:height::NUMBER(38,0) as block_id, - md5(cast(coalesce(cast(b.block_data:header:height::NUMBER(38,0) as TEXT), '_dbt_utils_surrogate_key_null_') as TEXT)) as streamline_blocks_id, - TO_TIMESTAMP_NTZ(b.block_data:header:timestamp::STRING) as block_timestamp, - b.block_data:header:hash::STRING as block_hash, - ARRAY_SIZE(b.block_data:chunks)::STRING as tx_count, - b.block_data:author::STRING as block_author, - b.block_data:header:chunks as chunks, - b.block_data:header:epoch_id::STRING as epoch_id, - b.block_data:header:events as events, - b.block_data:header:gas_price::NUMBER(38,0) as gas_price, - b.block_data:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, - b.block_data:header:next_epoch_id::STRING as next_epoch_id, - b.block_data:header:prev_hash::STRING as prev_hash, - b.block_data:header:total_supply::NUMBER(38,0) as total_supply, - b.block_data:header:validator_proposals as validator_proposals, - b.block_data:header:validator_reward::NUMBER(38,0) as validator_reward, - SYSDATE()::TIMESTAMP_NTZ(9) as inserted_timestamp, - SYSDATE()::TIMESTAMP_NTZ(9) as _inserted_timestamp, - SYSDATE()::TIMESTAMP_NTZ(9) as modified_timestamp, - b.block_data as header -FROM block_urls u, - TABLE({{ schema }}.tf_get_block_data(u.urls)) b + partition_num, + url, + PARSE_JSON({{ schema -}}.udf_get_block_data_(url::STRING)) as block_data +FROM block_urls + {% endmacro %} -- Get Near fact data {% macro get_fact_blocks_transformations(schema) %} {% set get_view_sql %} - SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks_poc') + SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks') {% endset %} {% set results = run_query(get_view_sql) %} @@ -273,57 +159,9 @@ FROM block_urls u, {{ return(transformations) }} {% endmacro %} -{# {% macro get_fact_blocks_transformations(schema) %} - {% set get_view_sql %} - SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks_poc') - {% endset %} - - {% set results = run_query(get_view_sql) %} - - {% set view_ddl = results.rows[0][0] %} - - -- Find the main SELECT statement (after the CTE) - {% set select_pos = view_ddl.upper().rfind('SELECT') %} - {% set from_pos = view_ddl.upper().rfind('FROM') %} - - -- Extract everything between SELECT and FROM - {% set transformations = view_ddl[select_pos + 6:from_pos].strip() %} - - -- Debug the extracted transformations - {% do log("Extracted transformations: " ~ transformations, info=True) %} - - {{ return(transformations) }} -{% endmacro %} #} - -{% macro near_live_view_fact_blocks_poc(schema, blockchain, network) %} -WITH heights AS ( - {{ near_live_view_latest_block_height() | indent(4) }} -), -spine AS ( - {{ near_live_view_get_spine('heights') | indent(4) }} -), -raw_blocks AS ( - {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} -) -SELECT - {{ get_fact_blocks_transformations(schema) }} -FROM raw_blocks - -{% endmacro %} {% macro near_live_view_fact_blocks(schema, blockchain, network) %} -{# - This macro generates a SQL query to fetch and transform NEAR blockchain block data. - - The macro creates a series of CTEs to: - 1. Get the latest block height using near_live_view_latest_block_height - 2. Generate a spine table for block range using near_live_view_get_spine - 3. Fetch block data from Near Lake using tf_get_block_data - 4. Transform the raw block data into a structured format reflecting the near.core.fact_blocks table - -#} - WITH heights AS ( {{ near_live_view_latest_block_height() | indent(4) }} ), @@ -333,44 +171,8 @@ spine AS ( raw_blocks AS ( {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} ) -SELECT - header:header:height::NUMBER(38,0) as block_id, - TO_TIMESTAMP_NTZ(header:header:timestamp::STRING) as block_timestamp, - header:header:hash::STRING as block_hash, - ARRAY_SIZE(header:chunks)::STRING as tx_count, - header:author::STRING as block_author, - header:header as header, - header:header:challenges_result::ARRAY as block_challenges_result, - header:header:challenges_root::STRING as block_challenges_root, - header:header:chunk_headers_root::STRING as chunk_headers_root, - header:header:chunk_tx_root::STRING as chunk_tx_root, - header:header:chunk_mask as chunk_mask, - header:header:chunk_receipts_root::STRING as chunk_receipts_root, - header:chunks as chunks, - header:header:chunks_included::NUMBER(38,0) as chunks_included, - header:header:epoch_id::STRING as epoch_id, - header:header:epoch_sync_data_hash::STRING as epoch_sync_data_hash, - header:events as events, - header:header:gas_price::NUMBER(38,0) as gas_price, - header:header:last_ds_final_block::STRING as last_ds_final_block, - header:header:last_final_block::STRING as last_final_block, - header:header:latest_protocol_version::NUMBER(38,0) as latest_protocol_version, - header:header:next_bp_hash::STRING as next_bp_hash, - header:header:next_epoch_id::STRING as next_epoch_id, - header:header:outcome_root::STRING as outcome_root, - header:header:prev_hash::STRING as prev_hash, - header:header:prev_height::NUMBER(38,0) as prev_height, - header:header:prev_state_root::STRING as prev_state_root, - header:header:random_value::STRING as random_value, - header:header:rent_paid::FLOAT as rent_paid, - header:header:signature::STRING as signature, - header:header:total_supply::NUMBER(38,0) as total_supply, - header:header:validator_proposals as validator_proposals, - header:header:validator_reward::NUMBER(38,0) as validator_reward, - MD5(header:header:height::STRING)::VARCHAR(32) as fact_blocks_id, - SYSDATE()::TIMESTAMP_NTZ(9) as inserted_timestamp, - SYSDATE()::TIMESTAMP_NTZ(9) as modified_timestamp +SELECT + {{ get_fact_blocks_transformations(schema) }} FROM raw_blocks -WHERE header IS NOT NULL {% endmacro %} diff --git a/models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql similarity index 63% rename from models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql rename to models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql index f7bd797..6b23aee 100644 --- a/models/deploy/near/silver/streamline/near_mainnet__fact_blocks_poc.sql +++ b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql @@ -1,6 +1,7 @@ -- models/tests/test_fact_blocks_transformations.sql {{ config( - materialized = 'view' + materialized = 'view', + tags = ['near_models','core','override'] ) }} SELECT * FROM {{ ref('near_models','core__fact_blocks')}} \ No newline at end of file diff --git a/models/doc_descriptions/integration/__overview__.md b/models/doc_descriptions/integration/__overview__.md index 9c0c0a1..d2002c7 100644 --- a/models/doc_descriptions/integration/__overview__.md +++ b/models/doc_descriptions/integration/__overview__.md @@ -46,9 +46,9 @@ Within the same directory (`models/deploy/marketplace/`), create a new folder fo Deploy your model following the standard deployment procedures. -- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` +- `dbt run -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` -- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"UPDATE_UDFS_AND_SPS":True}'` +- `dbt test -s models/deploy/marketplace/your_model/your_model__.sql -t dev --vars '{"LQ_UPDATE_UDFS_AND_SPS":True}'` #### Additional Tips: From bab57b06e14260007ec5abe76e5d67ae3f1bef5b Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 6 Dec 2024 15:33:35 -0800 Subject: [PATCH 16/18] remove poc session context columns --- macros/near/near.yaml.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/near/near.yaml.sql b/macros/near/near.yaml.sql index 2fba148..3dac17f 100644 --- a/macros/near/near.yaml.sql +++ b/macros/near/near.yaml.sql @@ -24,7 +24,7 @@ - [block_id, INTEGER, The start block height to get the blocks from] - [to_latest, BOOLEAN, Whether to continue fetching blocks until the latest block or not] return_type: - - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask VARIANT, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" + - "TABLE(block_id NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_count STRING, block_author STRING, header VARIANT, block_challenges_result ARRAY, block_challenges_root STRING, chunk_headers_root STRING, chunk_tx_root STRING, chunk_mask ARRAY, chunk_receipts_root STRING, chunks VARIANT, chunks_included NUMBER, epoch_id STRING, epoch_sync_data_hash STRING, events VARIANT, gas_price NUMBER, last_ds_final_block STRING, last_final_block STRING, latest_protocol_version NUMBER, next_bp_hash STRING, next_epoch_id STRING, outcome_root STRING, prev_hash STRING, prev_height NUMBER, prev_state_root STRING, random_value STRING, rent_paid FLOAT, signature STRING, total_supply NUMBER, validator_proposals VARIANT, validator_reward NUMBER, fact_blocks_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)" options: | NOT NULL RETURNS NULL ON NULL INPUT From be9e216045bfefcea262ae8ca89ae06d7ee5218f Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 6 Dec 2024 15:42:03 -0800 Subject: [PATCH 17/18] clean up unused udfs, columns, poc models --- Makefile | 10 +- dbt_project.yml | 7 +- macros/near/near_live_views.sql | 53 ++++------- .../streamline/near_mainnet__fact_blocks.sql | 1 - .../streamline/silver__streamline_blocks.sql | 94 +++++++++++++++++++ package-lock.yml | 10 +- packages.yml | 4 +- 7 files changed, 129 insertions(+), 50 deletions(-) create mode 100644 models/deploy/near/silver/streamline/silver__streamline_blocks.sql diff --git a/Makefile b/Makefile index d4d6b12..6758808 100644 --- a/Makefile +++ b/Makefile @@ -15,16 +15,10 @@ deploy_near_mainnet_lv: rm_logs --profile livequery \ --target dev -compile_near_mainnet: rm_logs - dbt compile \ - -s livequery_models.deploy.near.near__mainnet \ - --profiles-dir ~/.dbt \ - --profile livequery \ - --target dev -deploy_fact_blocks: rm_logs +deploy_overrides: rm_logs dbt run \ - -s livequery_models.deploy.near.silver.streamline.near_mainnet__fact_blocks \ + -s tag:override \ --vars '{LQ_UPDATE_UDFS_AND_SPS: true}' \ --profiles-dir ~/.dbt \ --profile livequery \ diff --git a/dbt_project.yml b/dbt_project.yml index 12541e7..9934cb6 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -48,10 +48,14 @@ models: core: +schema: core +materialized: ephemeral + fact_blocks: + +enabled: false silver: streamline: + +materialized: ephemeral silver__streamline_blocks: - +enabled: true # set to false if you need to override the models + +enabled: false + tests: +store_failures: true # all tests @@ -62,6 +66,7 @@ tests: # TODO: enable tests for blockpour once we get an API key +enabled: false + on-run-start: - "{{ create_sps() }}" diff --git a/macros/near/near_live_views.sql b/macros/near/near_live_views.sql index be08daa..2791b43 100644 --- a/macros/near/near_live_views.sql +++ b/macros/near/near_live_views.sql @@ -85,7 +85,7 @@ SELECT FROM ( SELECT - row_number() over (order by seq4()) - 1 + COALESCE(block_height, 0)::integer as block_height, + row_number() over (order by seq4()) - 1 + COALESCE(block_id, 0)::integer as block_height, min_height, max_height FROM @@ -134,45 +134,28 @@ WITH block_urls AS ( SELECT partition_num, url, - PARSE_JSON({{ schema -}}.udf_get_block_data_(url::STRING)) as block_data + PARSE_JSON({{ schema -}}.udf_get_block_data(url::STRING)) as block_data FROM block_urls {% endmacro %} --- Get Near fact data -{% macro get_fact_blocks_transformations(schema) %} - {% set get_view_sql %} - SELECT GET_DDL('VIEW', '{{ schema }}.fact_blocks') - {% endset %} - - {% set results = run_query(get_view_sql) %} - {% set view_ddl = results.rows[0][0] %} - - -- Find the inner SELECT with all the transformations - {% set select_pos = view_ddl.find('SELECT\n block_id') %} - {% set from_pos = view_ddl.find('\nFROM\n blocks') %} - - -- Extract just the transformations part - {% set transformations = view_ddl[select_pos + 6:from_pos].strip() %} - - {% do log("Extracted transformations: " ~ transformations, info=True) %} +{% macro near_live_view_fact_blocks(schema, blockchain, network) %} +{# + This macro returns fact_blocks table data from the specified schema. - {{ return(transformations) }} -{% endmacro %} - + Args: + schema (str): The schema name containing the fact_blocks table + blockchain (str): The blockchain name (e.g. 'near') + network (str): The network name (e.g. 'mainnet') + + Returns: + SQL query: A query that selects all columns from the fact_blocks table + + Note: + - Requires fact_blocks table to exist in the specified schema + - Used as a base table for other Near blockchain views +#} -{% macro near_live_view_fact_blocks(schema, blockchain, network) %} -WITH heights AS ( - {{ near_live_view_latest_block_height() | indent(4) }} -), -spine AS ( - {{ near_live_view_get_spine('heights') | indent(4) }} -), -raw_blocks AS ( - {{ near_live_view_get_raw_block_data('spine', schema) | indent(4) }} -) -SELECT - {{ get_fact_blocks_transformations(schema) }} -FROM raw_blocks +SELECT * FROM {{ schema -}}.fact_blocks {% endmacro %} diff --git a/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql index 6b23aee..997be01 100644 --- a/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql +++ b/models/deploy/near/silver/streamline/near_mainnet__fact_blocks.sql @@ -1,4 +1,3 @@ --- models/tests/test_fact_blocks_transformations.sql {{ config( materialized = 'view', tags = ['near_models','core','override'] diff --git a/models/deploy/near/silver/streamline/silver__streamline_blocks.sql b/models/deploy/near/silver/streamline/silver__streamline_blocks.sql new file mode 100644 index 0000000..0e1405c --- /dev/null +++ b/models/deploy/near/silver/streamline/silver__streamline_blocks.sql @@ -0,0 +1,94 @@ +-- models/silver/silver__streamline_blocks.sql +{{ config( + materialized = 'view', + tags = ['near_models','core','override'] +) }} + +WITH context AS ( + SELECT + CURRENT_SESSION() as session_id, + CURRENT_STATEMENT() as stmt, + -- Extract block_id + TRY_CAST(REGEXP_SUBSTR(stmt, '\\w+\\((\\d+),', 1, 1, 'e', 1) AS NUMBER) as stmt_block_id, + -- Extract to_latest with improved regex + CASE + WHEN REGEXP_SUBSTR(stmt, '\\w+\\((\\d+),\\s*(TRUE|FALSE)\\)', 1, 1, 'i', 2) = 'TRUE' THEN TRUE + WHEN REGEXP_SUBSTR(stmt, '\\w+\\((\\d+),\\s*(TRUE|FALSE)\\)', 1, 1, 'i', 2) = 'FALSE' THEN FALSE + ELSE FALSE + END as to_latest, + CURRENT_USER() as user_name, + CURRENT_ROLE() as role_name, + CURRENT_TRANSACTION() as transaction_id +), +heights AS ( + SELECT + live.udf_api( + 'https://rpc.mainnet.near.org', + utils.udf_json_rpc_call( + 'block', + {'finality': 'final'} + ) + ):data AS result, + result:result:header:height::integer as latest_block_height, + latest_block_height as min_height, -- Fixed min_height reference + latest_block_height as max_height, -- Fixed max_height reference + context.* -- Include context in output for testing + FROM context +), +spine AS ( + SELECT + block_height, + ROW_NUMBER() OVER (ORDER BY block_height) - 1 as partition_num + FROM + ( + SELECT + row_number() over (order by seq4()) - 1 + h.min_height as block_height, + h.min_height, + h.max_height + FROM + table(generator(ROWCOUNT => 1000)), + heights h + QUALIFY block_height BETWEEN h.min_height AND h.max_height + ) +), +raw_blocks AS ( + WITH block_urls AS ( + SELECT + partition_num, + BUILD_SCOPED_FILE_URL( + '@streamline.bronze.near_lake_data_mainnet', + CONCAT(LPAD(TO_VARCHAR(block_height), 12, '0'), '/block.json') + ) as url + FROM spine + ) + SELECT + partition_num, + url, + PARSE_JSON(near_mainnet.udf_get_block_data(url::STRING)) as block_data + FROM block_urls +) +SELECT + block_data:header:height::NUMBER as block_id, + TO_TIMESTAMP_NTZ(block_data:header:timestamp::STRING) as block_timestamp, + block_data:header:hash::STRING as block_hash, + ARRAY_SIZE(block_data:chunks)::STRING as tx_count, + block_data:author::STRING as block_author, + block_data:chunks as chunks, + block_data:header:epoch_id::STRING as epoch_id, + block_data:header:events as events, + block_data:header:gas_price::NUMBER as gas_price, + block_data:header:latest_protocol_version::NUMBER as latest_protocol_version, + block_data:header:next_epoch_id::STRING as next_epoch_id, + block_data:header:prev_hash::STRING as prev_hash, + block_data:header:total_supply::NUMBER as total_supply, + block_data:header:validator_proposals as validator_proposals, + block_data:header:validator_reward::NUMBER as validator_reward, + block_data:header as header, + partition_num as _partition_by_block_number, + SYSDATE() as _modified_timestamp, + SYSDATE() as _inserted_timestamp, + md5(cast(coalesce(cast(block_data:header:height::NUMBER as TEXT), '_dbt_utils_surrogate_key_null_') as TEXT)) as streamline_blocks_id, + SYSDATE() as inserted_timestamp, + SYSDATE() as modified_timestamp, + 'override' as _invocation_id +FROM raw_blocks r diff --git a/package-lock.yml b/package-lock.yml index 44a1cd4..aca831e 100644 --- a/package-lock.yml +++ b/package-lock.yml @@ -3,10 +3,14 @@ packages: version: 0.8.2 - package: dbt-labs/dbt_utils version: 1.0.0 -- git: https://github.com/FlipsideCrypto/near-models-nlq.git - revision: f1edb8a0a851ca6e1b6297405122cc486f5c928b +- git: https://github.com/FlipsideCrypto/near-models.git + revision: 6543067cd46292133779dc2402a1dc3ffbccfb78 - package: calogica/dbt_date version: 0.7.2 +- git: https://github.com/FlipsideCrypto/fsc-utils.git + revision: decabb19923fbd19b0ffdca42bece6d525807e53 - package: get-select/dbt_snowflake_query_tags version: 2.5.0 -sha1_hash: 146672df7bff15c1dc58878075c1b99e298ff914 +- git: https://github.com/FlipsideCrypto/livequery-base.git + revision: 27b35561f666c4bc393199be7fcebf7419a0e57e +sha1_hash: 992994788c097497994ea232fd3be0a4f48788a4 diff --git a/packages.yml b/packages.yml index 630d263..a335f1b 100644 --- a/packages.yml +++ b/packages.yml @@ -3,5 +3,5 @@ packages: version: [">=0.8.0", "<0.9.0"] - package: dbt-labs/dbt_utils version: [">=1.0.0", "<1.1.0"] - - git: "https://github.com/FlipsideCrypto/near-models-nlq.git" - revision: STREAM-1108/strip-lq-deps \ No newline at end of file + - git: "https://github.com/FlipsideCrypto/near-models.git" + revision: STREAM-1111/lq-base-fsc-utils \ No newline at end of file From 1df1c98357cc2242523fa5d60f2d1b920a732c04 Mon Sep 17 00:00:00 2001 From: shah Date: Mon, 9 Dec 2024 11:06:28 -0800 Subject: [PATCH 18/18] Remove deploy core models --- models/deploy/core/_live.sql | 2 - models/deploy/core/_utils.sql | 2 - models/deploy/core/_utils.yml | 11 -- models/deploy/core/live.sql | 5 - models/deploy/core/live.yml | 27 ---- models/deploy/core/secrets.sql | 4 - models/deploy/core/secrets.yml | 45 ------ models/deploy/core/utils.sql | 3 - models/deploy/core/utils.yml | 268 --------------------------------- models/live__allow_list.sql | 11 -- package-lock.yml | 8 +- packages.yml | 2 +- 12 files changed, 5 insertions(+), 383 deletions(-) delete mode 100644 models/deploy/core/_live.sql delete mode 100644 models/deploy/core/_utils.sql delete mode 100644 models/deploy/core/_utils.yml delete mode 100644 models/deploy/core/live.sql delete mode 100644 models/deploy/core/live.yml delete mode 100644 models/deploy/core/secrets.sql delete mode 100644 models/deploy/core/secrets.yml delete mode 100644 models/deploy/core/utils.sql delete mode 100644 models/deploy/core/utils.yml delete mode 100644 models/live__allow_list.sql diff --git a/models/deploy/core/_live.sql b/models/deploy/core/_live.sql deleted file mode 100644 index f37331e..0000000 --- a/models/deploy/core/_live.sql +++ /dev/null @@ -1,2 +0,0 @@ -{% set config = config_core__live %} -{{ ephemeral_deploy_core(config) }} diff --git a/models/deploy/core/_utils.sql b/models/deploy/core/_utils.sql deleted file mode 100644 index ac40ddf..0000000 --- a/models/deploy/core/_utils.sql +++ /dev/null @@ -1,2 +0,0 @@ -{% set config = config_core__utils %} -{{ ephemeral_deploy_core(config) }} diff --git a/models/deploy/core/_utils.yml b/models/deploy/core/_utils.yml deleted file mode 100644 index 80fcb8b..0000000 --- a/models/deploy/core/_utils.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 -models: - - name: _utils - columns: - - name: udf_introspect - tests: - - test_udf: - name: test___utils_udf_introspect - args: "'hello'" - assertions: - - result = 'hello' \ No newline at end of file diff --git a/models/deploy/core/live.sql b/models/deploy/core/live.sql deleted file mode 100644 index 9e088f2..0000000 --- a/models/deploy/core/live.sql +++ /dev/null @@ -1,5 +0,0 @@ --- depends_on: {{ ref('_utils') }} --- depends_on: {{ ref('utils') }} --- depends_on: {{ ref('_live') }} -{% set config = config_core_live %} -{{ ephemeral_deploy_core(config) }} diff --git a/models/deploy/core/live.yml b/models/deploy/core/live.yml deleted file mode 100644 index cb4bbf1..0000000 --- a/models/deploy/core/live.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 2 -models: - - name: live - columns: - - name: udf_api - tests: - - test_udf: - name: test__live_udf_api_post_data_object - args: | - 'https://httpbin.org/post', {'foo': 'bar'} - assertions: - - result:data.json is not null - - result:data.json = OBJECT_CONSTRUCT('foo', 'bar') - - test_udf: - name: test__live_udf_api_post_data_array - args: | - 'https://httpbin.org/post', ['foo', 'bar'] - assertions: - - result:data.json is not null - - result:data.json = ARRAY_CONSTRUCT('foo', 'bar') - - test_udf: - name: test__live_udf_api_post_data_string - args: | - 'https://httpbin.org/post', 'foo'::VARIANT - assertions: - - result:data.json is not null - - result:data.json = 'foo' \ No newline at end of file diff --git a/models/deploy/core/secrets.sql b/models/deploy/core/secrets.sql deleted file mode 100644 index 668ca14..0000000 --- a/models/deploy/core/secrets.sql +++ /dev/null @@ -1,4 +0,0 @@ --- depends_on: {{ ref('_utils') }} --- depends_on: {{ ref('live') }} -{% set config = config_core_secrets %} -{{ ephemeral_deploy_core(config) }} \ No newline at end of file diff --git a/models/deploy/core/secrets.yml b/models/deploy/core/secrets.yml deleted file mode 100644 index 7d54d74..0000000 --- a/models/deploy/core/secrets.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: 2 -models: - - name: secrets - columns: - - name: udf_register_secret - tests: - - test_udf: - name: test_secrets__udf_register_secret - args: > - 'test', 'test' - assertions: - - result = {'request_id':'test','success':false} - - name: udf_get_secret - tests: - - test_udf: - name: test_secrets__udf_get_secret - args: > - 'test' - assertions: - - > - result::OBJECT = {'key': 'value'} - - name: udf_get_secrets - tests: - - test_udf: - name: test_secrets__udf_get_secrets - args: '' - assertions: - - > - result = {'test': {'key': 'value'}} - - name: udf_create_secret - tests: - - test_udf: - name: test_secrets__udf_create_secret - args: > - 'test', {'key': 'value'} - assertions: - - result = 200 - - name: udf_delete_secret - tests: - - test_udf: - name: test_secrets__udf_delete_secret - args: > - 'test_delete' - assertions: - - result = 200 \ No newline at end of file diff --git a/models/deploy/core/utils.sql b/models/deploy/core/utils.sql deleted file mode 100644 index fbabfe1..0000000 --- a/models/deploy/core/utils.sql +++ /dev/null @@ -1,3 +0,0 @@ - -- depends_on: {{ ref('_utils') }} -{% set config = config_core_utils %} -{{ ephemeral_deploy_core(config) }} diff --git a/models/deploy/core/utils.yml b/models/deploy/core/utils.yml deleted file mode 100644 index 659b025..0000000 --- a/models/deploy/core/utils.yml +++ /dev/null @@ -1,268 +0,0 @@ -version: 2 -models: - - name: utils - columns: - - name: udf_json_rpc_call - tests: - - test_udf: - args: "'foo', [], 1" - assertions: - - > - result = { - 'jsonrpc': '2.0', - 'method': 'foo', - 'params': [], - 'id': '1' - } - - name: udf_urlencode - tests: - - test_udf: - name: test_utils__udf_urlencode_dict_true_1 - args: > - {'a':'b'}, TRUE - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_dict_true_2 - args: > - {'a':'a', 'b':'b'}, TRUE - assertions: - - result = 'a=a&b=b' - - test_udf: - name: test_utils__udf_urlencode_dict_true_space - args: > - {'space': 'abc 123'}, TRUE - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_dict_true_special - args: > - {'special!': ' !@#$,+"'}, TRUE - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_dict_true_array - args: > - {'array': [0, 1, 2]}, TRUE - assertions: - - result = 'array=0&array=1&array=2' - - test_udf: - name: test_utils__udf_urlencode_dict_false_1 - args: > - {'a':'b'}, FALSE - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_dict_false_2 - args: > - {'a':'b', 'b':'b'}, FALSE - assertions: - - result = 'a=b&b=b' - - test_udf: - name: test_utils__udf_urlencode_dict_false_space - args: > - {'space': 'abc 123'}, FALSE - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_dict_false_special - args: > - {'special!': ' !@#$,+"'}, FALSE - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_dict_false_array - args: > - {'array': [0, 1, 2]}, FALSE - assertions: - - result = 'array=%5B0%2C+1%2C+2%5D' - - test_udf: - name: test_utils__udf_urlencode_dict_1 - args: > - {'a':'b'} - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_dict_2 - args: > - {'a':'b', 'b':'b'} - assertions: - - result = 'a=b&b=b' - - test_udf: - name: test_utils__udf_urlencode_dict_space - args: > - {'space': 'abc 123'} - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_dict_special - args: > - {'special!': ' !@#$,+"'} - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_dict_array - args: > - {'array': [0, 1, 2]} - assertions: - - result = 'array=%5B0%2C+1%2C+2%5D' - # write tests but use arrays of arrays instead of dictionaries - - test_udf: - name: test_utils__udf_urlencode_array_true_1 - args: > - [['a', 'b']], TRUE - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_array_true_2 - args: > - [['a', 'a'], ['b', 'b']], TRUE - assertions: - - result = 'a=a&b=b' - - test_udf: - name: test_utils__udf_urlencode_array_true_space - args: > - [['space', 'abc 123']], TRUE - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_array_true_special - args: > - [['special!', ' !@#$,+"']], TRUE - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_array_true_array - args: > - [['array', [0, 1, 2]]], TRUE - assertions: - - result = 'array=0&array=1&array=2' - - test_udf: - name: test_utils__udf_urlencode_array_false_1 - args: > - [['a', 'b']], FALSE - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_array_false_2 - args: > - [['a', 'a'], ['b', 'b']], FALSE - assertions: - - result = 'a=a&b=b' - - test_udf: - name: test_utils__udf_urlencode_array_false_space - args: > - [['space', 'abc 123']], FALSE - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_array_false_special - args: > - [['special!', ' !@#$,+"']], FALSE - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_array_false_array - args: > - [['array', [0, 1, 2]]], FALSE - assertions: - - result = 'array=%5B0%2C+1%2C+2%5D' - - test_udf: - name: test_utils__udf_urlencode_array_1 - args: > - [['a', 'b']] - assertions: - - result = 'a=b' - - test_udf: - name: test_utils__udf_urlencode_array_2 - args: > - [['a', 'a'], ['b', 'b']] - assertions: - - result = 'a=a&b=b' - - test_udf: - name: test_utils__udf_urlencode_array_space - args: > - [['space', 'abc 123']] - assertions: - - result = 'space=abc+123' - - test_udf: - name: test_utils__udf_urlencode_array_special - args: > - [['special!', ' !@#$,+"']] - assertions: - - result = 'special%21=+%21%40%23%24%2C%2B%22' - - test_udf: - name: test_utils__udf_urlencode_array_array - args: > - [['array', [0, 1, 2]]] - assertions: - - result = 'array=%5B0%2C+1%2C+2%5D' - - name: udf_int_to_binary - tests: - - test_udf: - name: test_utils__udf_int_to_binary - args: 123456789 - assertions: - - result = '111010110111100110100010101' - - name: udf_int_to_binary - tests: - - test_udf: - name: test_utils__udf_int_to_binary_large_number - args: "'123456789123456789123456789123456789123456789'" - assertions: - - result = '101100010010011011011100101001111010001001110011010111111101111101010111011001001101000001111110001010100001011011010000100000001000101111100010101' - - name: udf_binary_to_int - tests: - - test_udf: - name: test_utils__udf_binary_to_int - args: '111010110111100110100010101' - assertions: - - result = '123456789' - - name: udf_binary_to_int - tests: - - test_udf: - name: test_utils__udf_binary_to_int_large_number - args: "'110110110100110110100101110101100110100000101111100010101'" - assertions: - - result = '123456789123456789' - - name: udf_evm_decode_log - tests: - - test_udf: - name: test_utils__udf_evm_decode_log - args: > - { - 'anonymous': false, - 'inputs': [ - { - 'indexed': false, - 'name': 'nonce', - 'type': 'uint256' - } - ], - 'name': 'NonceChanged', - 'type': 'event' - }::variant, - { - 'address': '0x55032650b14df07b85bf18a3a3ec8e0af2e028d5', - 'data': '0x000000000000000000000000000000000000000000000000000000000000279c', - 'topics': [ - '0x7220970e1f1f12864ecccd8942690a837c7a8dd45d158cb891eb45a8a69134aa' - ] - }::variant - assertions: - - > - result = [ - { - 'address': '0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5', - 'data': [ - { - 'decoded': true, - 'name': 'nonce', - 'type': 'uint256', - 'value': 10140 - } - ], - 'decoded': true, - 'name': 'NonceChanged' - } - ] \ No newline at end of file diff --git a/models/live__allow_list.sql b/models/live__allow_list.sql deleted file mode 100644 index 611fda3..0000000 --- a/models/live__allow_list.sql +++ /dev/null @@ -1,11 +0,0 @@ --- depends_on: {{ ref('live') }} -{{ config( - materialized = 'view', - grants = {'+select': fromyaml(var('ROLES'))} -) }} -SELECT '*.' || t.value AS allowed_domains -FROM table(flatten(input => {{ this.database }}.live.udf_allow_list())) AS t -ORDER BY - split_part(allowed_domains, '.', -1), - split_part(allowed_domains, '.', -2), - split_part(allowed_domains, '.', -3) diff --git a/package-lock.yml b/package-lock.yml index aca831e..65d8669 100644 --- a/package-lock.yml +++ b/package-lock.yml @@ -4,13 +4,13 @@ packages: - package: dbt-labs/dbt_utils version: 1.0.0 - git: https://github.com/FlipsideCrypto/near-models.git - revision: 6543067cd46292133779dc2402a1dc3ffbccfb78 + revision: 04fc27bec7971b3bbd9d77591889ce163db31eb4 - package: calogica/dbt_date version: 0.7.2 - git: https://github.com/FlipsideCrypto/fsc-utils.git - revision: decabb19923fbd19b0ffdca42bece6d525807e53 + revision: 6096046f00c5c27fa7b8d60ae6ec1dfe31d7fa10 - package: get-select/dbt_snowflake_query_tags version: 2.5.0 - git: https://github.com/FlipsideCrypto/livequery-base.git - revision: 27b35561f666c4bc393199be7fcebf7419a0e57e -sha1_hash: 992994788c097497994ea232fd3be0a4f48788a4 + revision: 10b53fd690bbbcfc26d65a3a432c004c9e4978bb +sha1_hash: 4540b0d3844a74ca5fae20487414c67b310b9d75 diff --git a/packages.yml b/packages.yml index a335f1b..2e56bff 100644 --- a/packages.yml +++ b/packages.yml @@ -4,4 +4,4 @@ packages: - package: dbt-labs/dbt_utils version: [">=1.0.0", "<1.1.0"] - git: "https://github.com/FlipsideCrypto/near-models.git" - revision: STREAM-1111/lq-base-fsc-utils \ No newline at end of file + revision: "04fc27bec7971b3bbd9d77591889ce163db31eb4" \ No newline at end of file