Python SDK
Definition
Create dataset definitions over ClickHouse tables and views in Python.
A dataset is a semantic model over a source table or view.
from hypequery.datasets import Dataset, dimension, measure
orders = Dataset(
name="orders",
source="orders",
tenant_key="tenant_id",
time_key="created_at",
dimensions={
"id": dimension("number"),
"created_at": dimension("timestamp"),
},
measures={
"revenue": measure.sum("amount"),
},
)name is the logical dataset name and source is the physical table or view. tenant_key and time_key are the
columns used for runtime tenant isolation and time grains.
Datasets are immutable Pydantic models, validated when you create them. Define them at module level and import them
where you query. The dataset(name, *, source=..., dimensions=..., ...) helper builds the same model with the
keyword spelling the TypeScript dataset() entrypoint uses.
Fields
A dataset can include:
nameandsourcetenant_keytime_keydimensionsmeasuresfiltersrelationshipslimits
See Dimensions, Measures, and Relationships for the main building blocks.