marivo.semantic#
marivo.semantic - Python-native semantic layer (v1.1).
Public surface:
import marivo.semantic as ms
catalog = ms.load() # returns SemanticCatalog
catalog = ms.load(domains=['sales']) # filter to specific domains
catalog.list().show()
catalog.list(kind="metric").show() # all metrics across domains
catalog.list(domain="sales", kind="metric").show() # metrics in one domain
ms.domain(name="sales", default=True)
orders = ms.entity(name="orders", datasource="warehouse", source=ms.table("orders"))
@ms.measure(entity=orders, additivity="additive", unit="USD")
def amount(orders):
return orders.amount
revenue = ms.aggregate(name="revenue", measure=amount, agg="sum")
Declaration decorators#
Declare an entity over a structured physical source. |
|
Declare a categorical dimension whose body returns an ibis expression over its entity. |
|
Declare a row-level quantitative measure whose expression can be aggregated. |
|
Declare a metric from an ibis body. |
|
Declare a join relationship between two entities. |
|
Declare a time-aware dimension that carries grain and parsing metadata. |
|
Declare a semantic domain namespace inside a project file. |
Aggregation & measure helpers#
Declare a tier-1 simple metric: an aggregation over a measure. |
|
Declare a derived linear metric (no body): sum of |
|
Declare a derived ratio metric (no body). |
|
Declare a derived weighted-average metric (no body). |
|
Declare a semi-additive nature: additive off the |
|
Declare daily snapshot partition versioning for an entity. |
|
Declare SCD2 validity interval versioning for an entity. |
|
Build one relationship key pair for |
Time parsing#
Declare an already-temporal datetime column parse. |
|
Declare an already-temporal timestamp column parse. |
|
Declare a string/integer strptime parse. |
|
Declare an hour-only partition parse using a day prefix column. |
Source builders & provenance#
Readiness & verification#
Run structural readiness check for the given semantic refs. |
|
Return a demand-ranked advisory richness report. |
|
Verify a single authored semantic object is reachable and valid. |
|
Run parity check for a metric against its source SQL. |
|
Record an authoring decision into the evidence ledger. |
Refs & loading#
Discovery#
Ref types#
Ref returned by ms.entity(). |
|
Ref returned by ms.dimension(). |
|
Ref returned by ms.measure(). |
|
Ref returned by ms.aggregate(), @ms.metric(), and derived constructors. |
|
Ref returned by ms.relationship(). |
|
Ref returned by ms.time_dimension(). |
|
Ref returned by ms.domain(). |
|
Stable identity for a semantic object, shared across all layers. |
Brief types#
Details types#
Details for an entity object. |
|
Details for a categorical dimension object. |
|
Details for a row-level quantitative measure object. |
|
Represent a PEP 604 union type |
|
Details for a relationship between entities. |
|
Details for a time dimension object. |
|
Details for a domain object. |
|
Details for a datasource object. |
|
Details for a derived (composed) metric. |
|
Details for a simple (entity-backed) metric. |
|
Represent a PEP 604 union type |
Catalog & objects#
Read-only object graph over a loaded semantic project. |
|
Single read shape for all loaded semantic objects. |
|
Browsing result returned by catalog.list(...). |
|
Row-level quantitative declaration that metrics aggregate. |
Sources & versioning#
Represent a PEP 604 union type |
|
Represent a PEP 604 union type |
|
SQL parity provenance for a Python-authored metric body. |
|
Represent a PEP 604 union type |
|
Time-parse specs#
Parse a time-dimension column as a calendar date. |
|
Parse a time-dimension column as a datetime, optionally timezone-aware. |
|
Parse a time-dimension column as a timestamp, optionally timezone-aware. |
|
Parse a time-dimension column using an explicit |
|
Parse a time-dimension column from an hour-prefixed string. |
|
A candidate temporal format inferred for a time-dimension column. |
Readiness & assessment#
Result of a single metric parity check. |
|
Facts & signals#
One left/right relationship key pair. |
|
AI context#
Structured AI-facing context for semantic objects. |
|
Errors#
Raised when a prepare_* call requires a prerequisite verify_object that hasn't been completed. |
Submodules#
|
Typed semantic errors and warnings raised across the semantic layer. |
|
Shared type aliases for the semantic surface. |
Type aliases#
Represent a PEP 604 union type |
|
Represent a PEP 604 union type |