Videos

The merge table function

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.

Follow us
X imageBluesky imageSlack image
GitHub imageTelegram imageMeetup image
Rss image