window_time
函数
适用于: Databricks SQL Databricks Runtime 12.2 LTS 及更高版本
返回由 window 或 session_window 函数生成的时间窗口的非独占结束时间。
语法
window_time(window)
参数
window
:由 window 函数生成的window
列。
返回
一个具有窗口的非独占终结点的 TIMESTAMP
值。
这等效于 window.end - INTERVAL '0.000001' SECOND
示例
> SELECT a, window.start as start, window.end as end, window_time(window), cnt
FROM (SELECT a, window, count(*) as cnt
FROM VALUES ('A1', '2021-01-01 00:00:00'),
('A1', '2021-01-01 00:04:30'),
('A1', '2021-01-01 00:06:00'),
('A2', '2021-01-01 00:01:00') AS tab(a, b)
GROUP by a, window(b, '5 MINUTES'))
ORDER BY a, window.start;
A1 2021-01-01 00:00:00 2021-01-01 00:05:00 2021-01-01 00:04:59.999999 2
A1 2021-01-01 00:05:00 2021-01-01 00:10:00 2021-01-01 00:09:59.999999 1
A2 2021-01-01 00:00:00 2021-01-01 00:05:00 2021-01-01 00:04:59.999999 1