artemis fixes (#101)

This commit is contained in:
eric-laurello 2025-04-11 09:51:08 -04:00 committed by GitHub
parent 755a296894
commit 370ab61da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 27 deletions

View File

@ -19,7 +19,7 @@ models:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 2
interval: 3
- name: ACTIVE_USERS
description: "The number of active users for the given blockchain and as of date."
tests:

View File

@ -19,7 +19,7 @@ models:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 2
interval: 3
- name: TX_COUNT
description: "The number of tx count for the given blockchain and as of date."
tests:

View File

@ -4,9 +4,10 @@
materialized = "incremental",
unique_key = ['metric_date', 'blockchain', 'metric'],
tags = ['silver', 'artemis']
)}}
) }}
WITH source_data AS (
SELECT
raw_data,
partition_key,
@ -15,18 +16,19 @@ WITH source_data AS (
FROM
{% if is_incremental() %}
{{ ref('bronze__artemis') }}
{{ ref('bronze__artemis') }}
{% else %}
{{ ref('bronze__artemis_FR') }}
{% endif %}
{% if is_incremental() %}
WHERE _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp)
FROM {{ this }}
)
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp)
FROM
{{ this }}
)
{% endif %}
),
parsed_data AS (
@ -34,17 +36,23 @@ parsed_data AS (
s._inserted_timestamp,
s.partition_key,
s.file_name,
blockchain_flat.KEY AS blockchain,
metric_flat.KEY AS metric,
metrics.value:date::STRING AS metric_date,
metrics.value:val AS metric_value
blockchain_flat.key AS blockchain,
metric_flat.key AS metric,
metrics.value :date :: STRING AS metric_date,
metrics.value :val AS metric_value
FROM
source_data s,
LATERAL FLATTEN(INPUT => raw_data:data:artemis_ids) AS blockchain_flat,
LATERAL FLATTEN(INPUT => blockchain_flat.value) AS metric_flat,
LATERAL FLATTEN(INPUT => metric_flat.value) AS metrics
LATERAL FLATTEN(
input => raw_data :data :artemis_ids
) AS blockchain_flat,
LATERAL FLATTEN(
input => blockchain_flat.value
) AS metric_flat,
LATERAL FLATTEN(
input => metric_flat.value
) AS metrics
WHERE
raw_data:data:artemis_ids IS NOT NULL
raw_data :data :artemis_ids IS NOT NULL
)
SELECT
TO_DATE(metric_date) AS metric_date,
@ -59,4 +67,6 @@ SELECT
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
parsed_data
parsed_data qualify(ROW_NUMBER() over (PARTITION BY metric_date, blockchain, metric
ORDER BY
_inserted_timestamp DESC) = 1)

View File

@ -15,20 +15,14 @@
) }}
WITH complete_data AS (
{% if is_incremental() %}
SELECT
date_day,
_invocation_id,
MAX(date_day) OVER () AS max_complete_date
FROM
{{ ref("streamline__artemis_complete") }}
{% else %}
SELECT
null as date_day,
null as _invocation_id,
'2025-01-01'::DATE AS max_complete_date
{% endif %}
),
date_params AS (
SELECT