💧 Raindrop migrated from Postgres to Tinybird in 1 week.
Read how.
Back
Jul 21, 2021

ClickHouse tips #10: Null behavior with LowCardinality columns

Does it work? What's actually inserted?
Alejandro del AmoData Engineer

If you have LowCardinality(String) column, inserting a NULL value will work fine. It will just treat it like you just have inserted an empty string (‘’). Let’s see an example.

Let’s insert some values now.

And now let’s see what has been inserted. As you can see, even though we inserted a NULL value, internally it’s saved as an empty string.

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.

Bonus: can you create LowCardinality(Nullable(String)) columns?

Yes, you can.

Using LowCardinality(Nullable(String)) instead of Nullable(String), apart of the benefits that it can bring LowCardinality if the conditions are right, also allows you to order by that column. See an example here:

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