# Moose / Olap / Model View Documentation – Python ## Included Files 1. moose/olap/model-view/model-view.mdx ## Modeling Views Source: moose/olap/model-view/model-view.mdx Define standard ClickHouse Views for read-time projections # Modeling Views ## Overview Views are read-time projections in ClickHouse. A static `SELECT` defines the view over one or more base tables or other views. Moose wraps [ClickHouse `VIEW`](https://clickhouse.com/docs/en/sql-reference/statements/create/view) with a simple `View` class in Python. You provide the view name, the `SELECT`, and the list of source tables/views so Moose can order DDL correctly during migrations. Use `View` when you want a virtual read-time projection and don’t need write-time transformation or a separate storage table. For write-time pipelines and backfills, use a Materialized View instead. ## Basic Usage ```python filename="BasicUsage.py" copy from moose_lib import View from tables import users, events active_user_events = View( "active_user_events", """ SELECT {events.columns.id} AS event_id, {users.columns.id} AS user_id, {users.columns.name} AS user_name, {events.columns.ts} AS ts FROM {events} JOIN {users} ON {events.columns.user_id} = {users.columns.id} WHERE {users.columns.active} = 1 """, [events, users], ) ``` ## Quick Reference ```python filename="Signature.py" copy # View(name: str, select_statement: str, base_tables: list[OlapTable | View]) View( "view_name", "SELECT ... FROM {someTable}", [someTable], ) ``` The `SELECT` should be static (no runtime parameters). In TypeScript, prefer Moose’s `sql` template for safe table/column interpolation; in Python, use string templates with `{table.columns.col}`.