Skip to content

Commit b0a1803

Browse files
committed
Fix ruff errors
1 parent 46097d1 commit b0a1803

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

python/datafusion/udf.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from __future__ import annotations
2121

22-
from ast import Call
2322
import functools
2423
from abc import ABCMeta, abstractmethod
2524
from enum import Enum
@@ -647,15 +646,17 @@ def udwf(
647646
) -> WindowUDF: ...
648647

649648
@staticmethod
650-
def udwf(*args: Any, **kwargs: Any): # noqa: D417
649+
def udwf(*args: Any, **kwargs: Any): # noqa: D417, C901
651650
"""Create a new User-Defined Window Function (UDWF).
652651
653652
This class can be used both as a **function** and as a **decorator**.
654653
655654
Usage:
656-
- **As a function**: Call `udwf(func, input_types, return_type, volatility, name)`.
657-
- **As a decorator**: Use `@udwf(input_types, return_type, volatility, name)`.
658-
When using `udwf` as a decorator, **do not pass `func` explicitly**.
655+
- **As a function**: Call `udwf(func, input_types, return_type, volatility,
656+
name)`.
657+
- **As a decorator**: Use `@udwf(input_types, return_type, volatility,
658+
name)`. When using `udwf` as a decorator, **do not pass `func`
659+
explicitly**.
659660
660661
**Function example:**
661662
```
@@ -665,7 +666,8 @@ class BiasedNumbers(WindowEvaluator):
665666
def __init__(self, start: int = 0) -> None:
666667
self.start = start
667668
668-
def evaluate_all(self, values: list[pa.Array], num_rows: int) -> pa.Array:
669+
def evaluate_all(self, values: list[pa.Array],
670+
num_rows: int) -> pa.Array:
669671
return pa.array([self.start + i for i in range(num_rows)])
670672
671673
def bias_10() -> BiasedNumbers:
@@ -685,8 +687,8 @@ def biased_numbers() -> BiasedNumbers:
685687
```
686688
687689
Args:
688-
func: **Only needed when calling as a function. Skip this argument when using
689-
`udwf` as a decorator.**
690+
func: **Only needed when calling as a function. Skip this argument when
691+
using `udwf` as a decorator.**
690692
input_types: The data types of the arguments.
691693
return_type: The data type of the return value.
692694
volatility: See :py:class:`Volatility` for allowed values.

python/tests/test_udwf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ def test_register_udwf(ctx, count_window_df):
303303

304304
ctx.register_udwf(window_count)
305305
result = ctx.sql(
306-
"SELECT window_count(a) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM test_table"
306+
"""
307+
SELECT window_count(a)
308+
OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
309+
FOLLOWING) FROM test_table
310+
"""
307311
).collect()[0]
308312
assert result.column(0) == pa.array([0, 1, 2])
309313

@@ -487,6 +491,9 @@ def test_udwf_named_function(ctx, count_window_df):
487491

488492
ctx.register_udwf(window_count)
489493
result = ctx.sql(
490-
"SELECT my_custom_counter(a) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM test_table"
494+
"""
495+
SELECT my_custom_counter(a)
496+
OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
497+
FOLLOWING) FROM test_table"""
491498
).collect()[0]
492499
assert result.column(0) == pa.array([0, 1, 2])

0 commit comments

Comments
 (0)