gaps delete

This commit is contained in:
Eric Laurello 2023-07-11 09:15:09 -04:00
parent 66396c5b93
commit 0897b95d0f
2 changed files with 0 additions and 138 deletions

View File

@ -1,70 +0,0 @@
{{ config(
materialized = 'incremental',
full_refresh = false
) }}
WITH source AS (
SELECT
block_id,
block_timestamp,
LAG(
block_id,
1
) over (
ORDER BY
block_id ASC
) AS prev_BLOCK_ID
FROM
{{ ref('silver__blocks') }}
{% if is_incremental() %}
WHERE
(
block_timestamp :: DATE >= (
SELECT
MAX(
max_block_timestamp
) :: DATE -3
FROM
{{ this }}
)
OR (
(
SELECT
block_gaps
FROM
{{ this }}
qualify(ROW_NUMBER() over(
ORDER BY
max_block_timestamp DESC) = 1)
) <> 0
)
)
{% endif %}
)
SELECT
MIN(block_id) AS min_block,
MAX(block_id) AS max_block,
MIN(block_timestamp) AS min_block_timestamp,
MAX(block_timestamp) AS max_block_timestamp,
COUNT(1) AS total_blocks,
SUM(
CASE
WHEN block_id - prev_BLOCK_ID <> 1 THEN 1
ELSE 0
END
) AS block_gaps,
ARRAY_AGG(
CASE
WHEN block_id - prev_BLOCK_ID <> 1 THEN OBJECT_CONSTRUCT(
'prev_block_id',
prev_block_id,
'block_id',
block_id
)
END
) AS block_gaps_details,
SYSDATE() AS _inserted_timestamp
FROM
source

View File

@ -1,68 +0,0 @@
version: 2
models:
- name: silver_observability__block_gaps
description: Records of all blocks block gaps with a timestamp the test was run
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _INSERTED_TIMESTAMP
columns:
- name: MIN_BLOCK
description: The lowest block id in the test
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: MAX_BLOCK
description: The highest block id in the test
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: MIN_BLOCK_TIMESTAMP
description: The lowest block timestamp in the test
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: MAX_BLOCK_TIMESTAMP
description: The highest block timestamp in the test
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: TOTAL_BLOCKS
description: Count of blocks in the test
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: BLOCK_GAPS
description: Count of block gaps in the test
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: BLOCK_GAPS_DETAILS
description: gap blocks
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- ARRAY
- name: _INSERTED_TIMESTAMP
description: "{{ doc('inserted_timestamp') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ