Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Python Schema in Rust #684

Merged
merged 10 commits into from
Aug 10, 2022
Merged
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ env_logger = "0"
reqwest = { version = "*", features = ["native-tls-vendored"] }
serde_json = "1"
chrono = "0"
regex = "1"
lazy_static = "1"

[dependencies.pyo3]
version = "0.16"
Expand Down
110 changes: 110 additions & 0 deletions python/deltalake/deltalake.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from typing import Any, Callable, Dict, List, Optional, Union

import pyarrow as pa
from typing_extensions import Literal

from deltalake.writer import AddAction

RawDeltaTable: Any
rust_core_version: Callable[[], str]
DeltaStorageFsBackend: Any

class PyDeltaTableError(BaseException): ...

write_new_deltalake: Callable[[str, pa.Schema, List[AddAction], str, List[str]], None]

# Can't implement inheritance (see note in src/schema.rs), so this is next
# best thing.
DataType = Union["PrimitiveType", "MapType", "StructType", "ArrayType"]

class PrimitiveType:
def __init__(self, data_type: str) -> None: ...
type: str

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "PrimitiveType": ...
def to_pyarrow(self) -> pa.DataType: ...
@staticmethod
def from_pyarrow(type: pa.DataType) -> "PrimitiveType": ...

class ArrayType:
def __init__(
self, element_type: DataType, *, contains_null: bool = True
) -> None: ...
type: Literal["array"]
element_type: DataType
contains_null: bool

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "ArrayType": ...
def to_pyarrow(
self,
) -> pa.ListType: ...
@staticmethod
def from_pyarrow(type: pa.ListType) -> "ArrayType": ...

class MapType:
def __init__(
self,
key_type: DataType,
value_type: DataType,
*,
value_contains_null: bool = True
) -> None: ...
type: Literal["map"]
key_type: DataType
value_type: DataType
value_contains_null: bool

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "MapType": ...
def to_pyarrow(self) -> pa.MapType: ...
@staticmethod
def from_pyarrow(type: pa.MapType) -> "MapType": ...

class Field:
def __init__(
self,
name: str,
type: DataType,
*,
nullable: bool = True,
metadata: Optional[Dict[str, Any]] = None
) -> None: ...
name: str
type: DataType
nullable: bool
metadata: Dict[str, Any]

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "Field": ...
def to_pyarrow(self) -> pa.Field: ...
@staticmethod
def from_pyarrow(type: pa.Field) -> "Field": ...

class StructType:
def __init__(self, fields: List[Field]) -> None: ...
type: Literal["struct"]
fields: List[Field]

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "StructType": ...
def to_pyarrow(self) -> pa.StructType: ...
@staticmethod
def from_pyarrow(type: pa.StructType) -> "StructType": ...

class Schema:
def __init__(self, fields: List[Field]) -> None: ...
fields: List[Field]

def to_json(self) -> str: ...
@staticmethod
def from_json(json: str) -> "Schema": ...
def to_pyarrow(self) -> pa.Schema: ...
@staticmethod
def from_pyarrow(type: pa.Schema) -> "Schema": ...
Loading