Partilhar via


Função window_time

Aplica-se a: Marque Sim Databricks SQL Marque Sim Databricks Runtime 12.2 LTS e superior

Devolve a hora de fim inclusiva de uma janela de tempo produzida pelas funções de janela ou session_window .

Sintaxe

window_time(window)

Argumentos

Devoluções

Um TIMESTAMP valor com o ponto de extremidade inclusivo da janela. Isto é equivalente a window.end - INTERVAL '0.000001' SECOND

Exemplos

> 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