@@ -153,10 +153,9 @@ def udf(*args: Any, **kwargs: Any): # noqa: D417
153
153
This class can be used both as a **function** and as a **decorator**.
154
154
155
155
Usage:
156
- - **As a function**: Call `udf(func, input_types, return_type, volatility,
157
- name)`.
158
- - **As a decorator**: Use `@udf(input_types, return_type, volatility,
159
- name)`. In this case, do **not** pass `func` explicitly.
156
+ - **As a function**: Call :py:func:`udf(func, input_types, return_type, volatility, name)`.
157
+ - **As a decorator**: Use :py:func:`@udf(input_types, return_type, volatility, name)`.
158
+ In this case, do **not** pass `func` explicitly.
160
159
161
160
Args:
162
161
func (Callable, optional): **Only needed when calling as a function.**
@@ -175,9 +174,8 @@ def udf(*args: Any, **kwargs: Any): # noqa: D417
175
174
A user-defined function that can be used in SQL expressions,
176
175
data aggregation, or window function calls.
177
176
178
- Example:
179
- **Using `udf` as a function:**
180
- ```
177
+ Example: **Using `udf` as a function**::
178
+
181
179
def double_func(x):
182
180
return x * 2
183
181
double_udf = udf(double_func, [pa.int32()], pa.int32(),
@@ -189,8 +187,7 @@ def double_func(x):
189
187
@udf([pa.int32()], pa.int32(), "volatile", "double_it")
190
188
def double_udf(x):
191
189
return x * 2
192
- ```
193
- """
190
+ """ # noqa: E501 W505
194
191
195
192
def _function (
196
193
func : Callable [..., _R ],
@@ -348,20 +345,18 @@ def udaf(*args: Any, **kwargs: Any): # noqa: D417
348
345
data aggregation or window function calls.
349
346
350
347
Usage:
351
- - **As a function**: Call `udaf(accum, input_types, return_type, state_type,
352
- volatility, name)`.
353
- - **As a decorator**: Use `@udaf(input_types, return_type, state_type,
354
- volatility, name)`.
355
- When using `udaf` as a decorator, **do not pass `accum` explicitly**.
348
+ - **As a function**: Call :py:func:`udaf(accum, input_types, return_type, state_type, volatility, name)`.
349
+ - **As a decorator**: Use :py:func:`@udaf(input_types, return_type, state_type, volatility, name)`.
350
+ When using `udaf` as a decorator, **do not pass `accum` explicitly**.
356
351
357
352
**Function example:**
358
353
359
- If your ` :py:class:Accumulator` can be instantiated with no arguments, you
360
- can simply pass it's type as `accum`. If you need to pass additional
361
- arguments to it's constructor, you can define a lambda or a factory method.
362
- During runtime the ` :py:class:Accumulator` will be constructed for every
363
- instance in which this UDAF is used. The following examples are all valid.
364
- ```
354
+ If your :py:class:` Accumulator` can be instantiated with no arguments, you
355
+ can simply pass it's type as `accum`. If you need to pass additional
356
+ arguments to it's constructor, you can define a lambda or a factory method.
357
+ During runtime the :py:class:` Accumulator` will be constructed for every
358
+ instance in which this UDAF is used. The following examples are all valid::
359
+
365
360
import pyarrow as pa
366
361
import pyarrow.compute as pc
367
362
@@ -390,14 +385,12 @@ def sum_bias_10() -> Summarize:
390
385
"immutable")
391
386
udaf3 = udaf(lambda: Summarize(20.0), pa.float64(), pa.float64(),
392
387
[pa.float64()], "immutable")
393
- ```
394
388
395
- **Decorator example:**
396
- ```
389
+ **Decorator example:**::
390
+
397
391
@udaf(pa.float64(), pa.float64(), [pa.float64()], "immutable")
398
392
def udf4() -> Summarize:
399
393
return Summarize(10.0)
400
- ```
401
394
402
395
Args:
403
396
accum: The accumulator python function. **Only needed when calling as a
@@ -411,7 +404,7 @@ def udf4() -> Summarize:
411
404
Returns:
412
405
A user-defined aggregate function, which can be used in either data
413
406
aggregation or window function calls.
414
- """
407
+ """ # noqa: E501 W505
415
408
416
409
def _function (
417
410
accum : Callable [[], Accumulator ],
@@ -691,8 +684,8 @@ def udwf(*args: Any, **kwargs: Any): # noqa: D417
691
684
name)`. When using `udwf` as a decorator, **do not pass `func`
692
685
explicitly**.
693
686
694
- **Function example:**
695
- ```
687
+ **Function example:**::
688
+
696
689
import pyarrow as pa
697
690
698
691
class BiasedNumbers(WindowEvaluator):
@@ -710,14 +703,11 @@ def bias_10() -> BiasedNumbers:
710
703
udwf2 = udwf(bias_10, pa.int64(), pa.int64(), "immutable")
711
704
udwf3 = udwf(lambda: BiasedNumbers(20), pa.int64(), pa.int64(), "immutable")
712
705
713
- ```
706
+ **Decorator example:**::
714
707
715
- **Decorator example:**
716
- ```
717
708
@udwf(pa.int64(), pa.int64(), "immutable")
718
709
def biased_numbers() -> BiasedNumbers:
719
710
return BiasedNumbers(10)
720
- ```
721
711
722
712
Args:
723
713
func: **Only needed when calling as a function. Skip this argument when
0 commit comments