SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Fun with ClickHouse
Window Functions
Robert Hodges and Vitaliy Zakaznikov @ Altinity
1
Presenter Bios and Altinity Introduction
The #1 enterprise ClickHouse provider. Now offering Altinity.Cloud
Major committer and community sponsor for ClickHouse in US/EU
Robert Hodges - CEO
30+ years on DBMS plus
virtualization and security.
ClickHouse is DBMS #20
Vitaliy Zakaznikov - QA Manager
13+ years testing hardware and
software; author of TestFlows
open source testing framework
ClickHouse: a great SQL data warehouse
Understands SQL
Runs on bare metal to cloud
Shared nothing architecture
Stores data in columns
Parallel and vectorized execution
Scales to many petabytes
Is Open source (Apache 2.0)
a b c d
a b c d
a b c d
a b c d
And it’s really fast!
3
Using the Altinity.Cloud public endpoint
4
https://github.demo.trial.altinity.cloud:8443/play
User
“demo”
Password
“demo”
clickhouse-client --host=github.demo.trial.altinity.cloud
-s --user=demo --password
What are
Window
Functions?
5
Let’s start with a simple query...
SELECT FlightDate,
count() AS Flights,
sum(Cancelled) AS Sum_Cancelled
FROM ontime
WHERE toYYYYMM(FlightDate) = 201901
GROUP BY FlightDate
ORDER BY FlightDate
FlightDate|Flights|Sum_Cancelled|
----------|-------|-------------|
2019-01-01| 18009| 141|
2019-01-02| 20384| 173|
6
Cancelled flights for
Jan 2019
7
SQL queries work like “cubes”
7
FlightDate
Cancelled
0 --
1 --
1/01 1/02 1/03 1/04 1/05 1/06 1/07 1/07 . ..
16807 Flights
129 Cancelled
Dimension
Metrics
(count, sum)
Dimension
Carrier
F
l
i
g
h
t
N
u
m
TailNum
(Other dimensions)
...But what happens if we want to...
8
Rank particular days by
number of cancelled flights?
Print cumulative cancellations
for each month?
Print trailing 7-day average
cancellations?
8
How can I do that in SQL??
This is a job for window functions!
9
Set session variable
clickhouse101 :) SET allow_experimental_window_functions = 1
SET allow_experimental_window_functions = 1
Query id: f8aec38c-7f31-4544-96df-bcdb4034f0ac
Ok.
<yandex>
<profiles>
<default>
<allow_experimental_window_functions>1</allow_...tions>
. . .
</default></profiles></yandex>
But first we need to enable them...
Set in user profile
Window functions add a new option to SQL
SELECT FlightDate, count() AS Flights,
sum(Cancelled) AS Daily_Cancelled,
avg(Daily_Cancelled)
OVER (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
AS Avg_Cancelled_7
FROM ontime_ref
WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate
FlightDate|Flights|Daily_Cancelled|Avg_Cancelled_7 |
----------|-------|---------------|------------------|
. . .
2019-01-30| 19102| 2145| 805.5714285714286|
2019-01-31| 19962| 1775| 999.0|
2019-02-01| 20045| 459|1037.2857142857142|
10
Window function!
How window functions work conceptually
SELECT FlightDate,
count() AS Flights,
sum(Cancelled) AS Daily_Cancelled,
avg(Daily_Cancelled)
OVER (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
AS Avg_Cancelled_7
FROM ontime_ref
WHERE Year = 2019
GROUP BY FlightDate
ORDER BY FlightDate
11
Operates on the
computed aggregate
Computes average
within a window
“frame” of 7 rows
Result is another
output column
Window
Functions -- The
gory details
21.3 (LTS) - First experimental
support
21.8 - Pre-release experimental
feature (should be enabled by
default soon)
12
How do window functions work for users?
13
Why do we need “gory details” anyway?
14
● Empty OVER clause means that there is
only one window that includes all the
result rows
● When no ORDER BY clause is specified
then all rows are the peers of the
current row
● The default frame is RANGE BETWEEN
UNBOUNDED PRECEDING AND
CURRENT ROW
SELECT
number,
sum(number) OVER ()
FROM numbers(1, 5)
┌─number─┬─sum(number) OVER ()─┐
│ 1 │ 15 │
│ 2 │ 15 │
│ 3 │ 15 │
│ 4 │ 15 │
│ 5 │ 15 │
└────────┴─────────────────────┘
Window function behavior is not obvious!
What can be a window function?
15
Any aggregate function
● min
● max
● sum
● avg
● etc.
SELECT number, min(number)
OVER () FROM numbers(1,5)
Window native function
● row_number
● first_value
● last_value
● rank
● dense_rank
● leadInFrame
● lagInFrame
SELECT number, rank() OVER (ORDER BY
number) FROM numbers(1,5)
What is an OVER clause?
16
● Can be empty
OVER defines the window specification
● Can contain window
specification
SELECT number,
sum(number) OVER ()
FROM numbers(1,5)
SELECT number,
sum(number) OVER (PARTITION BY number)
FROM numbers(1,5)
● Can refer to a named
window
SELECT number,
sum(number) OVER w
FROM numbers(1,5)
WINDOW w AS (PARTITION BY number)
What do window specifications look like?
17
● PARTITION BY clause
Defines window partition
Window Specification clause
[partition_clause] [order_clause] [frame_clause]
● ORDER BY clause
Orders rows within a frame
SELECT number,
sum(number) OVER (PARTITION BY number % 2)
FROM numbers(1,5)
SELECT number,
sum(number) OVER (ORDER BY number)
FROM numbers(1,5)
● FRAME clause
Defines frame within a
window partition
SELECT number,
sum(number) OVER (ROWS BETWEEN
UNBOUNDED PRECEDING AND CURRENT ROW)
FROM numbers(1,5)
What kind of frames are there?
18
● ROWS frame
Defines a frame with the range in
terms of relationship of rows to the
current row number
SELECT
number,
sum(number) OVER (ORDER BY
number ROWS 1 PRECEDING) AS sum
FROM numbers(1, 3)
┌─number─┬─sum─┐
│ 1 │ 1 │
│ 2 │ 3 │
│ 3 │ 5 │
└────────┴─────┘
FRAME clause
● RANGE frame
Defines a frame with the range in terms of row
values from the current row value.
SELECT
number,
sum(number) OVER (ORDER BY number RANGE
1 PRECEDING) AS sum
FROM values('number Int8', 1, 2, 2, 4)
┌─number─┬─sum─┐
│ 1 │ 1 │
│ 2 │ 5 │
│ 2 │ 5 │
│ 4 │ 4 │
└────────┴─────┘
What are current rows peers?
19
● With ORDER BY clause
SELECT
number,
sum(number) OVER (ORDER BY number)
AS sum
FROM values('number Int8', 1, 2, 2, 3,
4, 5)
┌─number─┬─sum─┐
│ 1 │ 1 │
│ 2 │ 5 │
│ 2 │ 5 │
│ 3 │ 8 │
│ 4 │ 12 │
│ 5 │ 17 │
└────────┴─────┘
CURRENT ROW Peers
Are rows that fall into the same sort bucket and applies only to RANGE frame.
● No ORDER BY clause
SELECT
number,
sum(number) OVER () AS sum
FROM values('number Int8', 1, 2, 2, 3,
4, 5)
┌─number─┬─sum─┐
│ 1 │ 17 │
│ 2 │ 17 │
│ 2 │ 17 │
│ 3 │ 17 │
│ 4 │ 17 │
│ 5 │ 17 │
└────────┴─────┘
How do we define the extent of the frame?
20
● frame START
Defines start of the frame with the end
being set implicitly to current row (for
both ROWS and RANGE frame)
SELECT number,sum(number) OVER
(ORDER BY number ROWS 1
PRECEDING) AS sum FROM
numbers(1,5)
is actually
SELECT
number,
sum(number) OVER (ORDER BY
number ASC ROWS BETWEEN 1
PRECEDING AND CURRENT ROW) AS sum
FROM numbers(1, 5)
FRAME extent clause
● frame BETWEEN
Defines a frame with start and end specified explicitly
SELECT number,sum(number) OVER (ORDER BY
number ROWS BETWEEN 1 PRECEDING AND 1
FOLLOWING) AS sum FROM numbers(1,5)
is actually the same
SELECT
number,
sum(number) OVER (ORDER BY number ASC
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
AS sum
FROM numbers(1, 5)
More on frame extents!
21
● CURRENT ROW
Current row as the frame slides through the window
● UNBOUNDED PRECEDING
All rows before current row, if ROWS frame,
or first row’s value in window partition, if RANGE
frame
● UNBOUNDED FOLLOWING
All rows after current row, if ROWS frame,
or last row’s value in window partition if RANGE frame
FRAME extent clause
● expr PRECEDING
Offset in rows before current row, if ROWS frame,
or current row value minus expr, if RANGE frame
● expr FOLLOWING
Offset in rows before current row, if ROWS frame,
or current row value plus expr, if RANGE frame
Frame START and frame END offsets can be specified as
How do window functions work internally?
22
Apply window
functions
Fully
Aggregate,
Sort
Scan,
Partially
Aggregate
Scan,
Partially
Aggregate
Scan,
Partially
Aggregate
Data
Data
Data
Result
Sequential Sequential
Parallel
Using Window
functions in
practice
21.3 (LTS) - First experimental
support
21.8 - Pre-release experimental
feature
23
Computing cumulative monthly cancellations
SELECT FlightDate, count() AS Flights,
sum(Cancelled) AS Daily_Cancelled,
sum(Daily_Cancelled)
OVER (PARTITION BY toStartOfMonth(FlightDate)
ORDER BY FlightDate)
AS Cumul_Cancelled
FROM ontime
WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate
FlightDate|Flights|Daily_Cancelled|Cumul_Cancelled|
----------|-------|---------------|---------------|
2019-01-01| 18009| 141| 141|
2019-01-02| 20384| 173| 314|
. . .
24
Group by flight month
Order by date of light
Rank cancellations by week
SELECT FlightDate, count() AS Flights,
sum(Cancelled) AS Daily_Cancelled,
rank() OVER
(PARTITION BY toStartOfWeek(FlightDate)
ORDER BY Daily_Cancelled DESC) as Weekly_Rank
FROM ontime
WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate
FlightDate|Flights|Daily_Cancelled|Weekly_Rank|
----------|-------|---------------|-----------|
2019-01-01| 18009| 141| 2|
2019-01-02| 20384| 173| 1|
2019-01-03| 19522| 134| 3|
25
Group by week
Multiple ranks for aircraft flights
SELECT TailNum, any(Carrier) AS Carrier, count() Flights,
rank() OVER (ORDER BY Flights DESC) as Overall_Rank,
rank() OVER (PARTITION BY Carrier ORDER BY Flights DESC) as
Carrier_Rank
FROM ontime
WHERE toYYYYMM(FlightDate) = 201901
GROUP BY TailNum ORDER BY Flights DESC
TailNum|Carrier|Flights|Overall_Rank|Carrier_Rank|
-------|-------|-------|------------|------------|
|OH | 2543| 1| 1|
N488HA |HA | 361| 2| 1|
N481HA |HA | 348| 3| 2|
26
Reuse window definitions
SELECT FlightDate, count() AS Flights,
sum(Cancelled) AS Daily_Cancelled,
min(Daily_Cancelled) OVER 7_day as Min_Cancelled_7,
avg(Daily_Cancelled) OVER 7_day as Avg_Cancelled_7,
max(Daily_Cancelled) OVER 7_day as Max_Cancelled_7
FROM ontime WHERE Year = 2019
GROUP BY FlightDate WINDOW 7_day AS (ROWS BETWEEN 6 PRECEDING
AND CURRENT ROW) ORDER BY FlightDate
FlightDate|Flights|Daily_Cancelled|Min_Cancelled_7|...
----------|-------|---------------|---------------|...
2019-01-01| 18009| 141| 141|...
2019-01-02| 20384| 173| 141|...
27
Are window functions the only way?
28
“Definitely not!”
Rank cancellations by week using arrays
SELECT FlightDate, Flights, Daily_Cancelled, Weekly_Rank FROM
(
SELECT
groupArray(FlightDate) AS FlightDate_Arr,
groupArray(Flights) AS Flights_Arr,
groupArray(Daily_Cancelled) AS Daily_Cancelled_Arr,
arrayEnumerate(Daily_Cancelled_Arr) AS Daily_Cancelled_Indexes,
arraySort((x, y) -> -y, Daily_Cancelled_Indexes, Daily_Cancelled_Arr) as Rank_Array
FROM
(
SELECT FlightDate, count() AS Flights,
sum(Cancelled) AS Daily_Cancelled
FROM ontime
WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate
)
GROUP BY toStartOfWeek(FlightDate)
ORDER BY toStartOfWeek(FlightDate)
)
ARRAY JOIN FlightDate_Arr AS FlightDate, Flights_Arr AS Flights,
Daily_Cancelled_Arr AS Daily_Cancelled, Rank_Array AS Weekly_Rank
ORDER BY FlightDate
29
Sort indexes by descending
sum of cancelled flights
Unroll arrays again
Roll up values by week
Roadmap and
more
information
30
Not supported or doesn’t work
Some features of window functions that are not supported now or don’t work
● RANGE frame only works for UIntX/IntX, Date and DateTime types and is not
supported for other data types including Nullable
● No INTERVAL support for Date and DateTime types
● No EXCLUDE clause
● No GROUPS frame
● No lag(value, offset) and lag(value, offset) functions but workaround is
documented
● Expressions can’t use window functions
● Can’t use RANGE frame with a named window
31
More information on window functions
● ClickHouse window function docs
● Altinity Blog: ClickHouse Window Functions — Current State of the Art
● Altinity Software Requirements Spec: SRS019 ClickHouse Window Functions
● Alinity Knowledge Base, e.g., cumulative sums
● Blog article on Window Functions by TinyBird.co
32
33
And special thanks to:
33
Alexander Kuzmenkov @ Yandex -- Implemented window functions
Alexey Milovidov @ Yandex -- ClickHouse lead committer
Altinity QA team -- Testing!
Questions?
Thank you!
Altinity
https://altinity.com
ClickHouse
https://github.com/ClickH
ouse/ClickHouse
Altinity.Cloud
https://altinity.com/cloud-
database/
We are hiring!
34

Mais conteúdo relacionado

Mais procurados

Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfDeep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfAltinity Ltd
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesAltinity Ltd
 
Your first ClickHouse data warehouse
Your first ClickHouse data warehouseYour first ClickHouse data warehouse
Your first ClickHouse data warehouseAltinity Ltd
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Altinity Ltd
 
All about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAll about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAltinity Ltd
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
 
Better than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseBetter than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseAltinity Ltd
 
Altinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouseAltinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouseAltinity Ltd
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...Altinity Ltd
 
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...Altinity Ltd
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOAltinity Ltd
 
Altinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Ltd
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareAltinity Ltd
 
10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouserpolat
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEOAltinity Ltd
 
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareClickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareAltinity Ltd
 
Clickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek VavrusaClickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek VavrusaAltinity Ltd
 
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...Altinity Ltd
 
Materialize: a platform for changing data
Materialize: a platform for changing dataMaterialize: a platform for changing data
Materialize: a platform for changing dataAltinity Ltd
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevAltinity Ltd
 

Mais procurados (20)

Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfDeep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
 
Your first ClickHouse data warehouse
Your first ClickHouse data warehouseYour first ClickHouse data warehouse
Your first ClickHouse data warehouse
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
 
All about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAll about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdf
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei Milovidov
 
Better than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseBetter than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouse
 
Altinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouseAltinity Quickstart for ClickHouse
Altinity Quickstart for ClickHouse
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
 
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
 
Altinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdf
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
 
10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
 
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareClickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
 
Clickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek VavrusaClickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek Vavrusa
 
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...
Size Matters-Best Practices for Trillion Row Datasets on ClickHouse-2202-08-1...
 
Materialize: a platform for changing data
Materialize: a platform for changing dataMaterialize: a platform for changing data
Materialize: a platform for changing data
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 

Semelhante a Fun with click house window functions webinar slides 2021-08-19

Simplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsSimplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsClayton Groom
 
The Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresThe Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresEDB
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLJim Mlodgenski
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimizationRiyaj Shamsudeen
 
5.Analytical Function.pdf
5.Analytical Function.pdf5.Analytical Function.pdf
5.Analytical Function.pdfssuser8b6c85
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3Mahmoud Ouf
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house queryCristinaMunteanu43
 
PostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analyticsPostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analyticsHans-Jürgen Schönig
 
J. Adcock Bi Portfolio
J. Adcock   Bi PortfolioJ. Adcock   Bi Portfolio
J. Adcock Bi PortfolioJerry Adcock
 
Bis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newBis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newassignmentcloud85
 
ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...Altinity Ltd
 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsDave Stokes
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answerRaajTech
 
Aorta interpreter Builder 2019
Aorta interpreter Builder 2019Aorta interpreter Builder 2019
Aorta interpreter Builder 2019Igor Braga
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performanceGuy Harrison
 

Semelhante a Fun with click house window functions webinar slides 2021-08-19 (20)

Simplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsSimplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functions
 
The Magic of Window Functions in Postgres
The Magic of Window Functions in PostgresThe Magic of Window Functions in Postgres
The Magic of Window Functions in Postgres
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimization
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
5.Analytical Function.pdf
5.Analytical Function.pdf5.Analytical Function.pdf
5.Analytical Function.pdf
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house query
 
PostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analyticsPostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analytics
 
Chapter5.ppt
Chapter5.pptChapter5.ppt
Chapter5.ppt
 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQL
 
J. Adcock Bi Portfolio
J. Adcock   Bi PortfolioJ. Adcock   Bi Portfolio
J. Adcock Bi Portfolio
 
Bis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newBis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-new
 
ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...
 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database Analytics
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
Do You Know The 11g Plan?
Do You Know The 11g Plan?Do You Know The 11g Plan?
Do You Know The 11g Plan?
 
Aorta interpreter Builder 2019
Aorta interpreter Builder 2019Aorta interpreter Builder 2019
Aorta interpreter Builder 2019
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performance
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 

Mais de Altinity Ltd

Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxBuilding an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxAltinity Ltd
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Altinity Ltd
 
Building an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceBuilding an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceAltinity Ltd
 
Fun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfFun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfAltinity Ltd
 
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfCloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfAltinity Ltd
 
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Altinity Ltd
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Altinity Ltd
 
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfOwn your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfAltinity Ltd
 
ClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsAltinity Ltd
 
Adventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAdventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAltinity Ltd
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache PinotAltinity Ltd
 
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Ltd
 
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...Altinity Ltd
 
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfOSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfAltinity Ltd
 
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...Altinity Ltd
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...Altinity Ltd
 
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...Altinity Ltd
 
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...Altinity Ltd
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...Altinity Ltd
 
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfOSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfAltinity Ltd
 

Mais de Altinity Ltd (20)

Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxBuilding an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
 
Building an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceBuilding an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open Source
 
Fun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfFun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdf
 
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfCloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
 
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
 
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfOwn your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
 
ClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom Apps
 
Adventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAdventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree Engine
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
 
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
 
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
 
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfOSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
 
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
 
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
 
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
 
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfOSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
 

Último

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Fun with click house window functions webinar slides 2021-08-19

  • 1. Fun with ClickHouse Window Functions Robert Hodges and Vitaliy Zakaznikov @ Altinity 1
  • 2. Presenter Bios and Altinity Introduction The #1 enterprise ClickHouse provider. Now offering Altinity.Cloud Major committer and community sponsor for ClickHouse in US/EU Robert Hodges - CEO 30+ years on DBMS plus virtualization and security. ClickHouse is DBMS #20 Vitaliy Zakaznikov - QA Manager 13+ years testing hardware and software; author of TestFlows open source testing framework
  • 3. ClickHouse: a great SQL data warehouse Understands SQL Runs on bare metal to cloud Shared nothing architecture Stores data in columns Parallel and vectorized execution Scales to many petabytes Is Open source (Apache 2.0) a b c d a b c d a b c d a b c d And it’s really fast! 3
  • 4. Using the Altinity.Cloud public endpoint 4 https://github.demo.trial.altinity.cloud:8443/play User “demo” Password “demo” clickhouse-client --host=github.demo.trial.altinity.cloud -s --user=demo --password
  • 6. Let’s start with a simple query... SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Sum_Cancelled FROM ontime WHERE toYYYYMM(FlightDate) = 201901 GROUP BY FlightDate ORDER BY FlightDate FlightDate|Flights|Sum_Cancelled| ----------|-------|-------------| 2019-01-01| 18009| 141| 2019-01-02| 20384| 173| 6 Cancelled flights for Jan 2019
  • 7. 7 SQL queries work like “cubes” 7 FlightDate Cancelled 0 -- 1 -- 1/01 1/02 1/03 1/04 1/05 1/06 1/07 1/07 . .. 16807 Flights 129 Cancelled Dimension Metrics (count, sum) Dimension Carrier F l i g h t N u m TailNum (Other dimensions)
  • 8. ...But what happens if we want to... 8 Rank particular days by number of cancelled flights? Print cumulative cancellations for each month? Print trailing 7-day average cancellations? 8 How can I do that in SQL??
  • 9. This is a job for window functions! 9 Set session variable clickhouse101 :) SET allow_experimental_window_functions = 1 SET allow_experimental_window_functions = 1 Query id: f8aec38c-7f31-4544-96df-bcdb4034f0ac Ok. <yandex> <profiles> <default> <allow_experimental_window_functions>1</allow_...tions> . . . </default></profiles></yandex> But first we need to enable them... Set in user profile
  • 10. Window functions add a new option to SQL SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled, avg(Daily_Cancelled) OVER (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS Avg_Cancelled_7 FROM ontime_ref WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate FlightDate|Flights|Daily_Cancelled|Avg_Cancelled_7 | ----------|-------|---------------|------------------| . . . 2019-01-30| 19102| 2145| 805.5714285714286| 2019-01-31| 19962| 1775| 999.0| 2019-02-01| 20045| 459|1037.2857142857142| 10 Window function!
  • 11. How window functions work conceptually SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled, avg(Daily_Cancelled) OVER (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS Avg_Cancelled_7 FROM ontime_ref WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate 11 Operates on the computed aggregate Computes average within a window “frame” of 7 rows Result is another output column
  • 12. Window Functions -- The gory details 21.3 (LTS) - First experimental support 21.8 - Pre-release experimental feature (should be enabled by default soon) 12
  • 13. How do window functions work for users? 13
  • 14. Why do we need “gory details” anyway? 14 ● Empty OVER clause means that there is only one window that includes all the result rows ● When no ORDER BY clause is specified then all rows are the peers of the current row ● The default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW SELECT number, sum(number) OVER () FROM numbers(1, 5) ┌─number─┬─sum(number) OVER ()─┐ │ 1 │ 15 │ │ 2 │ 15 │ │ 3 │ 15 │ │ 4 │ 15 │ │ 5 │ 15 │ └────────┴─────────────────────┘ Window function behavior is not obvious!
  • 15. What can be a window function? 15 Any aggregate function ● min ● max ● sum ● avg ● etc. SELECT number, min(number) OVER () FROM numbers(1,5) Window native function ● row_number ● first_value ● last_value ● rank ● dense_rank ● leadInFrame ● lagInFrame SELECT number, rank() OVER (ORDER BY number) FROM numbers(1,5)
  • 16. What is an OVER clause? 16 ● Can be empty OVER defines the window specification ● Can contain window specification SELECT number, sum(number) OVER () FROM numbers(1,5) SELECT number, sum(number) OVER (PARTITION BY number) FROM numbers(1,5) ● Can refer to a named window SELECT number, sum(number) OVER w FROM numbers(1,5) WINDOW w AS (PARTITION BY number)
  • 17. What do window specifications look like? 17 ● PARTITION BY clause Defines window partition Window Specification clause [partition_clause] [order_clause] [frame_clause] ● ORDER BY clause Orders rows within a frame SELECT number, sum(number) OVER (PARTITION BY number % 2) FROM numbers(1,5) SELECT number, sum(number) OVER (ORDER BY number) FROM numbers(1,5) ● FRAME clause Defines frame within a window partition SELECT number, sum(number) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM numbers(1,5)
  • 18. What kind of frames are there? 18 ● ROWS frame Defines a frame with the range in terms of relationship of rows to the current row number SELECT number, sum(number) OVER (ORDER BY number ROWS 1 PRECEDING) AS sum FROM numbers(1, 3) ┌─number─┬─sum─┐ │ 1 │ 1 │ │ 2 │ 3 │ │ 3 │ 5 │ └────────┴─────┘ FRAME clause ● RANGE frame Defines a frame with the range in terms of row values from the current row value. SELECT number, sum(number) OVER (ORDER BY number RANGE 1 PRECEDING) AS sum FROM values('number Int8', 1, 2, 2, 4) ┌─number─┬─sum─┐ │ 1 │ 1 │ │ 2 │ 5 │ │ 2 │ 5 │ │ 4 │ 4 │ └────────┴─────┘
  • 19. What are current rows peers? 19 ● With ORDER BY clause SELECT number, sum(number) OVER (ORDER BY number) AS sum FROM values('number Int8', 1, 2, 2, 3, 4, 5) ┌─number─┬─sum─┐ │ 1 │ 1 │ │ 2 │ 5 │ │ 2 │ 5 │ │ 3 │ 8 │ │ 4 │ 12 │ │ 5 │ 17 │ └────────┴─────┘ CURRENT ROW Peers Are rows that fall into the same sort bucket and applies only to RANGE frame. ● No ORDER BY clause SELECT number, sum(number) OVER () AS sum FROM values('number Int8', 1, 2, 2, 3, 4, 5) ┌─number─┬─sum─┐ │ 1 │ 17 │ │ 2 │ 17 │ │ 2 │ 17 │ │ 3 │ 17 │ │ 4 │ 17 │ │ 5 │ 17 │ └────────┴─────┘
  • 20. How do we define the extent of the frame? 20 ● frame START Defines start of the frame with the end being set implicitly to current row (for both ROWS and RANGE frame) SELECT number,sum(number) OVER (ORDER BY number ROWS 1 PRECEDING) AS sum FROM numbers(1,5) is actually SELECT number, sum(number) OVER (ORDER BY number ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS sum FROM numbers(1, 5) FRAME extent clause ● frame BETWEEN Defines a frame with start and end specified explicitly SELECT number,sum(number) OVER (ORDER BY number ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum FROM numbers(1,5) is actually the same SELECT number, sum(number) OVER (ORDER BY number ASC ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum FROM numbers(1, 5)
  • 21. More on frame extents! 21 ● CURRENT ROW Current row as the frame slides through the window ● UNBOUNDED PRECEDING All rows before current row, if ROWS frame, or first row’s value in window partition, if RANGE frame ● UNBOUNDED FOLLOWING All rows after current row, if ROWS frame, or last row’s value in window partition if RANGE frame FRAME extent clause ● expr PRECEDING Offset in rows before current row, if ROWS frame, or current row value minus expr, if RANGE frame ● expr FOLLOWING Offset in rows before current row, if ROWS frame, or current row value plus expr, if RANGE frame Frame START and frame END offsets can be specified as
  • 22. How do window functions work internally? 22 Apply window functions Fully Aggregate, Sort Scan, Partially Aggregate Scan, Partially Aggregate Scan, Partially Aggregate Data Data Data Result Sequential Sequential Parallel
  • 23. Using Window functions in practice 21.3 (LTS) - First experimental support 21.8 - Pre-release experimental feature 23
  • 24. Computing cumulative monthly cancellations SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled, sum(Daily_Cancelled) OVER (PARTITION BY toStartOfMonth(FlightDate) ORDER BY FlightDate) AS Cumul_Cancelled FROM ontime WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate FlightDate|Flights|Daily_Cancelled|Cumul_Cancelled| ----------|-------|---------------|---------------| 2019-01-01| 18009| 141| 141| 2019-01-02| 20384| 173| 314| . . . 24 Group by flight month Order by date of light
  • 25. Rank cancellations by week SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled, rank() OVER (PARTITION BY toStartOfWeek(FlightDate) ORDER BY Daily_Cancelled DESC) as Weekly_Rank FROM ontime WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate FlightDate|Flights|Daily_Cancelled|Weekly_Rank| ----------|-------|---------------|-----------| 2019-01-01| 18009| 141| 2| 2019-01-02| 20384| 173| 1| 2019-01-03| 19522| 134| 3| 25 Group by week
  • 26. Multiple ranks for aircraft flights SELECT TailNum, any(Carrier) AS Carrier, count() Flights, rank() OVER (ORDER BY Flights DESC) as Overall_Rank, rank() OVER (PARTITION BY Carrier ORDER BY Flights DESC) as Carrier_Rank FROM ontime WHERE toYYYYMM(FlightDate) = 201901 GROUP BY TailNum ORDER BY Flights DESC TailNum|Carrier|Flights|Overall_Rank|Carrier_Rank| -------|-------|-------|------------|------------| |OH | 2543| 1| 1| N488HA |HA | 361| 2| 1| N481HA |HA | 348| 3| 2| 26
  • 27. Reuse window definitions SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled, min(Daily_Cancelled) OVER 7_day as Min_Cancelled_7, avg(Daily_Cancelled) OVER 7_day as Avg_Cancelled_7, max(Daily_Cancelled) OVER 7_day as Max_Cancelled_7 FROM ontime WHERE Year = 2019 GROUP BY FlightDate WINDOW 7_day AS (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) ORDER BY FlightDate FlightDate|Flights|Daily_Cancelled|Min_Cancelled_7|... ----------|-------|---------------|---------------|... 2019-01-01| 18009| 141| 141|... 2019-01-02| 20384| 173| 141|... 27
  • 28. Are window functions the only way? 28 “Definitely not!”
  • 29. Rank cancellations by week using arrays SELECT FlightDate, Flights, Daily_Cancelled, Weekly_Rank FROM ( SELECT groupArray(FlightDate) AS FlightDate_Arr, groupArray(Flights) AS Flights_Arr, groupArray(Daily_Cancelled) AS Daily_Cancelled_Arr, arrayEnumerate(Daily_Cancelled_Arr) AS Daily_Cancelled_Indexes, arraySort((x, y) -> -y, Daily_Cancelled_Indexes, Daily_Cancelled_Arr) as Rank_Array FROM ( SELECT FlightDate, count() AS Flights, sum(Cancelled) AS Daily_Cancelled FROM ontime WHERE Year = 2019 GROUP BY FlightDate ORDER BY FlightDate ) GROUP BY toStartOfWeek(FlightDate) ORDER BY toStartOfWeek(FlightDate) ) ARRAY JOIN FlightDate_Arr AS FlightDate, Flights_Arr AS Flights, Daily_Cancelled_Arr AS Daily_Cancelled, Rank_Array AS Weekly_Rank ORDER BY FlightDate 29 Sort indexes by descending sum of cancelled flights Unroll arrays again Roll up values by week
  • 31. Not supported or doesn’t work Some features of window functions that are not supported now or don’t work ● RANGE frame only works for UIntX/IntX, Date and DateTime types and is not supported for other data types including Nullable ● No INTERVAL support for Date and DateTime types ● No EXCLUDE clause ● No GROUPS frame ● No lag(value, offset) and lag(value, offset) functions but workaround is documented ● Expressions can’t use window functions ● Can’t use RANGE frame with a named window 31
  • 32. More information on window functions ● ClickHouse window function docs ● Altinity Blog: ClickHouse Window Functions — Current State of the Art ● Altinity Software Requirements Spec: SRS019 ClickHouse Window Functions ● Alinity Knowledge Base, e.g., cumulative sums ● Blog article on Window Functions by TinyBird.co 32
  • 33. 33 And special thanks to: 33 Alexander Kuzmenkov @ Yandex -- Implemented window functions Alexey Milovidov @ Yandex -- ClickHouse lead committer Altinity QA team -- Testing!