Inspect incoming data with INSERT … RETURNING in ClickHouse

Use INSERT … RETURNING in ClickHouse 26.11 to inspect generated values, sample incoming rows, find invalid ratings, and summarise an ingestion batch.
ClickHouse 26.11 adds INSERT … RETURNING, letting you query incoming rows and return results as part of the same INSERT statement.
In this demo, we load 93.7 million Amazon reviews from S3 and use RETURNING to inspect generated column values, sample every 10 millionth row, find deliberately invalid star ratings, and summarise the ingestion batch.
The RETURNING query sees the current insert batch, not the existing contents of the table. Filtering its output doesn't stop those rows from being inserted. We also see why row samples can stream back during ingestion, while the final aggregate summary waits for the whole batch.
Chapters
- 00:00 What INSERT … RETURNING does
- 00:21 Create a table with generated columns
- 00:41 Return inserted rows and generated values
- 01:15 Sample every 10 millionth row
- 01:54 Find invalid star ratings
- 02:27 Summarise the ingestion batch
Resources
Related videos
View all Videos
How to
Reading and writing Vortex files with ClickHouse (26.11)
Query and export Vortex files with ClickHouse 26.11, using a FineWeb dataset containing just over a million web pages.
