snowflake.snowpark.Session.semantic_view¶
- Session.semantic_view(name: Union[str, Sequence[str]], *, dimensions: Optional[Union[str, Sequence[str]]] = None, metrics: Optional[Union[str, Sequence[str]]] = None, facts: Optional[Union[str, Sequence[str]]] = None, where: Optional[Union[str, Sequence[str]]] = None) DataFrame[source]¶
Returns a
DataFramefor a query against a semantic view.At least one of
dimensions,metrics, orfactsis required;wherealone is not a valid query.A clause string is emitted verbatim, so several members and inline
ASaliases can be written in one string. Clauses are always emitted in the orderDIMENSIONS,METRICS,FACTS,WHERE, which sets the default column order; reorder withDataFrame.select().Note
The strings passed to
dimensions,metrics,facts, andwhereare emitted verbatim, without any check or escaping. Do not build them from untrusted input.- Parameters:
name – A string, or a sequence of strings, that specifies the semantic view name or fully-qualified object identifier (database name, schema name, and semantic view name).
dimensions – Members to group by, as a verbatim clause string or a sequence of member strings, which are comma-joined. A member may carry an inline alias, as
"orders.revenue AS REV".metrics – Members to aggregate, in the same forms as
dimensions.facts – Row-level members, in the same forms as
dimensions. The server rejectsfactstogether withmetrics.where – A condition applied before aggregation. Pass a string, which is emitted verbatim, or a sequence of conditions, which are
AND-joined with each one parenthesized.WHEREtakes a single expression, so a sequence is how several conditions compose. A condition may reference dimensions and facts, but not metrics: a metric is filtered after aggregation, withDataFrame.filter()on the returned DataFrame.
Examples:
This function or method is in public preview since 1.57.0.