Skip to content

Commit d992977

Browse files
committed
Add defaults to ViewVersion fields
1 parent b066577 commit d992977

3 files changed

Lines changed: 4 additions & 12 deletions

File tree

‎pyiceberg/view/metadata.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19+
import time
1920
from typing import Literal
2021

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

47-
version_id: int = Field(alias="version-id")
48+
version_id: int = Field(alias="version-id", default=1)
4849
"""ID for the version"""
4950
schema_id: int = Field(alias="schema-id")
5051
"""ID of the schema for the view version"""
51-
timestamp_ms: int = Field(alias="timestamp-ms")
52+
timestamp_ms: int = Field(alias="timestamp-ms", default=int(time.time() * 1000))
5253
"""Timestamp when the version was created (ms from epoch)"""
53-
summary: dict[str, str] = Field()
54+
summary: dict[str, str] = Field(default={})
5455
"""A string to string map of summary metadata about the version"""
5556
representations: list[ViewRepresentation] = Field()
5657
"""A list of representations for the view definition"""

‎tests/catalog/test_rest.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,10 +1746,7 @@ def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example
17461746
identifier=("fokko", "fokko2"),
17471747
schema=table_schema_simple,
17481748
view_version=ViewVersion(
1749-
version_id=1,
1750-
timestamp_ms=12345,
17511749
schema_id=1,
1752-
summary={"engine-name": "spark", "engineVersion": "3.3"},
17531750
representations=[
17541751
{
17551752
"type": "sql",
@@ -1791,10 +1788,7 @@ def test_create_view_409(
17911788
identifier=("fokko", "fokko2"),
17921789
schema=table_schema_simple,
17931790
view_version=ViewVersion(
1794-
version_id=1,
1795-
timestamp_ms=12345,
17961791
schema_id=1,
1797-
summary={"engine-name": "spark", "engineVersion": "3.3"},
17981792
representations=[],
17991793
default_namespace=[],
18001794
),

‎tests/integration/test_writes/test_writes.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,10 +1769,7 @@ def test_create_view(
17691769
identifier = "default.some_view"
17701770
schema = pa.schema([pa.field("some_col", pa.int32())])
17711771
view_version = ViewVersion(
1772-
version_id=1,
17731772
schema_id=1,
1774-
timestamp_ms=int(time.time() * 1000),
1775-
summary={},
17761773
representations=[
17771774
SQLViewRepresentation(
17781775
type="sql",

0 commit comments

Comments
 (0)