forked from apache/datafusion-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.pyi
More file actions
353 lines (336 loc) · 13.3 KB
/
__init__.pyi
File metadata and controls
353 lines (336 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
import pyarrow as pa
from pyarrow.dataset import Dataset
import pandas as pd
import polars as pl
from ..udf import Accumulator, WindowEvaluator
from ..context import ArrowStreamExportable, TableProviderExportable
from .expr import SortExpr, Expr
class Catalog:
def names(self) -> List[str]: ...
def database(self, name: str = "public") -> Database: ...
class Database:
def names(self) -> Set[str]: ...
def table(self, name: str) -> Table: ...
class Table:
@property
def schema(self) -> pa.Schema: ...
@property
def kind(self) -> str: ...
class SessionConfig:
def __init__(self, config_options: Optional[Dict[str, str]] = None) -> None: ...
def with_create_default_catalog_and_schema(
self, enabled: bool
) -> SessionConfig: ...
def with_default_catalog_and_schema(
self, catalog: str, schema: str
) -> SessionConfig: ...
def with_information_schema(self, enabled: bool) -> SessionConfig: ...
def with_batch_size(self, batch_size: int) -> SessionConfig: ...
def with_target_partitions(self, target_partitions: int) -> SessionConfig: ...
def with_repartition_aggregations(self, enabled: bool) -> SessionConfig: ...
def with_repartition_joins(self, enabled: bool) -> SessionConfig: ...
def with_repartition_windows(self, enabled: bool) -> SessionConfig: ...
def with_repartition_sorts(self, enabled: bool) -> SessionConfig: ...
def with_repartition_file_scans(self, enabled: bool) -> SessionConfig: ...
def with_repartition_file_min_size(self, size: int) -> SessionConfig: ...
def with_parquet_pruning(self, enabled: bool) -> SessionConfig: ...
def set(self, key: str, value: str) -> SessionConfig: ...
class RuntimeEnvBuilder:
def __init__(self) -> None: ...
def with_disk_manager_disabled(self) -> RuntimeEnvBuilder: ...
def with_disk_manager_os(self) -> RuntimeEnvBuilder: ...
def with_disk_manager_specified(self, paths: List[str]) -> RuntimeEnvBuilder: ...
def with_unbounded_memory_pool(self) -> RuntimeEnvBuilder: ...
def with_fair_spill_pool(self, size: int) -> RuntimeEnvBuilder: ...
def with_greedy_memory_pool(self, size: int) -> RuntimeEnvBuilder: ...
def with_temp_file_path(self, path: str) -> RuntimeEnvBuilder: ...
class SQLOptions:
def __init__(self) -> None: ...
def with_allow_ddl(self, allow: bool) -> SQLOptions: ...
def with_allow_dml(self, allow: bool) -> SQLOptions: ...
def with_allow_statements(self, allow: bool) -> SQLOptions: ...
class SessionContext:
def __init__(
self,
config: Optional[SessionConfig] = None,
runtime: Optional[RuntimeEnvBuilder] = None,
) -> None: ...
def enable_url_table(self) -> SessionContext: ...
def register_object_store(
self, schema: str, storage: Any, host: Optional[str] = None
): ...
def register_listing_table(
self,
name: str,
path: str,
table_partition_cols: List[Tuple[str, str]] = [],
file_extension: str = ".parquet",
schema: Optional[pa.Schema] = None,
file_sort_order: Optional[List[List[SortExpr]]] = None,
): ...
def sql(self, query: str) -> DataFrame: ...
def sql_with_options(
self, query: str, options: Optional[SQLOptions] = None
) -> DataFrame: ...
def create_dataframe(
self,
partitions: List[List[pa.RecordBatch]],
name: Optional[str] = None,
schema: Optional[pa.Schema] = None,
) -> DataFrame: ...
def create_dataframe_from_logical_plan(self, plan: LogicalPlan) -> DataFrame: ...
def from_pylist(self, data: list, name: Optional[str] = None) -> DataFrame: ...
def from_pydict(self, data: dict, name: Optional[str] = None) -> DataFrame: ...
def from_arrow(
self,
data: ArrowStreamExportable | pa.RecordBatchReader,
name: Optional[str] = None,
) -> DataFrame: ...
def from_pandas(
self, data: pd.DataFrame, name: Optional[str] = None
) -> DataFrame: ...
def from_polars(
self, data: pl.DataFrame, name: Optional[str] = None
) -> DataFrame: ...
def register_table(self, data: str, table: Table): ...
def deregister_table(self, name: str): ...
def register_table_provider(self, name: str, provider: TableProviderExportable): ...
def register_record_batches(
self, name: str, partitions: List[List[pa.RecordBatch]]
): ...
def register_parquet(
self,
name: str,
path: str,
table_partition_cols: List[Tuple[str, str]] = [],
parquet_pruning: bool = True,
file_extension: str = ".parquet",
skip_metadata: bool = True,
schema: Optional[pa.Schema] = None,
file_sort_order: Optional[List[List[SortExpr]]] = None,
**kwargs,
): ...
def register_csv(
self,
name: str,
path: str | List[str],
schema: Optional[pa.Schema] = None,
has_header: bool = True,
delimiter: str = ",",
schema_infer_max_records: int = 1000,
file_extension: str = ".csv",
file_compression_type: Optional[str] = None,
**kwargs,
): ...
def register_json(
self,
name: str,
path: str | Path,
schema: Optional[pa.Schema] = None,
schema_infer_max_records: int = 1000,
file_extension: str = ".json",
table_partition_cols: List[Tuple[str, str]] = [],
file_compression_type: Optional[str] = None,
**kwargs,
): ...
def register_avro(
self,
name: str,
path: str | Path,
schema: Optional[pa.Schema] = None,
file_extension: str = ".avro",
table_partition_cols: List[Tuple[str, str]] = [],
): ...
def register_dataset(self, name: str, dataset: Dataset): ...
def register_udf(self, udf: ScalarUDF): ...
def register_udaf(self, udaf: AggregateUDF): ...
def register_udwf(self, udwf: WindowUDF): ...
def catalog(self, name: str = "datafusion") -> Catalog: ...
def tables(self) -> Set[str]: ...
def table(self, name: str) -> DataFrame: ...
def table_exist(self, name: str) -> bool: ...
def empty_table(self) -> DataFrame: ...
def session_id(self) -> str: ...
def read_json(
self,
path: str | List[str],
schema: Optional[pa.Schema] = None,
schema_infer_max_records: int = 1000,
file_extension: str = ".json",
table_partition_cols: List[Tuple[str, str]] = [],
file_compression_type: Optional[str] = None,
**kwargs,
): ...
def read_csv(
self,
path: str | List[str],
schema: Optional[pa.Schema] = None,
head_header: bool = True,
delimiter: str = ",",
schema_infer_max_records: int = 1000,
file_extension: str = ".csv",
table_partition_cols: List[Tuple[str, str]] = [],
file_compression_type: Optional[str] = None,
**kwargs,
): ...
def read_parquet(
self,
path: str | List[str],
table_partition_cols: List[Tuple[str, str]] = [],
parquet_pruning: bool = True,
file_extension: str = ".parquet",
skip_metadata: bool = True,
schema: Optional[pa.Schema] = None,
file_sort_order: Optional[List[List[SortExpr]]] = None,
**kwargs,
): ...
def read_avro(
self,
path: str,
schema: Optional[pa.Schema] = None,
table_partition_cols: List[Tuple[str, str]] = [],
file_extension: str = ".avro",
**kwargs,
): ...
def read_table(self, table: Table) -> DataFrame: ...
def execute(self, plan: ExecutionPlan, part: int) -> RecordBatchStream: ...
class DataFrame:
def __getitem__(self, key: str | List[str] | Tuple[str, ...]) -> DataFrame: ...
def _repr_html_(self) -> str: ...
def describe(self) -> DataFrame: ...
def schema(self) -> pa.Schema: ...
def select_columns(self, *args: str) -> DataFrame: ...
def select(self, *args: Expr) -> DataFrame: ...
def drop(self, *args: str) -> DataFrame: ...
def filter(self, predicate: Expr) -> DataFrame: ...
def with_column(self, name: str, expr: Expr) -> DataFrame: ...
def with_columns(self, exprs: List[Expr]) -> DataFrame: ...
def with_column_renamed(self, old_name: str, new_name: str) -> DataFrame: ...
def aggregate(self, group_by: List[Expr], aggs: List[Expr]) -> DataFrame: ...
def sort(self, *exprs: SortExpr) -> DataFrame: ...
def limit(self, count: int, offset: int) -> DataFrame: ...
def collect(self) -> List[pa.RecordBatch]: ...
def cache(self) -> DataFrame: ...
def collect_partitioned(self) -> List[List[pa.RecordBatch]]: ...
def show(self, num: int = 20): ...
def distinct(self) -> DataFrame: ...
def join(
self, right: DataFrame, how: str, left_on: List[str], right_on: List[str]
) -> DataFrame: ...
def join_on(
self, right: DataFrame, on_exprs: List[Expr], how: str
) -> DataFrame: ...
def explain(self, verbose: bool = False, analyze: bool = False): ...
def logical_plan(self) -> LogicalPlan: ...
def optimized_logical_plan(self) -> LogicalPlan: ...
def execution_plan(self) -> ExecutionPlan: ...
def repartition(self, num: int) -> DataFrame: ...
def repartition_by_hash(self, *args: Expr, num: int) -> DataFrame: ...
def union(self, py_df: DataFrame, distinct: bool = False) -> DataFrame: ...
def union_distinct(self, py_df: DataFrame) -> DataFrame: ...
def unnest_column(self, column: str, preserve_nulls: bool = True) -> DataFrame: ...
def unnest_columns(
self, columns: List[str], preserve_nulls: bool = True
) -> DataFrame: ...
def intersect(self, py_df: DataFrame) -> DataFrame: ...
def except_all(self, py_df: DataFrame) -> DataFrame: ...
def write_csv(self, path: str, with_header: bool): ...
def write_parquet(
self,
path: str,
compression: str = "uncompressed",
compression_level: Optional[int] = None,
): ...
def write_json(self, path: str): ...
def to_arrow_table(self) -> pa.Table: ...
def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...
def execute_stream(self) -> RecordBatchStream: ...
def execute_stream_partitioned(self) -> List[RecordBatchStream]: ...
def to_pandas(self) -> pd.DataFrame: ...
def to_pylist(self) -> list: ...
def to_pydict(self) -> dict: ...
def to_polars(self) -> pl.DataFrame: ...
def count(self) -> int: ...
class ScalarUDF:
def __init__(
self,
name: str,
func: Callable[..., pa.DataType],
input_types: List[pa.DataType],
return_type: pa.DataType,
volatility: str,
) -> None: ...
def __call__(self, *args: Expr) -> Expr: ...
class AggregateUDF:
def __init__(
self,
name: str,
accumulator: Callable[[], Accumulator],
input_types: List[pa.DataType],
return_type: pa.DataType,
state_type: List[pa.DataType],
volatility: str,
) -> None: ...
def __call__(self, *args: Expr) -> Expr: ...
class WindowUDF:
def __init__(
self,
name: str,
evaluator: Callable[[], WindowEvaluator],
input_types: List[pa.DataType],
return_type: pa.DataType,
volatility: str,
) -> None: ...
def __call__(self, *args: Expr) -> Expr: ...
class Config:
def __init__(self) -> None: ...
@staticmethod
def from_env() -> Config: ...
def get(self, key: str) -> Optional[str]: ...
def set(self, key: str, value: object): ...
def get_all(self) -> Dict[str, Optional[str]]: ...
class LogicalPlan:
def to_variant(self) -> Any: ...
def inputs(self) -> List[LogicalPlan]: ...
def display(self) -> str: ...
def display_indent(self) -> str: ...
def display_indent_schema(self) -> str: ...
def display_graphviz(self) -> str: ...
def to_proto(self) -> bytes: ...
@staticmethod
def from_proto(ctx: SessionContext, proto_msg: bytes) -> LogicalPlan: ...
class ExecutionPlan:
def children(self) -> List[ExecutionPlan]: ...
def display(self) -> str: ...
def display_indent(self) -> str: ...
def to_proto(self) -> bytes: ...
@staticmethod
def from_proto(ctx: SessionContext, proto_msg: bytes) -> ExecutionPlan: ...
@property
def partition_count(self) -> int: ...
class RecordBatch:
def to_pyarrow(self) -> pa.RecordBatch: ...
class RecordBatchStream:
def next(self) -> RecordBatch: ...
def __next__(self) -> RecordBatch: ...
async def __anext__(self) -> RecordBatch: ...
def __iter__(self) -> RecordBatch: ...
async def __aiter__(self) -> RecordBatch: ...