DBT Test: Dbt Expectations Expect Row Values To Have Recent Data S3 Inventory Snapshots Strptime Snapshot Ts Y M Dt H Mz Day 9
DBT test name: dbt_expectations_expect_row_values_to_have_recent_data_s3_inventory_snapshots_strptime_snapshot_ts_Y_m_dT_H_MZ___day__9
DBT details
-
Kind:
generic(expect_row_values_to_have_recent_data) -
Column under test:
snapshot_ts -
Test file: trase/data_pipeline/models/s3_monitoring/_schema_s3_monitoring.yml
Description
No description
Details
{{ dbt_expectations.test_expect_row_values_to_have_recent_data(**_dbt_generic_test_kwargs) }}{{ config(alias="dbt_expectations_expect_row_va_7b867bd8fc54a0fa7f796ac874879251") }}
with max_recency as (
select max(cast(strptime(snapshot_ts, '%Y-%m-%dT%H-%MZ') as timestamp)) as max_timestamp
from
"trase_ducklake"."main_s3_monitoring"."s3_inventory_snapshots"
where
-- to exclude erroneous future dates
cast(strptime(snapshot_ts, '%Y-%m-%dT%H-%MZ') as timestamp) <= cast(
cast(now() as timestamp)
at time zone 'UTC' at time zone 'UTC'
as timestamp
)
)
select
*
from
max_recency
where
-- if the row_condition excludes all rows, we need to compare against a default date
-- to avoid false negatives
coalesce(max_timestamp, cast('1970-01-01' as timestamp))
<
cast(
(cast(
cast(now() as timestamp)
at time zone 'UTC' at time zone 'UTC'
as timestamp
) + cast(-9 as bigint) * interval 1 day) as timestamp)