Moose OLAP
Viewing:
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
Ensure your OlapTable is correctly exported from your app/index.ts
file.
Ensure your OlapTable is correctly imported into your main.py
file.
Learn more about export pattern: local development / hosted.
interface MyFirstTable {
id: Key<string>;
name: string;
age: number;
}
// Create a table named "first_table"
export const myTable = new OlapTable<MyFirstTable>("first_table");
from pydantic import BaseModel
from moose_lib import Key, OlapTable
class MyFirstTable(BaseModel):
id: Key[str]
name: str
age: int
# Create a table named "first_table"
my_table = OlapTable[MyFirstTable]("first_table")
# No export needed - Python modules are automatically discovered
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 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
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:
[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
Accessing your data
These capabilities are available from other MooseStack modules or even from your own client applications:
Read Data
Insert Data
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:
[clickhouse_config]
db_name = "local"
user = "panda"
password = "pandapass"
use_ssl = false
host = "localhost"
host_port = 18123
native_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