MooseStack

Moose OLAP

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

Export Required

Ensure your OlapTable is correctly exported from your app/index.ts file.

Learn more about export pattern: local development / hosted.

FirstTable.ts
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

Terminal
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:

Terminal
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:

[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
Migrations

Dynamic Migrations

Always keep your code and database in sync with dynamic migrations

Accessing your data

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

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 = 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