Skip to content

Commit

Permalink
refactor: tweak typings and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
unknowntpo committed Jan 2, 2025
1 parent cf8f399 commit 9d1ceda
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ 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"].
APIs that are still evolving towards becoming stable APIs, and can change from one feature release to another (0.5.0 to 0.6.0).
"""

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ListPartition(Partition):
```
its name is "p202204_California" and lists are [["2022-04-01","Los Angeles"], ["2022-04-01", "San Francisco"]].
APIs that are still evolving towards becoming stable APIs, and can change from one feature release to another (0.5.0 to 0.6.0).
"""

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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()`.
APIs that are still evolving towards becoming stable APIs, and can change from one feature release to another (0.5.0 to 0.6.0).
"""

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# under the License.

from typing import List, Dict, Any, Optional
from abc import ABC, abstractmethod

from gravitino.api.expressions.literals.literal import Literal
from gravitino.api.expressions.partitions.identity_partition import IdentityPartition
Expand Down Expand Up @@ -57,8 +56,8 @@ def range(
@staticmethod
def list(
name: str,
lists: List[List[Literal]],
properties: Optional[Dict[str, str]] = None,
lists: List[List[Literal[Any]]],
properties: Optional[Dict[str, str]],
) -> ListPartition:
"""
Creates a list partition.
Expand All @@ -77,7 +76,7 @@ def list(
def identity(
name: Optional[str],
field_names: List[List[str]],
values: List[Literal],
values: List[Literal[Any]],
properties: Optional[Dict[str, str]] = None,
) -> IdentityPartition:
"""
Expand All @@ -98,30 +97,34 @@ def identity(


class RangePartitionImpl(RangePartition):
"""
Represents a result of range partitioning.
"""

def __init__(
self,
name: str,
upper: Literal,
lower: Literal,
upper: Literal[Any],
lower: Literal[Any],
properties: Optional[Dict[str, str]],
):
self._name = name
self._upper = upper
self._lower = lower
self._properties = properties

def upper(self) -> Literal:
def upper(self) -> Literal[Any]:
"""Returns the upper bound of the partition."""
return self._upper

def lower(self) -> Literal:
def lower(self) -> Literal[Any]:
"""Returns the lower bound of the partition."""
return self._lower

def name(self) -> str:
return self._name

def properties(self) -> Optional[Dict[str, str]]:
def properties(self) -> Dict[str, str]:
return self._properties

def __eq__(self, other: Any) -> bool:
Expand All @@ -144,14 +147,14 @@ class ListPartitionImpl(ListPartition):
def __init__(
self,
name: str,
lists: List[List[Literal]],
lists: List[List[Literal[Any]]],
properties: Optional[Dict[str, str]],
):
self._name = name
self._lists = lists
self._properties = properties

def lists(self) -> List[List[Literal]]:
def lists(self) -> List[List[Literal[Any]]]:
"""Returns the values of the list partition."""
return self._lists

Expand Down Expand Up @@ -183,9 +186,9 @@ def __hash__(self) -> int:
class IdentityPartitionImpl(IdentityPartition):
def __init__(
self,
name: Optional[str],
name: str,
field_names: List[List[str]],
values: List[Literal],
values: List[Literal[Any]],
properties: Dict[str, str],
):
self._name = name
Expand All @@ -197,7 +200,7 @@ def field_names(self) -> List[List[str]]:
"""Returns the field names of the identity partition."""
return self._field_names

def values(self) -> List[Literal]:
def values(self) -> List[Literal[Any]]:
"""Returns the values of the identity partition."""
return self._values

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class RangePartition(Partition):
```
its upper bound is "2020-03-22" and its lower bound is null.
APIs that are still evolving towards becoming stable APIs, and can change from one feature release to another (0.5.0 to 0.6.0).
"""

@abstractmethod
Expand Down

0 comments on commit 9d1ceda

Please sign in to comment.