finance-dbt/models/dw/dw.dim_time.sql
沈楠 9d9c343b71
Some checks failed
MJN/finance-dbt/pipeline/head There was a failure building this commit
release: 0.1.0 add ods for minutes trade data
2024-07-05 17:54:16 +08:00

26 lines
646 B
SQL

{{
config(
materialized='table',
engine='MergeTree',
order_by='(date_id_str, full_time_str, time_id)'
)
}}
Select toYYYYMMDDhhmmss(`full_time`) As time_id
, `full_time`
, `date_id`
, hour(`full_time`) As `hour`
, minute(`full_time`) As `minute`
, formatDateTimeInJodaSyntax(`full_time`, 'yyyy-MM-dd HH:mm:ss') As full_time_str
, Cast(`date_id` As String) As date_id_str
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