Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pyiceberg/view/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
from __future__ import annotations

import time
from typing import Literal

from pydantic import Field, RootModel, field_validator
Expand Down Expand Up @@ -44,13 +45,13 @@ class ViewRepresentation(IcebergBaseModel, RootModel):
class ViewVersion(IcebergBaseModel):
"""A version of the view definition."""

version_id: int = Field(alias="version-id")
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")
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()
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"""
Expand Down
4 changes: 0 additions & 4 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,8 +1746,6 @@ def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example
identifier=("fokko", "fokko2"),
schema=table_schema_simple,
view_version=ViewVersion(
version_id=1,
timestamp_ms=12345,
schema_id=1,
summary={"engine-name": "spark", "engineVersion": "3.3"},
Comment thread
ebyhr marked this conversation as resolved.
representations=[
Expand Down Expand Up @@ -1791,8 +1789,6 @@ def test_create_view_409(
identifier=("fokko", "fokko2"),
schema=table_schema_simple,
view_version=ViewVersion(
version_id=1,
timestamp_ms=12345,
schema_id=1,
summary={"engine-name": "spark", "engineVersion": "3.3"},
Comment thread
ebyhr marked this conversation as resolved.
representations=[],
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/test_writes/test_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,10 +1769,7 @@ def test_create_view(
identifier = "default.some_view"
schema = pa.schema([pa.field("some_col", pa.int32())])
view_version = ViewVersion(
version_id=1,
schema_id=1,
timestamp_ms=int(time.time() * 1000),
summary={},
representations=[
SQLViewRepresentation(
type="sql",
Expand Down