Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ repos:
# pre-commit run --hook-stage manual python-stubs --all-files
# The type checkers run with uvx, in the environment of
# python/requirements-stubs.txt. They don't need PyArrow installed: the
# modules that aren't annotated yet, e.g. pyarrow.compute, are treated as Any
# (see python/pyproject.toml).
# modules that aren't annotated yet, e.g. pyarrow.interchange, are treated
# as Any (see python/pyproject.toml).
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.2
hooks:
Expand Down
1 change: 1 addition & 0 deletions python/pyarrow-stubs-tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ pyarrow\.__lib\.[a-z]+\.__all__

# The __init__ of Cython extension types takes (*args, **kwargs) at runtime.
pyarrow\.__lib\.[a-z]+\.[A-Za-z_]+\.__init__
pyarrow\._compute\.(Expression|Function|FunctionRegistry|Kernel|UdfContext)\.__init__
51 changes: 51 additions & 0 deletions python/pyarrow-stubs-tests/test_acero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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 typing import TYPE_CHECKING

import pytest

import pyarrow as pa

from _check import assert_type, check

# PyArrow can be built without Acero.
pytest.importorskip("pyarrow._acero")

from pyarrow._acero import ( # noqa: E402
AggregateNodeOptions,
Declaration,
TableSourceNodeOptions,
)


def test_declaration() -> None:
table = pa.table({"a": [1, 2]})
decl = Declaration("table_source", TableSourceNodeOptions(table))
check(assert_type(decl, Declaration), Declaration)
check(assert_type(decl.to_table(), pa.Table), pa.Table)

if TYPE_CHECKING:
TableSourceNodeOptions(table.to_batches()[0]) # type: ignore[arg-type]


def test_aggregate() -> None:
aggr_opts = AggregateNodeOptions([(["a"], "sum", None, "a_sum")])
check(assert_type(aggr_opts, AggregateNodeOptions), AggregateNodeOptions)

aggr_opts = AggregateNodeOptions([(("a", ), "sum", None, "a_sum")])
check(assert_type(aggr_opts, AggregateNodeOptions), AggregateNodeOptions)
Loading
Loading