1
1
import sys
2
- from typing import Any , Callable , Dict , List , Mapping , Optional , Tuple , Union
2
+ from typing import Any , Dict , List , Mapping , Optional , Tuple , Union
3
3
4
4
if sys .version_info >= (3 , 8 ):
5
5
from typing import Literal
@@ -13,24 +13,104 @@ from deltalake.writer import AddAction
13
13
14
14
__version__ : str
15
15
16
- RawDeltaTable : Any
17
- rust_core_version : Callable [[], str ]
18
-
19
- write_new_deltalake : Callable [
20
- [
21
- str ,
22
- pa .Schema ,
23
- List [AddAction ],
24
- str ,
25
- List [str ],
26
- Optional [str ],
27
- Optional [str ],
28
- Optional [Mapping [str , Optional [str ]]],
29
- Optional [Dict [str , str ]],
30
- ],
31
- None ,
32
- ]
16
+ class RawDeltaTableMetaData :
17
+ id : int
18
+ name : str
19
+ description : str
20
+ partition_columns : List [str ]
21
+ created_time : int
22
+ configuration : Dict [str , str ]
23
+
24
+ class RawDeltaTable :
25
+ schema : Any
26
+
27
+ def __init__ (
28
+ self ,
29
+ table_uri : str ,
30
+ version : Optional [int ],
31
+ storage_options : Optional [Dict [str , str ]],
32
+ without_files : bool ,
33
+ log_buffer_size : Optional [int ],
34
+ ) -> None : ...
35
+ @staticmethod
36
+ def get_table_uri_from_data_catalog (
37
+ data_catalog : str ,
38
+ database_name : str ,
39
+ table_name : str ,
40
+ data_catalog_id : Optional [str ] = None ,
41
+ catalog_options : Optional [Dict [str , str ]] = None ,
42
+ ) -> str : ...
43
+ def table_uri (self ) -> str : ...
44
+ def version (self ) -> int : ...
45
+ def metadata (self ) -> RawDeltaTableMetaData : ...
46
+ def protocol_versions (self ) -> List [int ]: ...
47
+ def load_version (self , version : int ) -> None : ...
48
+ def load_with_datetime (self , ds : str ) -> None : ...
49
+ def files_by_partitions (
50
+ self , partitions_filters : Optional [FilterType ]
51
+ ) -> List [str ]: ...
52
+ def files (self , partition_filters : Optional [FilterType ]) -> List [str ]: ...
53
+ def file_uris (self , partition_filters : Optional [FilterType ]) -> List [str ]: ...
54
+ def vacuum (
55
+ self ,
56
+ dry_run : bool ,
57
+ retention_hours : Optional [int ],
58
+ enforce_retention_duration : bool ,
59
+ ) -> List [str ]: ...
60
+ def compact_optimize (
61
+ self ,
62
+ partition_filters : Optional [FilterType ],
63
+ target_size : Optional [int ],
64
+ max_concurrent_tasks : Optional [int ],
65
+ min_commit_interval : Optional [int ],
66
+ ) -> str : ...
67
+ def z_order_optimize (
68
+ self ,
69
+ z_order_columns : List [str ],
70
+ partition_filters : Optional [FilterType ],
71
+ target_size : Optional [int ],
72
+ max_concurrent_tasks : Optional [int ],
73
+ max_spill_size : Optional [int ],
74
+ min_commit_interval : Optional [int ],
75
+ ) -> str : ...
76
+ def restore (
77
+ self ,
78
+ target : Optional [Any ],
79
+ ignore_missing_files : bool ,
80
+ protocol_downgrade_allowed : bool ,
81
+ ) -> str : ...
82
+ def history (self , limit : Optional [int ]) -> List [str ]: ...
83
+ def update_incremental (self ) -> None : ...
84
+ def dataset_partitions (
85
+ self , schema : pa .Schema , partition_filters : Optional [FilterType ]
86
+ ) -> List [Any ]: ...
87
+ def create_checkpoint (self ) -> None : ...
88
+ def get_add_actions (self , flatten : bool ) -> pa .RecordBatch : ...
89
+ def delete (self , predicate : Optional [str ]) -> str : ...
90
+ def get_active_partitions (
91
+ self , partitions_filters : Optional [FilterType ] = None
92
+ ) -> Any : ...
93
+ def create_write_transaction (
94
+ self ,
95
+ add_actions : List [AddAction ],
96
+ mode : str ,
97
+ partition_by : List [str ],
98
+ schema : pa .Schema ,
99
+ partitions_filters : Optional [FilterType ],
100
+ ) -> None : ...
33
101
102
+ def rust_core_version () -> str : ...
103
+ def write_new_deltalake (
104
+ table_uri : str ,
105
+ schema : pa .Schema ,
106
+ add_actions : List [AddAction ],
107
+ _mode : str ,
108
+ partition_by : List [str ],
109
+ name : Optional [str ],
110
+ description : Optional [str ],
111
+ configuration : Optional [Mapping [str , Optional [str ]]],
112
+ storage_options : Optional [Dict [str , str ]],
113
+ ) -> None : ...
34
114
def batch_distinct (batch : pa .RecordBatch ) -> pa .RecordBatch : ...
35
115
36
116
# Can't implement inheritance (see note in src/schema.rs), so this is next
@@ -93,34 +173,18 @@ class Field:
93
173
* ,
94
174
nullable : bool = True ,
95
175
metadata : Optional [Dict [str , Any ]] = None ,
96
- ) -> None :
97
- """A named field, with a data type, nullability, and optional metadata."""
176
+ ) -> None : ...
98
177
name : str
99
- """The field name."""
100
178
type : DataType
101
- """The field data type."""
102
179
nullable : bool
103
- """The field nullability."""
104
180
metadata : Dict [str , Any ]
105
- """The field metadata."""
106
-
107
- def to_json (self ) -> str :
108
- """Get the JSON representation of the Field.
109
181
110
- :rtype: str
111
- """
182
+ def to_json (self ) -> str : ...
112
183
@staticmethod
113
- def from_json (json : str ) -> "Field" :
114
- """Create a new Field from a JSON string.
115
-
116
- :param json: A json string representing the Field.
117
- :rtype: Field
118
- """
119
- def to_pyarrow (self ) -> pa .Field :
120
- """Convert field to a pyarrow.Field."""
184
+ def from_json (json : str ) -> "Field" : ...
185
+ def to_pyarrow (self ) -> pa .Field : ...
121
186
@staticmethod
122
- def from_pyarrow (type : pa .Field ) -> "Field" :
123
- """Create a new field from pyarrow.Field."""
187
+ def from_pyarrow (type : pa .Field ) -> "Field" : ...
124
188
125
189
class StructType :
126
190
def __init__ (self , fields : List [Field ]) -> None : ...
@@ -138,41 +202,13 @@ class Schema:
138
202
def __init__ (self , fields : List [Field ]) -> None : ...
139
203
fields : List [Field ]
140
204
invariants : List [Tuple [str , str ]]
141
- """The list of invariants defined on the table.
142
-
143
- The first string in each tuple is the field path, the second is the SQL of the invariant.
144
- """
145
205
146
- def to_json (self ) -> str :
147
- """Get the JSON representation of the schema.
148
-
149
- :rtype: str
150
- """
206
+ def to_json (self ) -> str : ...
151
207
@staticmethod
152
- def from_json (json : str ) -> "Schema" :
153
- """Create a new Schema from a JSON string.
154
-
155
- :param schema_json: a JSON string
156
- :rtype: Schema
157
- """
158
- def to_pyarrow (self , as_large_types : bool = False ) -> pa .Schema :
159
- """Return equivalent PyArrow schema.
160
-
161
- Note: this conversion is lossy as the Invariants are not stored in pyarrow.Schema.
162
-
163
- :param as_large_types: get schema with all variable size types (list,
164
- binary, string) as large variants (with int64 indices). This is for
165
- compatibility with systems like Polars that only support the large
166
- versions of Arrow types.
167
- :rtype: pyarrow.Schema
168
- """
208
+ def from_json (json : str ) -> "Schema" : ...
209
+ def to_pyarrow (self , as_large_types : bool = False ) -> pa .Schema : ...
169
210
@staticmethod
170
- def from_pyarrow (type : pa .Schema ) -> "Schema" :
171
- """Create a new Schema from a pyarrow.Schema.
172
-
173
- :param data_type: a PyArrow schema
174
- :rtype: Schema
175
- """
211
+ def from_pyarrow (type : pa .Schema ) -> "Schema" : ...
176
212
177
213
class ObjectInputFile :
178
214
@property
@@ -289,3 +325,8 @@ class DeltaProtocolError(DeltaError):
289
325
"""Raised when a violation with the Delta protocol specs ocurred."""
290
326
291
327
pass
328
+
329
+ FilterLiteralType = Tuple [str , str , Any ]
330
+ FilterConjunctionType = List [FilterLiteralType ]
331
+ FilterDNFType = List [FilterConjunctionType ]
332
+ FilterType = Union [FilterConjunctionType , FilterDNFType ]
0 commit comments