Jul 21, 2021

ClickHouse tips #10: Null behavior with LowCardinality columns

Does it work? What's actually inserted?
Alejandro del Amo
Data 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.

SCHEMA > Evolution
Get 10 links weekly to the Data and AI articles the Tinybird team is reading.

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:

Do you like this post?

Related posts

ClickHouse tips #7: Forward and backfilling null values
Add data from CSVs with different column orders
A big performance boost, adding columns and more

Tinybird

Team

May 31, 2021
Changelog #18: High-frequency ingestion, handling NDJSON files and more product enhancements

Tinybird

Team

Feb 01, 2022
ClickHouse Tips #12: Apply Functions to Columns with a Single Call

Tinybird

Team

Sep 29, 2021
ClickHouse tips #9: Filling gaps in time-series on ClickHouse
Changelog: BigQuery connector, CLI improvements, Pagination on endpoints and more

Tinybird

Team

Mar 04, 2021
The era of JSON data analytics
ClickHouse tips #11: Best way to get query types

Tinybird

Team

Sep 22, 2021
Changelog #15: improved data flow graph, anomaly detection and more

Tinybird

Team

Jun 25, 2021

Build fast data products, faster.

Try Tinybird and bring your data sources together and enable engineers to build with data in minutes. No credit card required, free to get started.
Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.