Skip to content

The merge table function

YouTube Video: b4YfRhD9SSI

Mark Needham

This video demonstrates using ClickHouse's merge table function to query multiple tables with different schemas simultaneously. You'll see how ClickHouse automatically handles data type unification and performs parallelized reading across tables, making it easy to work with evolving data.

Using a real tennis dataset spanning multiple decades, the tutorial shows how the merge function intelligently combines tables where column types have changed over time. You'll learn how ClickHouse promotes data types to their most compatible common type and creates variant types when no common type exists between tables.

  • Practical Schema Handling: See how tables with evolving schemas (like winner_seed changing from string to uint8 to uint16) are automatically unified in query results
  • Variant Type Queries: Learn to write queries that handle variant types using conditional logic with variantType() and variantElement() functions
  • Column Differences: Understand how columns that exist in some tables but not others appear in merged results, and how to work with the special _table variable to track row origins
  • Real-World Examples: Follow along with queries that find specific tennis match data across decades, including handling complex scenarios like detecting walkovers across different data formats

The video walks through writing increasingly complex queries, demonstrating how to extract meaningful insights from heterogeneous table structures. It also shows both the power and practical considerations when working with the merge table function in production scenarios.

Recent videos

YouTube Video: e-NnqMTY_3A

How to

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.

YouTube Video: BsmTK-pa5ks

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.

Follow us

XBlueskySlackGithubTelegramMeetupRSS