marivo.semantic.entity#

marivo.semantic.entity(*, name, datasource, source, primary_key=None, versioning=None, domain=None, ai_context=None)[source]#

Declare an entity over a structured physical source.

Parameters:
  • name (str) – Entity name.

  • datasource (DatasourceRef | str) – Datasource ref returned by md.ref(...) or a global datasource name string declared in models/datasources/*.py.

  • source (TableSourceIR | ParquetSourceIR | CsvSourceIR) – Structured physical source, usually ms.table(...) or ms.parquet(...), or ms.csv(...).

  • primary_key (list[str] | None) – Optional list of column names forming the primary key.

  • domain (DomainRef | None) – Override the active domain namespace with a DomainRef returned by ms.domain(...). Defaults to the file’s default domain.

  • ai_context (AiContext | None) – Optional AiContext with extra agent-facing hints.

  • versioning (SnapshotVersioningIR | ValidityVersioningIR | None)

Returns:

An EntityRef usable by @ms.dimension and @ms.metric.

Raises:

SemanticDecoratorErrordatasource is not a datasource ref or string, name collides with another object, or source is not an entity source.

Return type:

EntityRef

Example

>>> orders = ms.entity(
...     name="orders",
...     datasource="warehouse",
...     source=ms.table("orders", database="sales_mart"),
... )