|
19 | 19 |
|
20 | 20 | from __future__ import annotations |
21 | 21 |
|
22 | | -import pathlib |
23 | | - |
24 | | -import pyarrow |
| 22 | +from typing import TYPE_CHECKING |
25 | 23 |
|
26 | 24 | from datafusion.dataframe import DataFrame |
27 | | -from datafusion.expr import Expr |
28 | 25 |
|
29 | 26 | from ._internal import SessionContext as SessionContextInternal |
30 | 27 |
|
| 28 | +if TYPE_CHECKING: |
| 29 | + import pathlib |
| 30 | + |
| 31 | + import pyarrow as pa |
| 32 | + |
| 33 | + from datafusion.expr import Expr |
| 34 | + |
31 | 35 |
|
32 | | -def read_parquet( |
| 36 | +def read_parquet( # noqa: PLR0913 |
33 | 37 | path: str | pathlib.Path, |
| 38 | + *, |
34 | 39 | table_partition_cols: list[tuple[str, str]] | None = None, |
35 | 40 | parquet_pruning: bool = True, |
36 | 41 | file_extension: str = ".parquet", |
37 | 42 | skip_metadata: bool = True, |
38 | | - schema: pyarrow.Schema | None = None, |
| 43 | + schema: pa.Schema | None = None, |
39 | 44 | file_sort_order: list[list[Expr]] | None = None, |
40 | 45 | ) -> DataFrame: |
41 | 46 | """Read a Parquet source into a :py:class:`~datafusion.dataframe.Dataframe`. |
@@ -77,9 +82,10 @@ def read_parquet( |
77 | 82 | ) |
78 | 83 |
|
79 | 84 |
|
80 | | -def read_json( |
| 85 | +def read_json( # noqa: PLR0913 |
81 | 86 | path: str | pathlib.Path, |
82 | | - schema: pyarrow.Schema | None = None, |
| 87 | + *, |
| 88 | + schema: pa.Schema | None = None, |
83 | 89 | schema_infer_max_records: int = 1000, |
84 | 90 | file_extension: str = ".json", |
85 | 91 | table_partition_cols: list[tuple[str, str]] | None = None, |
@@ -118,9 +124,10 @@ def read_json( |
118 | 124 | ) |
119 | 125 |
|
120 | 126 |
|
121 | | -def read_csv( |
| 127 | +def read_csv( # noqa: PLR0913 |
122 | 128 | path: str | pathlib.Path | list[str] | list[pathlib.Path], |
123 | | - schema: pyarrow.Schema | None = None, |
| 129 | + *, |
| 130 | + schema: pa.Schema | None = None, |
124 | 131 | has_header: bool = True, |
125 | 132 | delimiter: str = ",", |
126 | 133 | schema_infer_max_records: int = 1000, |
@@ -173,7 +180,7 @@ def read_csv( |
173 | 180 |
|
174 | 181 | def read_avro( |
175 | 182 | path: str | pathlib.Path, |
176 | | - schema: pyarrow.Schema | None = None, |
| 183 | + schema: pa.Schema | None = None, |
177 | 184 | file_partition_cols: list[tuple[str, str]] | None = None, |
178 | 185 | file_extension: str = ".avro", |
179 | 186 | ) -> DataFrame: |
|
0 commit comments