Skip to content

Commit 8e1d5eb

Browse files
committed
This is a breaking change to move the module datafusion.udf to datafusion.user_defined
1 parent c9f1554 commit 8e1d5eb

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

docs/source/user-guide/common-operations/udf-and-udfa.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Scalar Functions
2626

2727
When writing a user-defined function that can operate on a row by row basis, these are called Scalar
2828
Functions. You can define your own scalar function by calling
29-
:py:func:`~datafusion.udf.ScalarUDF.udf` .
29+
:py:func:`~datafusion.user_defined.ScalarUDF.udf` .
3030

3131
The basic definition of a scalar UDF is a python function that takes one or more
3232
`pyarrow <https://arrow.apache.org/docs/python/index.html>`_ arrays and returns a single array as
@@ -93,9 +93,9 @@ converting to Python objects to do the evaluation.
9393
Aggregate Functions
9494
-------------------
9595

96-
The :py:func:`~datafusion.udf.AggregateUDF.udaf` function allows you to define User-Defined
96+
The :py:func:`~datafusion.user_defined.AggregateUDF.udaf` function allows you to define User-Defined
9797
Aggregate Functions (UDAFs). To use this you must implement an
98-
:py:class:`~datafusion.udf.Accumulator` that determines how the aggregation is performed.
98+
:py:class:`~datafusion.user_defined.Accumulator` that determines how the aggregation is performed.
9999

100100
When defining a UDAF there are four methods you need to implement. The ``update`` function takes the
101101
array(s) of input and updates the internal state of the accumulator. You should define this function
@@ -153,8 +153,8 @@ Window Functions
153153
----------------
154154

155155
To implement a User-Defined Window Function (UDWF) you must call the
156-
:py:func:`~datafusion.udf.WindowUDF.udwf` function using a class that implements the abstract
157-
class :py:class:`~datafusion.udf.WindowEvaluator`.
156+
:py:func:`~datafusion.user_defined.WindowUDF.udwf` function using a class that implements the abstract
157+
class :py:class:`~datafusion.user_defined.WindowEvaluator`.
158158

159159
There are three methods of evaluation of UDWFs.
160160

@@ -207,7 +207,7 @@ determine which evaluate functions are called.
207207
208208
import pyarrow as pa
209209
from datafusion import udwf, col, SessionContext
210-
from datafusion.udf import WindowEvaluator
210+
from datafusion.user_defined import WindowEvaluator
211211
212212
class ExponentialSmooth(WindowEvaluator):
213213
def __init__(self, alpha: float) -> None:

examples/python-udwf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from datafusion import col, lit, udwf
2323
from datafusion import functions as f
2424
from datafusion.expr import WindowFrame
25-
from datafusion.udf import WindowEvaluator
25+
from datafusion.user_defined import WindowEvaluator
2626

2727
# This example creates five different examples of user defined window functions in order
2828
# to demonstrate the variety of ways a user may need to implement.

python/datafusion/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@
4949
from .io import read_avro, read_csv, read_json, read_parquet
5050
from .plan import ExecutionPlan, LogicalPlan
5151
from .record_batch import RecordBatch, RecordBatchStream
52-
from .udf import Accumulator, AggregateUDF, ScalarUDF, WindowUDF, udaf, udf, udwf
52+
from .user_defined import (
53+
Accumulator,
54+
AggregateUDF,
55+
ScalarUDF,
56+
WindowUDF,
57+
udaf,
58+
udf,
59+
udwf,
60+
)
5361

5462
__version__ = importlib_metadata.version(__name__)
5563

python/datafusion/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from datafusion.dataframe import DataFrame
3131
from datafusion.expr import Expr, SortExpr, sort_list_to_raw_sort_list
3232
from datafusion.record_batch import RecordBatchStream
33-
from datafusion.udf import AggregateUDF, ScalarUDF, WindowUDF
33+
from datafusion.user_defined import AggregateUDF, ScalarUDF, WindowUDF
3434

3535
from ._internal import RuntimeEnvBuilder as RuntimeEnvBuilderInternal
3636
from ._internal import SessionConfig as SessionConfigInternal

python/tests/test_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_class_module_is_datafusion():
107107
AggregateUDF,
108108
ScalarUDF,
109109
]:
110-
assert klass.__module__ == "datafusion.udf"
110+
assert klass.__module__ == "datafusion.user_defined"
111111

112112
# expressions
113113
for klass in [Expr, Column, Literal, BinaryExpr, AggregateFunction]:

python/tests/test_udwf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from datafusion import SessionContext, column, lit, udwf
2323
from datafusion import functions as f
2424
from datafusion.expr import WindowFrame
25-
from datafusion.udf import WindowEvaluator
25+
from datafusion.user_defined import WindowEvaluator
2626

2727

2828
class ExponentialSmoothDefault(WindowEvaluator):

0 commit comments

Comments
 (0)