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:

  • name and source
  • tenant_key
  • time_key
  • dimensions
  • measures
  • filters
  • relationships
  • limits

See Dimensions, Measures, and Relationships for the main building blocks.

On this page

Get early access to hypequery cloud.

Cloud hosts the same model you run in your backend, with a managed API and MCP server, versions, and rollback. We're letting teams in a few at a time. Join the waitlist and we'll reach out when your project can go live.

How do you want to build your analytics layer? (Optional)
What features do you most need? (Optional)

Pick as many as you like.

Only your email is required. All other questions are optional.