沈楠
ec07e9ca89
Some checks failed
MJN/finance-dbt/pipeline/head There was a failure building this commit
adjust fields
31 lines
707 B
SQL
31 lines
707 B
SQL
|
|
/*
|
|
日期
|
|
*/
|
|
{{
|
|
config(
|
|
materialized='table',
|
|
engine='MergeTree',
|
|
order_by='date_id'
|
|
)
|
|
}}
|
|
SELECT
|
|
toYYYYMMDD(date) AS date_id,
|
|
formatDateTimeInJodaSyntax(date, 'yyyyMMdd') AS date_id_str,
|
|
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 |