🤖 Track your AI apps.
Use our free template.
Back
Sep 29, 2021

ClickHouse Tips #12: Apply Functions to Columns with a Single Call

Clickhouse 21 allows some fancy operations packed into multiple columns with SELECT modifiers.
TinybirdTeam

Sometimes we have to apply simple operations in multiple columns and modify the stored/original value of those columns. ClickHouse has SELECT modifiers that can help us: APPLY, EXCEPT AND REPLACE.

Let’s see some easy examples using this simple set:

The first one APPLY will apply a function to all the columns we specify in the SELECT clause like:

Now, with EXCEPT we can select different columns except the ones specified, and we can combine the modifiers:

Start building with Tinybird!
If you've read this far, you might want to use Tinybird as your analytics backend. You can just get started, on the free plan.

The last one is REPLACE that you can use again apply simple visual functions and replace columns with new values, using alias expressions:

Sweet right? well as we said you can mix them all like this:

or this,

And stay tuned for the next ClickHouse release 21.10 in which we can use a lambda function inside an APPLY.

Subscribe to our newsletter
Get 10 links weekly to the Data and AI articles the Tinybird team is reading.
Do you like this post? Spread it!

Related posts

Skip the infra work. Ship your first API today.

Read the docs
Tinybird wordmark