正如我在问题中提到的那样,我现在正在回答这个问题,因为我已经找到了使用开始和结束日期创建日历表或视图的问题的解决方案。
CREATE table mytest.calendar
(
date DATE primary key
);
将边界日期插入日历表(您想要的表中的最小和最大日期)。
Insert into mytest.calendar (select min(date) from mytest.benchmarks);
Insert into mytest.calendar (select max(date) from mytest.benchmarks);
现在要生成中间日期,请执行以下操作:
SELECT CAST(slice_time AS DATE) date
FROM mytest.calendar mtc
TIMESERIES slice_time as '1 day'
OVER (ORDER BY CAST(mtc.date as TIMESTAMP));
您可以将其单独用作表格:
SELECT date from
(SELECT CAST(slice_time AS DATE) date
FROM mytest.calendar mtc
TIMESERIES slice_time as '1 day'
OVER (ORDER BY CAST(mtc.date as TIMESTAMP))) calendar
where mytest.isBusinessDay(date) = 't';
SELECT date
FROM
(SELECT date
FROM
(SELECT CAST(slice_time AS DATE) date
FROM mytest.calendar mtc
TIMESERIES slice_time as '1 day'
OVER (ORDER BY CAST(mtc.date as TIMESTAMP))
) calendar
WHERE mytest.isBusinessDay(date) = 't') calendar;
我有从开始日期(min(date)
来自基准表)到结束日期(即 )的日期max(date)
列表