New counter_diff SQL window function for time-series analysis
The counter_diff window function calculates differences between consecutive cumulative counter values and handles resets.
O que mudou
The counter_diff window function converts cumulative counters into delta format by calculating the difference between consecutive values in a time series. ### Use cases Imagine you monitor system request volumes and need to turn cumulative readings into incremental interval values. It helps to: - Convert cumulative counters into deltas. - Handle counter drops when a service or machine restarts. - Use an optional timestamp to signal resets independently. ### How to use ```sql SELECT m, t, counter_diff(c) OVER (PARTITION BY m ORDER BY t) FROM VALUES ('http_requests', TIMESTAMP '2026-01-01T00:00:00', 100), ('http_requests', TIMESTAMP '2026-01-01T00:01:00', 200), ('http_requests', TIMESTAMP '2026-01-01T00:02:00', 400) AS tab(m, t, c);
What happens in this code:
1. The PARTITION BY clause separates data by metric name.
2. The ORDER BY clause sorts rows by timestamp.
3. The function calculates the difference between the current and previous counter value. ### Limitations and requirements Available in Databricks SQL and Databricks Runtime 19.0 and above. The function strictly requires an ORDER BY clause in the window definition. Negative values raise an error.
- sql
- window functions
- time-series
- databricks sql
The counter_diff SQL window function is now available
Resumo e explicação gerados por IA a partir da release note oficial. Em caso de dúvida, a documentação oficial da plataforma prevalece.
Relacionadas
- DatabricksGA
Repositórios de pacotes em nível de workspace para Databricks Apps
Administradores de workspace podem configurar repositórios padrão de pacotes Python e npm para Databricks Apps.
databricks apps · workspace settings - DatabricksGA
Redimensione partições de stateful streaming sem perder o checkpoint no Databricks
Agora é possível alterar o número de partições de shuffle em queries Structured Streaming e pipelines Lakeflow sem descartar o estado do checkpoint.
structured streaming · lakeflow - DatabricksAtualização
Google Gemini 4 Argon disponível no Unity Gateway do Databricks
O modelo multimodal Google Gemini 4 Argon já pode ser acessado via Foundation Model APIs e Unity Gateway.
unity catalog · foundation model apis