finance-dbt/models/dw/dw.dim_time.sql
沈楠 cb3026dd48
Some checks failed
MJN/finance-dbt/pipeline/head There was a failure building this commit
init: create finance-dbt
2024-04-08 11:50:14 +08:00

24 lines
516 B
SQL

{{
config(
materialized='table',
engine='MergeTree',
order_by='time_id'
)
}}
Select cast(formatDateTime(`full_time`, '%Y%m%d%H%i') As Int64) As time_id
, `full_time`
, `date_id`
, hour(`full_time`) As `hour`
, minute(`full_time`) As `minute`
From(
SELECT
arrayJoin(
arrayMap(
x -> toStartOfMinute(toDateTime(toDate(`full_date`)) + x * 60),
range(0, 24 * 60)
)
) AS `full_time`
, `date_id`
From {{ ref("dw.dim_date") }}
Where `date_id` >= 20090101
) As T