1. MooseStack
  2. Moose OLAP

On this page

OverviewBasic ExampleGetting startedImport your schema from an existing ClickHouse databaseStart from scratchEnabling Moose OLAPCore CapabilitiesManaging your databaseAccessing your dataConnecting to your ClickHouse instanceCombining with other modules:

Moose OLAP

Overview

The Moose OLAP module provides standalone ClickHouse database management with type-safe schemas. You can use this capability independently to create tables, materialized views, and manage your table schemas without requiring other MooseStack components.

Basic Example

Export Requirement

In TypeScript, you must export all primitives (tables, views, etc.) for Moose to discover them. For example: export { myTable }

import { Key, OlapTable } from "@514labs/moose-lib"; interface MyFirstTable {  id: Key<string>;  name: string;  age: number;} // Create a table named "first_table"export const myTable = new OlapTable<MyFirstTable>("first_table");

Getting started

If you're new to Moose OLAP, choose one of these paths:

Import your schema from an existing ClickHouse database

moose init your-project-name --from-remote
Review the full guide

Review the full guide to learn more about how to bootstrap a new Moose OLAP project from an existing ClickHouse DB.

Start from scratch

Create a blank project, then model your first table:

moose init your-project-name --language <typescript|python>
cd your-project-name
Next steps: Model a table

Review the guide to learn more about how to model your first table.

Working with ClickPipes/PeerDB? Read External Tables and keep them in sync with DB Pull.

Enabling Moose OLAP

In your moose.config.toml file, enable the OLAP Database capability:

moose.config.toml
[features]olap = true

Core Capabilities

  • Model tables and views with TypeScript or Python
  • Automatic type mapping and support for advanced ClickHouse column types (e.g JSON, LowCardinality, Nullable, etc)
  • Create tables and views with one line of code
  • In-database transformations/materialized views
  • Migrations and schema evolution
  • Query with templated SQL strings and type-safe table and column references
  • Bulk insertion with failure handling and runtime validation

Managing your database

Tables
OLAP Tables
Define and create ClickHouse tables with type-safe schemas
Materialized Views
Materialized Views
Pre-compute and store query results for faster analytics
Data Modeling
Schema Optimization
Schema design best practices to optimize your queries

Accessing your data

These capabilities are available from other MooseStack modules or even from your own client applications:

Read Data
Write type-safe SQL queries with automatic interpolation
Learn More →
Insert Data
Bulk insert and manage data in your OLAP tables
Learn More →

Connecting to your ClickHouse instance

You can connect to your ClickHouse instance with your favorite database client. Your credentials are located in your moose.config.toml file:

moose.config.toml
[clickhouse_config]db_name = "local"user = "panda"password = "pandapass"use_ssl = falsehost = "localhost"host_port = 18123native_port = 9000
Default Credentials

These are the default credentials for your local ClickHouse instance running in dev mode.

Combining with other modules:

Although designed to work independently, Moose OLAP can be combined with other modules to add additional capabilities surrounding your database:

  • Combine with Streaming and APIs to setup streaming ingestion into ClickHouse tables
  • Combine with Workflows to build ETL pipelines and data transformations
  • Combine with APIs to expose your ClickHouse queries to client applications via REST API
Migrations
Dynamic Migrations
Always keep your code and database in sync with dynamic migrations
  • Overview
  • Quick Start
  • Templates / Examples
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
MooseStack in your App
  • App / API frameworks
Modules
  • Moose OLAP
    • Data Modeling
    • Tables
    • Views
    • Materialized Views
    • Materialized Columns
    • External Data & Introspection
    • External Tables
    • Introspecting Tables
    • Data Access
    • Inserting Data
    • Reading Data
    • Performance & Optimization
    • Schema Optimization
    • Secondary & Data-skipping Indexes
    • TTL (Time-to-Live)
    • Schema Versioning
  • Moose Streaming
  • Moose Workflows
  • Moose APIs
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Changelog
Contribution
  • Documentation
  • Framework
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplates
Changelog
Source506