semolina.introspection

The result types of Engine.introspect().

Frozen dataclasses describing a semantic view as the warehouse reports it. Each engine’s introspect() produces them, and semolina codegen renders them into a SemanticView subclass. They live outside semolina.codegen because introspect() is part of the core API, and the CLI’s package is not.

Classes

IntrospectedField

Intermediate representation of a single field from an introspected semantic view.

IntrospectedView

Intermediate representation of a semantic view returned by engine introspection.

Module Contents

class semolina.introspection.IntrospectedField[source]

Intermediate representation of a single field from an introspected semantic view.

Produced by warehouse introspection engines and consumed by the Python code renderer to generate Metric, Dimension, or Fact field declarations.

name[source]

Python attribute name for the field (e.g., ‘revenue’, ‘country’): the column name folded by its engine (lower-cased for Snowflake and Databricks), then made a valid, unique identifier by python_field_names().

field_type[source]

Semantic role of the field: ‘metric’, ‘dimension’, or ‘fact’.

data_type[source]

Python annotation string (e.g., ‘int’, ‘str’, ‘datetime.date’), or None if the SQL type has no clean Python equivalent (triggers a TODO comment in the generated output).

description[source]

Human-readable description of the field. Defaults to empty string if the warehouse provides no description metadata.

source_name[source]

Original warehouse column name when name does not lead back to it. Set when the column was created with a quoted identifier (e.g., "order_id" in Snowflake, stored as lowercase), and whenever python_field_names() had to change the name (what? becomes what_). None for standard columns that round-trip correctly through normalize_identifier.

raw_type[source]

The warehouse’s own spelling of the column type (e.g. 'DECIMAL(38,2)', '{"type": "FIXED", "scale": 2}'), carried so the renderer can preserve it as a comment for annotations that do not name it. None means the engine supplied no raw type, and the renderer then emits no comment rather than guessing one.

class semolina.introspection.IntrospectedView[source]

Intermediate representation of a semantic view returned by engine introspection.

Produced by Engine.introspect() and consumed by the Python code renderer to generate a complete SemanticView subclass.

view_name[source]

Warehouse identifier for the view (e.g., ‘sales_view’). Used as the view= parameter in the generated SemanticView subclass.

class_name[source]

Python class name to use in the generated code (e.g., ‘Sales’). Derived from view_name by the introspection layer (snake_case → PascalCase).

fields[source]

All fields discovered in the view, in the order returned by the warehouse API. Includes metrics, dimensions, and facts.