Skip to content

metadata

SQLViewRepresentation

Bases: IcebergBaseModel

Represents the SQL query that defines the view.

Source code in pyiceberg/view/metadata.py
class SQLViewRepresentation(IcebergBaseModel):
    """Represents the SQL query that defines the view."""

    type: Literal["sql"] = Field()
    """A string that indicates the type of representation. Must be `sql`"""
    sql: str = Field()
    """A string that contains the SQL text of the view definition."""
    dialect: str = Field()
    """The dialect of the SQL, e.g. `spark`, `trino`, `presto`."""

dialect = Field() class-attribute instance-attribute

The dialect of the SQL, e.g. spark, trino, presto.

sql = Field() class-attribute instance-attribute

A string that contains the SQL text of the view definition.

type = Field() class-attribute instance-attribute

A string that indicates the type of representation. Must be sql

ViewHistoryEntry

Bases: IcebergBaseModel

A log entry of a view version change.

Source code in pyiceberg/view/metadata.py
class ViewHistoryEntry(IcebergBaseModel):
    """A log entry of a view version change."""

    timestamp_ms: int = Field(alias="timestamp-ms")
    """Timestamp when the version was created (ms from epoch)"""
    version_id: int = Field(alias="version-id")
    """ID for the version"""

timestamp_ms = Field(alias='timestamp-ms') class-attribute instance-attribute

Timestamp when the version was created (ms from epoch)

version_id = Field(alias='version-id') class-attribute instance-attribute

ID for the version

ViewMetadata

Bases: IcebergBaseModel

The metadata for a view.

Source code in pyiceberg/view/metadata.py
class ViewMetadata(IcebergBaseModel):
    """The metadata for a view."""

    view_uuid: str = Field(alias="view-uuid")
    """A UUID that identifies the view, generated when the view is created."""
    format_version: ViewVersionLiteral = Field(alias="format-version", ge=1, le=1)
    """An integer version number for the view format; must be 1"""
    location: str = Field()
    """The view's base location; used to create metadata file locations"""
    schemas: list[Schema] = Field()
    """A list of known schemas"""
    current_version_id: int = Field(alias="current-version-id")
    """ID of the current version of the view (version-id)"""
    versions: list[ViewVersion] = Field()
    """A list of known versions of the view"""
    version_log: list[ViewHistoryEntry] = Field(alias="version-log")
    """A list of version log entries"""
    properties: dict[str, str] = Field(default_factory=dict)
    """A string to string map of view properties"""

    @field_validator("properties", mode="before")
    def transform_properties_dict_value_to_str(cls, properties: Properties) -> dict[str, str]:
        return transform_dict_value_to_str(properties)

current_version_id = Field(alias='current-version-id') class-attribute instance-attribute

ID of the current version of the view (version-id)

format_version = Field(alias='format-version', ge=1, le=1) class-attribute instance-attribute

An integer version number for the view format; must be 1

location = Field() class-attribute instance-attribute

The view's base location; used to create metadata file locations

properties = Field(default_factory=dict) class-attribute instance-attribute

A string to string map of view properties

schemas = Field() class-attribute instance-attribute

A list of known schemas

version_log = Field(alias='version-log') class-attribute instance-attribute

A list of version log entries

versions = Field() class-attribute instance-attribute

A list of known versions of the view

view_uuid = Field(alias='view-uuid') class-attribute instance-attribute

A UUID that identifies the view, generated when the view is created.

ViewVersion

Bases: IcebergBaseModel

A version of the view definition.

Source code in pyiceberg/view/metadata.py
class ViewVersion(IcebergBaseModel):
    """A version of the view definition."""

    version_id: int = Field(alias="version-id", default=1)
    """ID for the version"""
    schema_id: int = Field(alias="schema-id")
    """ID of the schema for the view version"""
    timestamp_ms: int = Field(alias="timestamp-ms", default_factory=lambda: int(time.time() * 1000))
    """Timestamp when the version was created (ms from epoch)"""
    summary: dict[str, str] = Field(default_factory=dict)
    """A string to string map of summary metadata about the version"""
    representations: list[ViewRepresentation] = Field()
    """A list of representations for the view definition"""
    default_catalog: str | None = Field(alias="default-catalog", default=None)
    """Catalog name to use when a reference in the SELECT does not contain a catalog"""
    default_namespace: Identifier = Field(alias="default-namespace")
    """Namespace to use when a reference in the SELECT is a single identifier"""

default_catalog = Field(alias='default-catalog', default=None) class-attribute instance-attribute

Catalog name to use when a reference in the SELECT does not contain a catalog

default_namespace = Field(alias='default-namespace') class-attribute instance-attribute

Namespace to use when a reference in the SELECT is a single identifier

representations = Field() class-attribute instance-attribute

A list of representations for the view definition

schema_id = Field(alias='schema-id') class-attribute instance-attribute

ID of the schema for the view version

summary = Field(default_factory=dict) class-attribute instance-attribute

A string to string map of summary metadata about the version

timestamp_ms = Field(alias='timestamp-ms', default_factory=lambda: int(time.time() * 1000)) class-attribute instance-attribute

Timestamp when the version was created (ms from epoch)

version_id = Field(alias='version-id', default=1) class-attribute instance-attribute

ID for the version