OLAP Database
Viewing:
Overview
The OLAP Database capability 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.
Enabling OLAP Database
In your moose.config.toml
file, enable the OLAP Database capability:
[features]
olap = true
Basic Example
interface MyFirstTable {
id: Key<string>;
name: string;
age: number;
}
// Create a table named "first_table"
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")
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