Skip to content

Commit

Permalink
wip: add impl
Browse files Browse the repository at this point in the history
  • Loading branch information
unknowntpo committed Dec 25, 2024
1 parent 69f3224 commit 090e874
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ class IdentityPartition(Partition):
its partition name is "dt=2008-08-08/country=us", field names are [["dt"], ["country"]] and
values are ["2008-08-08", "us"].
This class is evolving and may change in future versions.
"""

@abstractmethod
def field_names(self) -> List[List[str]]:
"""
Returns the field names of the identity partition.
Returns:
List[List[str]]: A list of lists representing the field names of the identity partition.
"""
Expand All @@ -47,10 +43,7 @@ def field_names(self) -> List[List[str]]:
@abstractmethod
def values(self) -> List[Any]:
"""
Returns the values of the identity partition. The values are in the same order as the field
names.
Returns:
List[Any]: A list representing the values of the identity partition.
List[Any]: The values of the identity partition.
"""
pass
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

from abc import abstractmethod
from typing import List, Any
from .partition import Partition

from gravitino.api.expressions.partitions.partition import Partition

class ListPartition(Partition):
"""
Expand All @@ -31,16 +32,12 @@ class ListPartition(Partition):
```
its name is "p202204_California" and lists are [["2022-04-01","Los Angeles"], ["2022-04-01", "San Francisco"]].
This class is evolving and may change in future versions.
"""

@abstractmethod
def lists(self) -> List[List[Any]]:
"""
Returns the values of the list partition.
Returns:
List[List[Any]]: A list of lists representing the values of the list partition.
List[List[Any]]: The values of the list partition.
"""
pass
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ class Partition(ABC):
"""
A partition represents a result of partitioning a table. The partition can be either a
`IdentityPartition`, `ListPartition`, or `RangePartition`. It depends on the `Table.partitioning()`.
This class is evolving and may change in future versions.
"""

@abstractmethod
def name(self) -> str:
"""
Returns the name of the partition.
Returns:
str: The name of the partition.
"""
Expand All @@ -39,9 +35,7 @@ def name(self) -> str:
@abstractmethod
def properties(self) -> Dict[str, str]:
"""
Returns the properties of the partition, such as statistics, location, etc.
Returns:
Dict[str, str]: A dictionary containing the properties of the partition.
Dict[str, str]: The properties of the partition, such as statistics, location, etc.
"""
pass
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
# under the License.

from abc import abstractmethod
from typing import Optional
from .partition import Partition
from .literal import Literal
from typing import Any

from gravitino.api.expressions.literals.literal import Literal
from gravitino.api.expressions.partitions.partition import Partition

class RangePartition(Partition):
"""
Expand All @@ -29,24 +30,20 @@ class RangePartition(Partition):
```
its upper bound is "2020-03-22" and its lower bound is null.
This class is evolving and may change in future versions.
"""

@abstractmethod
def upper(self) -> Optional[Literal]:
def upper(self) -> Literal[Any]:
"""
Returns:
Optional[Literal]: The upper bound of the partition, or None if there is no upper bound.
Literal[Any]: The upper bound of the partition.
"""
pass

@abstractmethod
def lower(self) -> Optional[Literal]:
def lower(self) -> Literal[Any]:
"""
Returns the lower bound of the partition.
Returns:
Optional[Literal]: The lower bound of the partition, or None if there is no lower bound.
Literal[Any]: The lower bound of the partition.
"""
pass

0 comments on commit 090e874

Please sign in to comment.