Skip to content

Commit 24a9cb5

Browse files
authored
feat: support pyarrow 19.0 (zen-xu#198)
* build: upgrade pyarrow min version to 19.0 * feat: support pyarrow 19.0 * omit mypy bool8 override error
1 parent 3cafcc7 commit 24a9cb5

File tree

17 files changed

+202
-43
lines changed

17 files changed

+202
-43
lines changed

pixi.lock

Lines changed: 24 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyarrow-stubs/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ from pyarrow.lib import (
8989
Time64Type,
9090
DurationType,
9191
FixedSizeBinaryType,
92+
Decimal32Type,
93+
Decimal64Type,
9294
Decimal128Type,
9395
Decimal256Type,
9496
BaseExtensionType,
@@ -403,6 +405,8 @@ __all__ = [
403405
"Time64Type",
404406
"DurationType",
405407
"FixedSizeBinaryType",
408+
"Decimal32Type",
409+
"Decimal64Type",
406410
"Decimal128Type",
407411
"Decimal256Type",
408412
"BaseExtensionType",

pyarrow-stubs/__lib_pxi/array.pyi

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ from pyarrow._stubs_typing import (
3838
SupportArrowArray,
3939
SupportArrowDeviceArray,
4040
)
41-
from pyarrow.lib import Buffer, MemoryPool, MonthDayNano, Tensor, _Weakrefable
41+
from pyarrow.lib import (
42+
Buffer,
43+
Device,
44+
MemoryManager,
45+
MemoryPool,
46+
MonthDayNano,
47+
Tensor,
48+
_Weakrefable,
49+
)
4250

4351
from . import scalar, types
4452
from .device import DeviceAllocationType
@@ -673,6 +681,14 @@ def nulls(
673681
size: int, types: types.Float64Type, memory_pool: MemoryPool | None = None
674682
) -> DoubleArray: ...
675683
@overload
684+
def nulls(
685+
size: int, types: types.Decimal32Type, memory_pool: MemoryPool | None = None
686+
) -> Decimal128Array: ...
687+
@overload
688+
def nulls(
689+
size: int, types: types.Decimal64Type, memory_pool: MemoryPool | None = None
690+
) -> Decimal128Array: ...
691+
@overload
676692
def nulls(
677693
size: int, types: types.Decimal128Type, memory_pool: MemoryPool | None = None
678694
) -> Decimal128Array: ...
@@ -1165,6 +1181,7 @@ class Array(_PandasConvertible[pd.Series], Generic[_Scalar_CoT]):
11651181
@property
11661182
def offset(self) -> int: ...
11671183
def buffers(self) -> list[Buffer | None]: ...
1184+
def copy_to(self, destination: MemoryManager | Device) -> Self: ...
11681185
def _export_to_c(self, out_ptr: int, out_schema_ptr: int = 0) -> None: ...
11691186
@classmethod
11701187
def _import_from_c(cls, in_ptr: int, type: int | DataType) -> Self: ...
@@ -1214,6 +1231,8 @@ class HalfFloatArray(FloatingPointArray[scalar.HalfFloatScalar]): ...
12141231
class FloatArray(FloatingPointArray[scalar.FloatScalar]): ...
12151232
class DoubleArray(FloatingPointArray[scalar.DoubleScalar]): ...
12161233
class FixedSizeBinaryArray(Array[scalar.FixedSizeBinaryScalar]): ...
1234+
class Decimal32Array(FixedSizeBinaryArray): ...
1235+
class Decimal64Array(FixedSizeBinaryArray): ...
12171236
class Decimal128Array(FixedSizeBinaryArray): ...
12181237
class Decimal256Array(FixedSizeBinaryArray): ...
12191238

@@ -1536,6 +1555,7 @@ class StructArray(Array[scalar.StructScalar]):
15361555
fields: list[Field] | None = None,
15371556
mask=None,
15381557
memory_pool: MemoryPool | None = None,
1558+
type: types.StructType | None = None,
15391559
) -> StructArray: ...
15401560
def sort(self, order: Order = "ascending", by: str | None = None, **kwargs) -> StructArray: ...
15411561

@@ -1587,11 +1607,23 @@ class ExtensionArray(Array[scalar.ExtensionScalar], Generic[_ArrayT]):
15871607
typ: types.BaseExtensionType, storage: _ArrayT
15881608
) -> ExtensionArray[_ArrayT]: ...
15891609

1610+
class JsonArray(ExtensionArray[_ArrayT]): ...
1611+
class UuidArray(ExtensionArray[_ArrayT]): ...
1612+
15901613
class FixedShapeTensorArray(ExtensionArray[_ArrayT]):
15911614
def to_numpy_ndarray(self) -> np.ndarray: ...
15921615
def to_tensor(self) -> Tensor: ...
1593-
@staticmethod
1594-
def from_numpy_ndarray(obj: np.ndarray) -> FixedShapeTensorArray: ...
1616+
@classmethod
1617+
def from_numpy_ndarray(cls, obj: np.ndarray) -> Self: ...
1618+
1619+
class OpaqueArray(ExtensionArray[_ArrayT]): ...
1620+
1621+
class Bool8Array(ExtensionArray):
1622+
def to_numpy(self, zero_copy_only: bool = ..., writable: bool = ...) -> np.ndarray: ...
1623+
@classmethod
1624+
def from_storage(cls, storage: Int8Array) -> Self: ... # type: ignore[override]
1625+
@classmethod
1626+
def from_numpy(cls, obj: np.ndarray) -> Self: ...
15951627

15961628
def concat_arrays(arrays: Iterable[_ArrayT], memory_pool: MemoryPool | None = None) -> _ArrayT: ...
15971629
def _empty_array(type: _DataTypeT) -> Array[scalar.Scalar[_DataTypeT]]: ...

pyarrow-stubs/__lib_pxi/scalar.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class Int64Scalar(Scalar[types.Int64Type]): ...
120120
class HalfFloatScalar(Scalar[types.Float16Type]): ...
121121
class FloatScalar(Scalar[types.Float32Type]): ...
122122
class DoubleScalar(Scalar[types.Float64Type]): ...
123+
class Decimal32Scalar(Scalar[types.Decimal32Type]): ...
124+
class Decimal64Scalar(Scalar[types.Decimal64Type]): ...
123125
class Decimal128Scalar(Scalar[types.Decimal128Type]): ...
124126
class Decimal256Scalar(Scalar[types.Decimal256Type]): ...
125127
class Date32Scalar(Scalar[types.Date32Type]): ...
@@ -352,6 +354,20 @@ def scalar(
352354
memory_pool: MemoryPool | None = None,
353355
) -> ListScalar[types.ListType[types.Float64Type]]: ...
354356
@overload
357+
def scalar(
358+
value: CollectionValue[Decimal],
359+
*,
360+
from_pandas: bool | None = None,
361+
memory_pool: MemoryPool | None = None,
362+
) -> ListScalar[types.ListType[types.Decimal32Type]]: ...
363+
@overload
364+
def scalar(
365+
value: CollectionValue[Decimal],
366+
*,
367+
from_pandas: bool | None = None,
368+
memory_pool: MemoryPool | None = None,
369+
) -> ListScalar[types.ListType[types.Decimal64Type]]: ...
370+
@overload
355371
def scalar(
356372
value: CollectionValue[Decimal],
357373
*,

pyarrow-stubs/__lib_pxi/table.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from pyarrow._stubs_typing import (
4444
)
4545
from pyarrow.compute import Expression
4646
from pyarrow.interchange.dataframe import _PyArrowDataFrame
47-
from pyarrow.lib import Field, MemoryPool, MonthDayNano, Schema
47+
from pyarrow.lib import Device, Field, MemoryManager, MemoryPool, MonthDayNano, Schema
4848

4949
from . import scalar
5050
from .array import Array, StructArray, _CastAs, _PandasConvertible
@@ -145,6 +145,8 @@ class ChunkedArray(_PandasConvertible[pd.Series], Generic[_Scalar_CoT]):
145145
def __arrow_c_stream__(self, requested_schema=None) -> Any: ...
146146
@classmethod
147147
def _import_from_c_capsule(cls, stream) -> Self: ...
148+
@property
149+
def is_cpu(self) -> bool: ...
148150

149151
@overload
150152
def chunked_array(
@@ -507,6 +509,7 @@ class RecordBatch(_Tabular[Array]):
507509
def device_type(self) -> DeviceAllocationType: ...
508510
@property
509511
def is_cpu(self) -> bool: ...
512+
def copy_to(self, destination: MemoryManager | Device) -> Self: ...
510513

511514
def table_to_blocks(options, table: Table, categories, extension_columns): ...
512515

@@ -594,6 +597,8 @@ class Table(_Tabular[ChunkedArray]):
594597
right_by: str | list[str] | None = None,
595598
) -> Self: ...
596599
def __arrow_c_stream__(self, requested_schema=None): ...
600+
@property
601+
def is_cpu(self) -> bool: ...
597602

598603
def record_batch(
599604
data: dict[str, list | Array]
@@ -641,6 +646,10 @@ class TableGroupBy:
641646
@property
642647
def _use_threads(self) -> bool: ...
643648

649+
def concat_batches(
650+
recordbatches: Iterable[RecordBatch], memory_pool: MemoryPool | None = None
651+
) -> RecordBatch: ...
652+
644653
__all__ = [
645654
"ChunkedArray",
646655
"chunked_array",
@@ -652,4 +661,5 @@ __all__ = [
652661
"table",
653662
"concat_tables",
654663
"TableGroupBy",
664+
"concat_batches",
655665
]

0 commit comments

Comments
 (0)