vortex-data 0.86.1__cp311-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vortex/__init__.py +231 -0
- vortex/_lib/__init__.pyi +61 -0
- vortex/_lib/arrays.pyi +142 -0
- vortex/_lib/cli.pyi +4 -0
- vortex/_lib/compress.pyi +6 -0
- vortex/_lib/dataset.pyi +34 -0
- vortex/_lib/dtype.pyi +80 -0
- vortex/_lib/expr.pyi +122 -0
- vortex/_lib/file.pyi +66 -0
- vortex/_lib/io.pyi +36 -0
- vortex/_lib/iter.pyi +21 -0
- vortex/_lib/registry.pyi +6 -0
- vortex/_lib/runtime.pyi +5 -0
- vortex/_lib/scalar.pyi +55 -0
- vortex/_lib/scan.pyi +18 -0
- vortex/_lib/serde.pyi +39 -0
- vortex/_lib/store/LICENSE +21 -0
- vortex/_lib/store/__init__.pyi +211 -0
- vortex/_lib/store/_aws.pyi +550 -0
- vortex/_lib/store/_azure.pyi +418 -0
- vortex/_lib/store/_client.pyi +90 -0
- vortex/_lib/store/_gcs.pyi +225 -0
- vortex/_lib/store/_http.pyi +61 -0
- vortex/_lib/store/_retry.pyi +100 -0
- vortex/_lib.pyd +4 -0
- vortex/arrays.py +485 -0
- vortex/arrow/__init__.py +2 -0
- vortex/arrow/expression.py +56 -0
- vortex/cli.py +10 -0
- vortex/dataset.py +948 -0
- vortex/datasets.py +956 -0
- vortex/expr.py +95 -0
- vortex/file.py +269 -0
- vortex/io.py +6 -0
- vortex/polars_.py +166 -0
- vortex/py.typed +0 -0
- vortex/ray/__init__.py +2 -0
- vortex/ray/datasource.py +152 -0
- vortex/registry.py +8 -0
- vortex/scan.py +98 -0
- vortex/serde.py +11 -0
- vortex/store/LICENSE +21 -0
- vortex/store/__init__.py +180 -0
- vortex/store/_aws.py +563 -0
- vortex/store/_azure.py +408 -0
- vortex/store/_client.py +81 -0
- vortex/store/_cos.py +13 -0
- vortex/store/_gcs.py +240 -0
- vortex/store/_goosefs.py +13 -0
- vortex/store/_hf.py +16 -0
- vortex/store/_http.py +82 -0
- vortex/store/_local.py +84 -0
- vortex/store/_memory.py +18 -0
- vortex/store/_retry.py +79 -0
- vortex/substrait.py +621 -0
- vortex/type_aliases.py +22 -0
- vortex_data-0.86.1.dist-info/METADATA +294 -0
- vortex_data-0.86.1.dist-info/RECORD +61 -0
- vortex_data-0.86.1.dist-info/WHEEL +4 -0
- vortex_data-0.86.1.dist-info/entry_points.txt +2 -0
- vortex_data-0.86.1.dist-info/sboms/vortex-python.cyclonedx.json +23474 -0
vortex/__init__.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
import importlib
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
import importlib.util
|
|
7
|
+
from types import ModuleType
|
|
8
|
+
|
|
9
|
+
from . import _lib, arrays, dataset, expr, file, io, ray, registry, scan
|
|
10
|
+
from ._lib.arrays import (
|
|
11
|
+
AlpArray,
|
|
12
|
+
AlpRdArray,
|
|
13
|
+
BoolArray,
|
|
14
|
+
ByteBoolArray,
|
|
15
|
+
ChunkedArray,
|
|
16
|
+
ConstantArray,
|
|
17
|
+
DateTimePartsArray,
|
|
18
|
+
# DecimalArray # TODO(connor): Is this missing a `DecimalArray`?
|
|
19
|
+
DictArray,
|
|
20
|
+
ExtensionArray,
|
|
21
|
+
FastLanesBitPackedArray,
|
|
22
|
+
FastLanesDeltaArray,
|
|
23
|
+
FastLanesFoRArray,
|
|
24
|
+
FixedSizeListArray,
|
|
25
|
+
FsstArray,
|
|
26
|
+
ListArray,
|
|
27
|
+
NullArray,
|
|
28
|
+
PrimitiveArray,
|
|
29
|
+
RunEndArray,
|
|
30
|
+
SequenceArray,
|
|
31
|
+
SparseArray,
|
|
32
|
+
StructArray,
|
|
33
|
+
VarBinArray,
|
|
34
|
+
VarBinViewArray,
|
|
35
|
+
ZigZagArray,
|
|
36
|
+
)
|
|
37
|
+
from ._lib.compress import compress
|
|
38
|
+
from ._lib.dtype import (
|
|
39
|
+
BinaryDType,
|
|
40
|
+
BoolDType,
|
|
41
|
+
DecimalDType,
|
|
42
|
+
DType,
|
|
43
|
+
ExtensionDType,
|
|
44
|
+
FixedSizeListDType,
|
|
45
|
+
ListDType,
|
|
46
|
+
NullDType,
|
|
47
|
+
PrimitiveDType,
|
|
48
|
+
PType,
|
|
49
|
+
StructDType,
|
|
50
|
+
Utf8DType,
|
|
51
|
+
binary,
|
|
52
|
+
bool_,
|
|
53
|
+
date,
|
|
54
|
+
decimal,
|
|
55
|
+
fixed_size_list,
|
|
56
|
+
float_,
|
|
57
|
+
int_,
|
|
58
|
+
list_,
|
|
59
|
+
null,
|
|
60
|
+
struct,
|
|
61
|
+
time,
|
|
62
|
+
timestamp,
|
|
63
|
+
uint,
|
|
64
|
+
utf8,
|
|
65
|
+
)
|
|
66
|
+
from ._lib.iter import ArrayIterator
|
|
67
|
+
from ._lib.runtime import (
|
|
68
|
+
set_worker_threads,
|
|
69
|
+
worker_threads,
|
|
70
|
+
)
|
|
71
|
+
from ._lib.scalar import (
|
|
72
|
+
BinaryScalar,
|
|
73
|
+
BoolScalar,
|
|
74
|
+
# TODO(connor): Is this missing a `DecimalScalar`?
|
|
75
|
+
ExtensionScalar,
|
|
76
|
+
ListScalar,
|
|
77
|
+
NullScalar,
|
|
78
|
+
PrimitiveScalar,
|
|
79
|
+
Scalar,
|
|
80
|
+
StructScalar,
|
|
81
|
+
Utf8Scalar,
|
|
82
|
+
scalar,
|
|
83
|
+
)
|
|
84
|
+
from ._lib.serde import ArrayContext, SerializedArray
|
|
85
|
+
from .arrays import (
|
|
86
|
+
Array,
|
|
87
|
+
PyArray,
|
|
88
|
+
_unpickle_array,
|
|
89
|
+
array,
|
|
90
|
+
)
|
|
91
|
+
from .file import VortexFile, open
|
|
92
|
+
from .scan import RepeatedScan
|
|
93
|
+
|
|
94
|
+
_ = _lib # Ensure we eagerly import the Vortex native library.
|
|
95
|
+
|
|
96
|
+
# Resolve the installed distribution version so it is available as vortex.__version__.
|
|
97
|
+
|
|
98
|
+
__version__ = "unknown"
|
|
99
|
+
try:
|
|
100
|
+
# Try to read the installed distribution version for the Python package name.
|
|
101
|
+
__version__ = importlib.metadata.version("vortex-data")
|
|
102
|
+
except importlib.metadata.PackageNotFoundError:
|
|
103
|
+
# If the distribution is not installed, keep the unknown fallback.
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def cuda_extension_installed() -> bool:
|
|
108
|
+
"""Return whether the optional Vortex CUDA extension package is importable.
|
|
109
|
+
|
|
110
|
+
The base ``vortex-data`` wheel is CPU-only. Optional CUDA functionality is
|
|
111
|
+
provided by the separate ``vortex-data-cuda`` extension package. This returns
|
|
112
|
+
``True`` when the ``vortex_cuda`` import package can be found in the current
|
|
113
|
+
environment, which is what ``vortex-data[cuda]`` installs.
|
|
114
|
+
|
|
115
|
+
This does not probe the CUDA driver or attached devices, and it does not
|
|
116
|
+
imply that any particular GPU interop API is available. After installing the
|
|
117
|
+
extension package, use ``vortex_cuda.cuda_available()`` to check whether CUDA
|
|
118
|
+
is usable at runtime.
|
|
119
|
+
"""
|
|
120
|
+
return importlib.util.find_spec("vortex_cuda") is not None
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def __getattr__(name: str) -> ModuleType:
|
|
124
|
+
# `datasets` is exposed lazily and deliberately kept out of __all__: importing it pulls in the
|
|
125
|
+
# optional `vortex-data[hf]` dependencies, so it must not be imported by `from vortex import *`
|
|
126
|
+
# or by merely importing `vortex`.
|
|
127
|
+
if name == "datasets":
|
|
128
|
+
module = importlib.import_module(".datasets", __name__)
|
|
129
|
+
globals()[name] = module
|
|
130
|
+
return module
|
|
131
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
__all__ = [
|
|
135
|
+
# --- Modules ---
|
|
136
|
+
"arrays",
|
|
137
|
+
"dataset",
|
|
138
|
+
"expr",
|
|
139
|
+
"file",
|
|
140
|
+
"scan",
|
|
141
|
+
"io",
|
|
142
|
+
"registry",
|
|
143
|
+
"ray",
|
|
144
|
+
# --- Objects and Functions ---
|
|
145
|
+
"array",
|
|
146
|
+
"compress",
|
|
147
|
+
"cuda_extension_installed",
|
|
148
|
+
# Arrays
|
|
149
|
+
"Array",
|
|
150
|
+
"PyArray",
|
|
151
|
+
# DTypes
|
|
152
|
+
"DType",
|
|
153
|
+
"PType",
|
|
154
|
+
"NullDType",
|
|
155
|
+
"BoolDType",
|
|
156
|
+
"DecimalDType",
|
|
157
|
+
"PrimitiveDType",
|
|
158
|
+
"Utf8DType",
|
|
159
|
+
"BinaryDType",
|
|
160
|
+
"StructDType",
|
|
161
|
+
"ListDType",
|
|
162
|
+
"FixedSizeListDType",
|
|
163
|
+
"ExtensionDType",
|
|
164
|
+
"null",
|
|
165
|
+
"bool_",
|
|
166
|
+
"decimal",
|
|
167
|
+
"int_",
|
|
168
|
+
"uint",
|
|
169
|
+
"float_",
|
|
170
|
+
"utf8",
|
|
171
|
+
"binary",
|
|
172
|
+
"struct",
|
|
173
|
+
"list_",
|
|
174
|
+
"fixed_size_list",
|
|
175
|
+
"date",
|
|
176
|
+
"time",
|
|
177
|
+
"timestamp",
|
|
178
|
+
# Encodings
|
|
179
|
+
"ConstantArray",
|
|
180
|
+
"ChunkedArray",
|
|
181
|
+
"NullArray",
|
|
182
|
+
"BoolArray",
|
|
183
|
+
"ByteBoolArray",
|
|
184
|
+
"PrimitiveArray",
|
|
185
|
+
"VarBinArray",
|
|
186
|
+
"VarBinViewArray",
|
|
187
|
+
"StructArray",
|
|
188
|
+
"ListArray",
|
|
189
|
+
"FixedSizeListArray",
|
|
190
|
+
"ExtensionArray",
|
|
191
|
+
"AlpArray",
|
|
192
|
+
"AlpRdArray",
|
|
193
|
+
"DateTimePartsArray",
|
|
194
|
+
"DictArray",
|
|
195
|
+
"FsstArray",
|
|
196
|
+
"RunEndArray",
|
|
197
|
+
"SequenceArray",
|
|
198
|
+
"SparseArray",
|
|
199
|
+
"ZigZagArray",
|
|
200
|
+
"FastLanesBitPackedArray",
|
|
201
|
+
"FastLanesDeltaArray",
|
|
202
|
+
"FastLanesFoRArray",
|
|
203
|
+
# Scalars
|
|
204
|
+
"scalar",
|
|
205
|
+
"Scalar",
|
|
206
|
+
"NullScalar",
|
|
207
|
+
"BoolScalar",
|
|
208
|
+
"PrimitiveScalar",
|
|
209
|
+
"Utf8Scalar",
|
|
210
|
+
"BinaryScalar",
|
|
211
|
+
"StructScalar",
|
|
212
|
+
"ListScalar",
|
|
213
|
+
"ExtensionScalar",
|
|
214
|
+
# Serde
|
|
215
|
+
"ArrayContext",
|
|
216
|
+
"SerializedArray",
|
|
217
|
+
# Pickle support
|
|
218
|
+
"_unpickle_array",
|
|
219
|
+
# File
|
|
220
|
+
"VortexFile",
|
|
221
|
+
"open",
|
|
222
|
+
# Iterator
|
|
223
|
+
"ArrayIterator",
|
|
224
|
+
# Scan
|
|
225
|
+
"RepeatedScan",
|
|
226
|
+
# Runtime
|
|
227
|
+
"set_worker_threads",
|
|
228
|
+
"worker_threads",
|
|
229
|
+
# Version
|
|
230
|
+
"__version__",
|
|
231
|
+
]
|
vortex/_lib/__init__.pyi
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
class CosStore:
|
|
5
|
+
"""A Tencent Cloud COS object store, backed by OpenDAL.
|
|
6
|
+
|
|
7
|
+
Construct it with explicit configuration and pass it to
|
|
8
|
+
``vortex.io.read_url(url, store=cos_store)`` /
|
|
9
|
+
``vortex.io.write(arrays, path, store=cos_store)``.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
bucket: str,
|
|
15
|
+
endpoint: str,
|
|
16
|
+
*,
|
|
17
|
+
secret_id: str | None = None,
|
|
18
|
+
secret_key: str | None = None,
|
|
19
|
+
root: str | None = None,
|
|
20
|
+
disable_config_load: bool = False,
|
|
21
|
+
) -> None: ...
|
|
22
|
+
|
|
23
|
+
class GoosefsStore:
|
|
24
|
+
"""A Tencent Cloud GooseFS object store, backed by OpenDAL.
|
|
25
|
+
|
|
26
|
+
Construct it with explicit configuration and pass it to
|
|
27
|
+
``vortex.io.read_url(url, store=goosefs_store)`` /
|
|
28
|
+
``vortex.io.write(arrays, path, store=goosefs_store)``.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
master_addr: str,
|
|
34
|
+
*,
|
|
35
|
+
root: str | None = None,
|
|
36
|
+
block_size: int | None = None,
|
|
37
|
+
chunk_size: int | None = None,
|
|
38
|
+
write_type: str | None = None,
|
|
39
|
+
auth_type: str | None = None,
|
|
40
|
+
auth_username: str | None = None,
|
|
41
|
+
) -> None: ...
|
|
42
|
+
|
|
43
|
+
class HfStore:
|
|
44
|
+
"""A Hugging Face Hub object store, rooted at one repository and revision.
|
|
45
|
+
|
|
46
|
+
Reading an ``hf://`` URL needs no store; this covers a token held in a variable
|
|
47
|
+
rather than the environment, and reads that must stay anonymous regardless of it.
|
|
48
|
+
|
|
49
|
+
Construct it and pass it to ``vortex.io.read_url(path, store=hf_store)``, where
|
|
50
|
+
``path`` is a path within the repository.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
repo_id: str,
|
|
56
|
+
*,
|
|
57
|
+
repo_type: str = "dataset",
|
|
58
|
+
revision: str | None = None,
|
|
59
|
+
token: bool | str | None = None,
|
|
60
|
+
endpoint: str | None = None,
|
|
61
|
+
) -> None: ...
|
vortex/_lib/arrays.pyi
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
from typing import final
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import polars as pl
|
|
9
|
+
import pyarrow as pa
|
|
10
|
+
|
|
11
|
+
from .dtype import DType, PType
|
|
12
|
+
from .expr import Expr
|
|
13
|
+
from .scalar import Scalar, ScalarPyType
|
|
14
|
+
from .serde import ArrayContext
|
|
15
|
+
|
|
16
|
+
class Array:
|
|
17
|
+
def __lt__(self, other: Array) -> Array: ...
|
|
18
|
+
def __le__(self, other: Array) -> Array: ...
|
|
19
|
+
def __gt__(self, other: Array) -> Array: ...
|
|
20
|
+
def __ge__(self, other: Array) -> Array: ...
|
|
21
|
+
def __len__(self) -> int: ...
|
|
22
|
+
@staticmethod
|
|
23
|
+
def from_arrow(
|
|
24
|
+
obj: pa.Array[pa.Scalar[pa.DataType]] | pa.ChunkedArray[pa.Scalar[pa.DataType]] | pa.Table,
|
|
25
|
+
) -> Array: ...
|
|
26
|
+
@staticmethod
|
|
27
|
+
def from_range(obj: range, *, dtype: DType | None = None) -> Array: ...
|
|
28
|
+
def to_arrow_array(self, *, arrow_type: pa.DataType | None = None) -> pa.Array[pa.Scalar[pa.DataType]]: ...
|
|
29
|
+
def __vortex_array_metadata__(self) -> tuple[str, bytes, int, bytes, list[object], list[object]]: ...
|
|
30
|
+
@property
|
|
31
|
+
def id(self) -> str: ...
|
|
32
|
+
@property
|
|
33
|
+
def nbytes(self) -> int: ...
|
|
34
|
+
@property
|
|
35
|
+
def dtype(self) -> DType: ...
|
|
36
|
+
def filter(self, mask: Array) -> Array: ...
|
|
37
|
+
def scalar_at(self, index: int) -> Scalar: ...
|
|
38
|
+
def take(self, indices: Array) -> Array: ...
|
|
39
|
+
def slice(self, start: int, end: int) -> Array: ...
|
|
40
|
+
def display_tree(self) -> str: ...
|
|
41
|
+
def to_arrow_table(self) -> pa.Table: ...
|
|
42
|
+
def to_numpy(self, *, zero_copy_only: bool = True) -> np.ndarray: ...
|
|
43
|
+
def to_pandas(self) -> pd.DataFrame: ...
|
|
44
|
+
def to_polars_dataframe(self) -> pl.DataFrame: ...
|
|
45
|
+
def to_polars_series(self) -> pl.Series: ...
|
|
46
|
+
def to_pylist(self) -> list[ScalarPyType]: ...
|
|
47
|
+
def serialize(self, ctx: ArrayContext) -> bytes: ...
|
|
48
|
+
def apply(self, expr: Expr) -> Array: ...
|
|
49
|
+
|
|
50
|
+
class NativeArray(Array): ...
|
|
51
|
+
|
|
52
|
+
class PythonArray(Array):
|
|
53
|
+
def __init__(self, len: int, dtype: DType) -> None: ...
|
|
54
|
+
|
|
55
|
+
@final
|
|
56
|
+
class NullArray(Array): ...
|
|
57
|
+
|
|
58
|
+
@final
|
|
59
|
+
class BoolArray(Array): ...
|
|
60
|
+
|
|
61
|
+
@final
|
|
62
|
+
class PrimitiveArray(Array):
|
|
63
|
+
@property
|
|
64
|
+
def ptype(self) -> PType: ...
|
|
65
|
+
|
|
66
|
+
@final
|
|
67
|
+
class DecimalArray(Array):
|
|
68
|
+
@property
|
|
69
|
+
def precision(self) -> int: ...
|
|
70
|
+
@property
|
|
71
|
+
def scale(self) -> int: ...
|
|
72
|
+
|
|
73
|
+
@final
|
|
74
|
+
class VarBinArray(Array): ...
|
|
75
|
+
|
|
76
|
+
@final
|
|
77
|
+
class VarBinViewArray(Array): ...
|
|
78
|
+
|
|
79
|
+
@final
|
|
80
|
+
class StructArray(Array):
|
|
81
|
+
def field(self, name: str) -> Array: ...
|
|
82
|
+
def names(self) -> list[str]: ...
|
|
83
|
+
|
|
84
|
+
@final
|
|
85
|
+
class ListArray(Array): ...
|
|
86
|
+
|
|
87
|
+
@final
|
|
88
|
+
class FixedSizeListArray(Array): ...
|
|
89
|
+
|
|
90
|
+
@final
|
|
91
|
+
class ExtensionArray(Array): ...
|
|
92
|
+
|
|
93
|
+
@final
|
|
94
|
+
class ConstantArray(Array):
|
|
95
|
+
def scalar(self) -> Scalar: ...
|
|
96
|
+
|
|
97
|
+
@final
|
|
98
|
+
class ChunkedArray(Array):
|
|
99
|
+
def chunks(self) -> list[Array]: ...
|
|
100
|
+
|
|
101
|
+
@final
|
|
102
|
+
class ByteBoolArray(Array): ...
|
|
103
|
+
|
|
104
|
+
@final
|
|
105
|
+
class SequenceArray(Array): ...
|
|
106
|
+
|
|
107
|
+
@final
|
|
108
|
+
class SparseArray(Array): ...
|
|
109
|
+
|
|
110
|
+
@final
|
|
111
|
+
class AlpArray(Array): ...
|
|
112
|
+
|
|
113
|
+
@final
|
|
114
|
+
class AlpRdArray(Array): ...
|
|
115
|
+
|
|
116
|
+
@final
|
|
117
|
+
class DateTimePartsArray(Array): ...
|
|
118
|
+
|
|
119
|
+
@final
|
|
120
|
+
class DictArray(Array): ...
|
|
121
|
+
|
|
122
|
+
@final
|
|
123
|
+
class FsstArray(Array): ...
|
|
124
|
+
|
|
125
|
+
@final
|
|
126
|
+
class RunEndArray(Array): ...
|
|
127
|
+
|
|
128
|
+
@final
|
|
129
|
+
class ZigZagArray(Array):
|
|
130
|
+
@staticmethod
|
|
131
|
+
def encode(array: Array) -> Array: ...
|
|
132
|
+
|
|
133
|
+
@final
|
|
134
|
+
class FastLanesBitPackedArray(Array):
|
|
135
|
+
@property
|
|
136
|
+
def bit_width(self) -> int: ...
|
|
137
|
+
|
|
138
|
+
@final
|
|
139
|
+
class FastLanesDeltaArray(Array): ...
|
|
140
|
+
|
|
141
|
+
@final
|
|
142
|
+
class FastLanesFoRArray(Array): ...
|
vortex/_lib/cli.pyi
ADDED
vortex/_lib/compress.pyi
ADDED
vortex/_lib/dataset.pyi
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
import pyarrow
|
|
5
|
+
|
|
6
|
+
from .arrays import Array
|
|
7
|
+
from .expr import Expr
|
|
8
|
+
|
|
9
|
+
class VortexDataset:
|
|
10
|
+
def to_array(
|
|
11
|
+
self,
|
|
12
|
+
columns: list[str] | list[int] | None = None,
|
|
13
|
+
row_filter: Expr | None = None,
|
|
14
|
+
indices: Array | None = None,
|
|
15
|
+
row_range: tuple[int, int] | None = None,
|
|
16
|
+
) -> Array: ...
|
|
17
|
+
def to_record_batch_reader(
|
|
18
|
+
self,
|
|
19
|
+
columns: list[str] | list[int] | None = None,
|
|
20
|
+
row_filter: Expr | None = None,
|
|
21
|
+
indices: Array | None = None,
|
|
22
|
+
split_by: int | None = None,
|
|
23
|
+
row_range: tuple[int, int] | None = None,
|
|
24
|
+
) -> pyarrow.RecordBatchReader: ...
|
|
25
|
+
def count_rows(
|
|
26
|
+
self,
|
|
27
|
+
row_filter: Expr | None = None,
|
|
28
|
+
split_by: int | None = None,
|
|
29
|
+
row_range: tuple[int, int] | None = None,
|
|
30
|
+
) -> int: ...
|
|
31
|
+
def schema(self) -> pyarrow.Schema: ...
|
|
32
|
+
def splits(self) -> list[tuple[int, int]]: ...
|
|
33
|
+
|
|
34
|
+
def dataset_from_url(url: str) -> VortexDataset: ...
|
vortex/_lib/dtype.pyi
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
from typing import Literal, final
|
|
5
|
+
|
|
6
|
+
import pyarrow as pa
|
|
7
|
+
|
|
8
|
+
class DType:
|
|
9
|
+
def is_nullable(self) -> bool: ...
|
|
10
|
+
def to_arrow_schema(self) -> pa.Schema: ...
|
|
11
|
+
def to_arrow_type(self) -> pa.DataType: ...
|
|
12
|
+
@classmethod
|
|
13
|
+
def from_arrow(cls, arrow_dtype: pa.DataType | pa.Schema, *, non_nullable: bool = False) -> DType: ...
|
|
14
|
+
|
|
15
|
+
@final
|
|
16
|
+
class NullDType(DType): ...
|
|
17
|
+
|
|
18
|
+
@final
|
|
19
|
+
class BoolDType(DType): ...
|
|
20
|
+
|
|
21
|
+
@final
|
|
22
|
+
class PrimitiveDType(DType):
|
|
23
|
+
@property
|
|
24
|
+
def ptype(self) -> PType: ...
|
|
25
|
+
|
|
26
|
+
@final
|
|
27
|
+
class DecimalDType(DType):
|
|
28
|
+
@property
|
|
29
|
+
def precision(self) -> int: ...
|
|
30
|
+
@property
|
|
31
|
+
def scale(self) -> int: ...
|
|
32
|
+
|
|
33
|
+
@final
|
|
34
|
+
class Utf8DType(DType): ...
|
|
35
|
+
|
|
36
|
+
@final
|
|
37
|
+
class BinaryDType(DType): ...
|
|
38
|
+
|
|
39
|
+
@final
|
|
40
|
+
class StructDType(DType):
|
|
41
|
+
def names(self) -> list[str]: ...
|
|
42
|
+
def fields(self) -> list[DType]: ...
|
|
43
|
+
|
|
44
|
+
@final
|
|
45
|
+
class ListDType(DType): ...
|
|
46
|
+
|
|
47
|
+
@final
|
|
48
|
+
class FixedSizeListDType(DType): ...
|
|
49
|
+
|
|
50
|
+
@final
|
|
51
|
+
class ExtensionDType(DType): ...
|
|
52
|
+
|
|
53
|
+
@final
|
|
54
|
+
class PType:
|
|
55
|
+
U8: PType
|
|
56
|
+
U16: PType
|
|
57
|
+
U32: PType
|
|
58
|
+
U64: PType
|
|
59
|
+
I8: PType
|
|
60
|
+
I16: PType
|
|
61
|
+
I32: PType
|
|
62
|
+
I64: PType
|
|
63
|
+
F16: PType
|
|
64
|
+
F32: PType
|
|
65
|
+
F64: PType
|
|
66
|
+
|
|
67
|
+
def null() -> DType: ...
|
|
68
|
+
def bool_(*, nullable: bool = False) -> DType: ...
|
|
69
|
+
def int_(width: Literal[8, 16, 32, 64] = 64, *, nullable: bool = False) -> DType: ...
|
|
70
|
+
def uint(width: Literal[8, 16, 32, 64] = 64, *, nullable: bool = False) -> DType: ...
|
|
71
|
+
def float_(width: Literal[16, 32, 64] = 64, *, nullable: bool = False) -> DType: ...
|
|
72
|
+
def decimal(*, precision: int = 10, scale: int = 0, nullable: bool = False) -> DType: ...
|
|
73
|
+
def utf8(*, nullable: bool = False) -> DType: ...
|
|
74
|
+
def binary(*, nullable: bool = False) -> DType: ...
|
|
75
|
+
def struct(fields: dict[str, DType] | None = None, *, nullable: bool = False) -> DType: ...
|
|
76
|
+
def list_(element: DType, *, nullable: bool = False) -> DType: ...
|
|
77
|
+
def fixed_size_list(element: DType, size: int, *, nullable: bool = False) -> DType: ...
|
|
78
|
+
def date(unit: Literal["ms", "days"], *, nullable: bool = False) -> DType: ...
|
|
79
|
+
def time(unit: Literal["s", "ms", "us", "ns"], *, nullable: bool = False) -> DType: ...
|
|
80
|
+
def timestamp(unit: Literal["s", "ms", "us", "ns"], *, tz: str | None = None, nullable: bool = False) -> DType: ...
|
vortex/_lib/expr.pyi
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
|
|
3
|
+
|
|
4
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
5
|
+
from datetime import date, datetime
|
|
6
|
+
from typing import Literal, TypeAlias, final
|
|
7
|
+
|
|
8
|
+
from typing_extensions import override
|
|
9
|
+
|
|
10
|
+
from .dtype import DType
|
|
11
|
+
from .scalar import ScalarPyType
|
|
12
|
+
|
|
13
|
+
IntoExpr: TypeAlias = Expr | bool | int | float | str | bytes | date | datetime | None
|
|
14
|
+
"""A value accepted anywhere an expression is expected. Non-``Expr`` values become literals."""
|
|
15
|
+
|
|
16
|
+
VariantPath: TypeAlias = str | int | Sequence[str | int]
|
|
17
|
+
|
|
18
|
+
@final
|
|
19
|
+
class Expr:
|
|
20
|
+
@override
|
|
21
|
+
def __eq__(self, other: IntoExpr) -> Expr: ... # ty: ignore[invalid-method-override]
|
|
22
|
+
@override
|
|
23
|
+
def __ne__(self, other: IntoExpr) -> Expr: ... # ty: ignore[invalid-method-override]
|
|
24
|
+
def __lt__(self, other: IntoExpr) -> Expr: ...
|
|
25
|
+
def __le__(self, other: IntoExpr) -> Expr: ...
|
|
26
|
+
def __gt__(self, other: IntoExpr) -> Expr: ...
|
|
27
|
+
def __ge__(self, other: IntoExpr) -> Expr: ...
|
|
28
|
+
def __and__(self, other: IntoExpr) -> Expr: ...
|
|
29
|
+
def __rand__(self, other: IntoExpr) -> Expr: ...
|
|
30
|
+
def __or__(self, other: IntoExpr) -> Expr: ...
|
|
31
|
+
def __ror__(self, other: IntoExpr) -> Expr: ...
|
|
32
|
+
def __invert__(self) -> Expr: ...
|
|
33
|
+
def __add__(self, other: IntoExpr) -> Expr: ...
|
|
34
|
+
def __radd__(self, other: IntoExpr) -> Expr: ...
|
|
35
|
+
def __sub__(self, other: IntoExpr) -> Expr: ...
|
|
36
|
+
def __rsub__(self, other: IntoExpr) -> Expr: ...
|
|
37
|
+
def __mul__(self, other: IntoExpr) -> Expr: ...
|
|
38
|
+
def __rmul__(self, other: IntoExpr) -> Expr: ...
|
|
39
|
+
def __truediv__(self, other: IntoExpr) -> Expr: ...
|
|
40
|
+
def __rtruediv__(self, other: IntoExpr) -> Expr: ...
|
|
41
|
+
def __getitem__(self, field: str) -> Expr: ...
|
|
42
|
+
def serialize(self) -> bytes: ...
|
|
43
|
+
@override
|
|
44
|
+
def __reduce__(self) -> tuple[object, tuple[bytes]]: ...
|
|
45
|
+
|
|
46
|
+
# Leaves and scope
|
|
47
|
+
def root() -> Expr: ...
|
|
48
|
+
def column(name: str) -> Expr: ...
|
|
49
|
+
def literal(dtype: DType, value: ScalarPyType) -> Expr: ...
|
|
50
|
+
def get_item(field: str, child: IntoExpr | None = None) -> Expr: ...
|
|
51
|
+
|
|
52
|
+
# Boolean logic
|
|
53
|
+
def not_(child: IntoExpr) -> Expr: ...
|
|
54
|
+
def and_(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
55
|
+
def or_(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
56
|
+
def and_collect(exprs: Iterable[IntoExpr]) -> Expr | None: ...
|
|
57
|
+
def or_collect(exprs: Iterable[IntoExpr]) -> Expr | None: ...
|
|
58
|
+
|
|
59
|
+
# Comparisons and arithmetic
|
|
60
|
+
def eq(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
61
|
+
def not_eq(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
62
|
+
def gt(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
63
|
+
def gt_eq(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
64
|
+
def lt(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
65
|
+
def lt_eq(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
66
|
+
def add(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
67
|
+
def sub(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
68
|
+
def mul(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
69
|
+
def div(left: IntoExpr, right: IntoExpr) -> Expr: ...
|
|
70
|
+
def between(
|
|
71
|
+
child: IntoExpr,
|
|
72
|
+
lower: IntoExpr,
|
|
73
|
+
upper: IntoExpr,
|
|
74
|
+
*,
|
|
75
|
+
lower_strict: bool = False,
|
|
76
|
+
upper_strict: bool = False,
|
|
77
|
+
) -> Expr: ...
|
|
78
|
+
|
|
79
|
+
# Nullability
|
|
80
|
+
def is_null(child: IntoExpr) -> Expr: ...
|
|
81
|
+
def is_not_null(child: IntoExpr) -> Expr: ...
|
|
82
|
+
def fill_null(child: IntoExpr, fill_value: IntoExpr) -> Expr: ...
|
|
83
|
+
|
|
84
|
+
# Strings
|
|
85
|
+
def like(child: IntoExpr, pattern: IntoExpr) -> Expr: ...
|
|
86
|
+
def ilike(child: IntoExpr, pattern: IntoExpr) -> Expr: ...
|
|
87
|
+
def not_like(child: IntoExpr, pattern: IntoExpr) -> Expr: ...
|
|
88
|
+
def not_ilike(child: IntoExpr, pattern: IntoExpr) -> Expr: ...
|
|
89
|
+
def byte_length(child: IntoExpr) -> Expr: ...
|
|
90
|
+
|
|
91
|
+
# Structs
|
|
92
|
+
def select(fields: str | Iterable[str], child: IntoExpr | None = None) -> Expr: ...
|
|
93
|
+
def select_exclude(fields: str | Iterable[str], child: IntoExpr | None = None) -> Expr: ...
|
|
94
|
+
def pack(
|
|
95
|
+
fields: Mapping[str, IntoExpr] | Iterable[tuple[str, IntoExpr]],
|
|
96
|
+
*,
|
|
97
|
+
nullable: bool = False,
|
|
98
|
+
) -> Expr: ...
|
|
99
|
+
def merge(
|
|
100
|
+
exprs: Iterable[IntoExpr],
|
|
101
|
+
*,
|
|
102
|
+
duplicate_handling: Literal["error", "rightmost"] = "error",
|
|
103
|
+
) -> Expr: ...
|
|
104
|
+
|
|
105
|
+
# Lists
|
|
106
|
+
def list_contains(child: IntoExpr, value: IntoExpr) -> Expr: ...
|
|
107
|
+
def list_length(child: IntoExpr) -> Expr: ...
|
|
108
|
+
def list_sum(child: IntoExpr, *, skip_nans: bool = True) -> Expr: ...
|
|
109
|
+
|
|
110
|
+
# Conditionals and misc
|
|
111
|
+
def case_when(
|
|
112
|
+
when_then: Iterable[tuple[IntoExpr, IntoExpr]],
|
|
113
|
+
else_value: IntoExpr | None = None,
|
|
114
|
+
) -> Expr: ...
|
|
115
|
+
def zip_(mask: IntoExpr, if_true: IntoExpr, if_false: IntoExpr) -> Expr: ...
|
|
116
|
+
def mask(child: IntoExpr, mask: IntoExpr) -> Expr: ...
|
|
117
|
+
def cast(child: IntoExpr, dtype: DType) -> Expr: ...
|
|
118
|
+
def ext_storage(child: IntoExpr) -> Expr: ...
|
|
119
|
+
def variant_get(child: IntoExpr, path: VariantPath, dtype: DType | None = None) -> Expr: ...
|
|
120
|
+
|
|
121
|
+
# Serialization
|
|
122
|
+
def deserialize(data: bytes) -> Expr: ...
|