We value your privacy

This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content. See our Privacy Policy.

  1. MooseStack
  2. Engines
  3. Merge

Merge

The Merge engine provides a read-only view over multiple tables matching a regex pattern.

MergeTable.ts
import { OlapTable, ClickHouseEngines } from '@514labs/moose-lib'; interface Event {  eventId: string;  userId: string;  timestamp: number;} // Read-only view over all tables matching ^events_.*$ in the current databaseexport const allEvents = new OlapTable<Event>("all_events", {  engine: ClickHouseEngines.Merge,  sourceDatabase: "currentDatabase()",  tablesRegexp: "^events_.*$",});

Configuration Options

OptionDescription
sourceDatabaseDatabase to scan for source tables. Accepts a literal name, currentDatabase(), or REGEXP('pattern')
tablesRegexpRegular expression pattern to match table names within the source database

The database field accepts:

  • currentDatabase() — matches the configured database, works across dev and prod without hardcoding
  • Literal name (e.g., "analytics") — matches a specific database
  • REGEXP('pattern') — matches multiple databases by regex

Limitations

  • Read-only: INSERT operations are not supported. Cannot be used as a destination in IngestPipeline.
  • No ORDER BY, PARTITION BY, or SAMPLE BY: These clauses are not supported on Merge tables.
  • Self-hosted only: Not supported on ClickHouse Cloud (see supported engines).
  • Other constant expressions (e.g., concat('a', 'b')) for source database will cause the table to be recreated on each restart. ClickHouse evaluates and stores the result (e.g., 'ab'), so the expression never matches Moose's configured value and the table is dropped and recreated every time. Use currentDatabase() or a literal name instead.

For more details, see the ClickHouse Merge documentation.

On this page

Configuration OptionsLimitations
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackHostingTemplatesGuides
Release Notes
Source531
  • Overview
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Language Server
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs & Web Apps
Deployment & Lifecycle
  • Moose Dev
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework
MergeTable.ts
import { OlapTable, ClickHouseEngines } from '@514labs/moose-lib'; interface Event {  eventId: string;  userId: string;  timestamp: number;} // Read-only view over all tables matching ^events_.*$ in the current databaseexport const allEvents = new OlapTable<Event>("all_events", {  engine: ClickHouseEngines.Merge,  sourceDatabase: "currentDatabase()",  tablesRegexp: "^events_.*$",});
OptionDescription
sourceDatabaseDatabase to scan for source tables. Accepts a literal name, currentDatabase(), or REGEXP('pattern')
tablesRegexpRegular expression pattern to match table names within the source database