Skip to content

Commit 4b40d56

Browse files
committed
Add abstract method
1 parent 202ff3d commit 4b40d56

6 files changed

Lines changed: 88 additions & 0 deletions

File tree

pyiceberg/catalog/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
)
7474
from pyiceberg.utils.config import Config, merge_config
7575
from pyiceberg.utils.properties import property_as_bool
76+
from pyiceberg.view import View
77+
from pyiceberg.view.metadata import ViewVersion
7678

7779
if TYPE_CHECKING:
7880
import pyarrow as pa
@@ -657,6 +659,32 @@ def drop_view(self, identifier: Union[str, Identifier]) -> None:
657659
NoSuchViewError: If a view with the given name does not exist.
658660
"""
659661

662+
@abstractmethod
663+
def create_view(
664+
self,
665+
identifier: Union[str, Identifier],
666+
schema: Union[Schema, "pa.Schema"],
667+
view_version: ViewVersion,
668+
location: Optional[str] = None,
669+
properties: Properties = EMPTY_DICT,
670+
) -> View:
671+
"""Create a view.
672+
673+
Args:
674+
identifier (str | Identifier): View identifier.
675+
schema (Schema): View's schema.
676+
location (str | None): Location for the view. Optional Argument.
677+
partition_spec (PartitionSpec): PartitionSpec for the view.
678+
sort_order (SortOrder): SortOrder for the view.
679+
properties (Properties): View properties that can be a string based dictionary.
680+
681+
Returns:
682+
View: the created view instance.
683+
684+
Raises:
685+
ViewAlreadyExistsError: If a view with the name already exists.
686+
"""
687+
660688
@staticmethod
661689
def identifier_to_tuple(identifier: Union[str, Identifier]) -> Identifier:
662690
"""Parse an identifier to a tuple.

pyiceberg/catalog/dynamodb.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
)
6464
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
6565
from pyiceberg.utils.properties import get_first_property_value
66+
from pyiceberg.view import View
67+
from pyiceberg.view.metadata import ViewVersion
6668

6769
if TYPE_CHECKING:
6870
import pyarrow as pa
@@ -538,6 +540,16 @@ def update_namespace_properties(
538540

539541
return properties_update_summary
540542

543+
def create_view(
544+
self,
545+
identifier: Union[str, Identifier],
546+
schema: Union[Schema, "pa.Schema"],
547+
view_version: ViewVersion,
548+
location: Optional[str] = None,
549+
properties: Properties = EMPTY_DICT,
550+
) -> View:
551+
raise NotImplementedError
552+
541553
def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]:
542554
raise NotImplementedError
543555

pyiceberg/catalog/glue.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
UUIDType,
9090
)
9191
from pyiceberg.utils.properties import get_first_property_value, property_as_bool
92+
from pyiceberg.view import View
93+
from pyiceberg.view.metadata import ViewVersion
9294

9395
if TYPE_CHECKING:
9496
import pyarrow as pa
@@ -809,6 +811,16 @@ def update_namespace_properties(
809811

810812
return properties_update_summary
811813

814+
def create_view(
815+
self,
816+
identifier: Union[str, Identifier],
817+
schema: Union[Schema, "pa.Schema"],
818+
view_version: ViewVersion,
819+
location: Optional[str] = None,
820+
properties: Properties = EMPTY_DICT,
821+
) -> View:
822+
raise NotImplementedError
823+
812824
def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]:
813825
raise NotImplementedError
814826

pyiceberg/catalog/hive.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
UUIDType,
117117
)
118118
from pyiceberg.utils.properties import property_as_bool, property_as_float
119+
from pyiceberg.view import View
120+
from pyiceberg.view.metadata import ViewVersion
119121

120122
if TYPE_CHECKING:
121123
import pyarrow as pa
@@ -439,6 +441,16 @@ def create_table(
439441

440442
return self._convert_hive_into_iceberg(hive_table)
441443

444+
def create_view(
445+
self,
446+
identifier: Union[str, Identifier],
447+
schema: Union[Schema, "pa.Schema"],
448+
view_version: ViewVersion,
449+
location: Optional[str] = None,
450+
properties: Properties = EMPTY_DICT,
451+
) -> View:
452+
raise NotImplementedError
453+
442454
def register_table(self, identifier: Union[str, Identifier], metadata_location: str) -> Table:
443455
"""Register a new table using existing metadata.
444456

pyiceberg/catalog/noop.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
TableUpdate,
3838
)
3939
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
40+
from pyiceberg.view import View
41+
from pyiceberg.view.metadata import ViewVersion
4042

4143
if TYPE_CHECKING:
4244
import pyarrow as pa
@@ -126,5 +128,15 @@ def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]:
126128
def view_exists(self, identifier: Union[str, Identifier]) -> bool:
127129
raise NotImplementedError
128130

131+
def create_view(
132+
self,
133+
identifier: Union[str, Identifier],
134+
schema: Union[Schema, "pa.Schema"],
135+
view_version: ViewVersion,
136+
location: Optional[str] = None,
137+
properties: Properties = EMPTY_DICT,
138+
) -> View:
139+
raise NotImplementedError
140+
129141
def drop_view(self, identifier: Union[str, Identifier]) -> None:
130142
raise NotImplementedError

pyiceberg/catalog/sql.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
)
7373
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
7474
from pyiceberg.types import strtobool
75+
from pyiceberg.view import View
76+
from pyiceberg.view.metadata import ViewVersion
7577

7678
if TYPE_CHECKING:
7779
import pyarrow as pa
@@ -722,6 +724,16 @@ def update_namespace_properties(
722724
session.commit()
723725
return properties_update_summary
724726

727+
def create_view(
728+
self,
729+
identifier: Union[str, Identifier],
730+
schema: Union[Schema, "pa.Schema"],
731+
view_version: ViewVersion,
732+
location: Optional[str] = None,
733+
properties: Properties = EMPTY_DICT,
734+
) -> View:
735+
raise NotImplementedError
736+
725737
def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]:
726738
raise NotImplementedError
727739

0 commit comments

Comments
 (0)