沈楠
0734f50550
Some checks failed
MJN/finance-dbt/pipeline/head There was a failure building this commit
30 lines
686 B
SQL
30 lines
686 B
SQL
|
|
/*
|
|
日期
|
|
*/
|
|
{{
|
|
config(
|
|
materialized='table',
|
|
engine='MergeTree',
|
|
order_by='date_id'
|
|
)
|
|
}}
|
|
SELECT
|
|
toUInt32(year(date) * 10000 + month(date) * 100 + day(date)) AS date_id,
|
|
date AS full_date,
|
|
toYear(date) AS year,
|
|
toUInt8(quarter(date)) AS quarter,
|
|
toUInt8(month(date)) AS month,
|
|
toUInt8(toDayOfMonth(date)) AS day,
|
|
toUInt8(week(date)) AS week_num_of_year,
|
|
toUInt8(toDayOfWeek(date)) AS day_num_of_week
|
|
FROM (
|
|
SELECT
|
|
arrayJoin(
|
|
arrayMap(
|
|
x -> toDate('1990-01-01') + x,
|
|
range(toUInt32(dateDiff('day', toDate('1990-01-01'), toDate('2031-01-01'))))
|
|
)
|
|
) AS date
|
|
)
|
|
ORDER BY date_id |