finance-dbt/models/dw/dw.dim_time.sql
沈楠 3b1c9f96ea
Some checks failed
MJN/finance-dbt/pipeline/head There was a failure building this commit
Created: a dbt project for finance data (hs_stock)
2024-04-07 19:09:16 +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