You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/contributor-guide/index.md
+19-14Lines changed: 19 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -249,22 +249,27 @@ These are valuable for comparative evaluation against alternative Arrow implemen
249
249
250
250
Below is a checklist of what you need to do to add a new scalar function to DataFusion:
251
251
252
-
- Add the actual implementation of the function:
253
-
-[here](../../../datafusion/physical-expr/src/string_expressions.rs) for string functions
254
-
-[here](../../../datafusion/physical-expr/src/math_expressions.rs) for math functions
255
-
-[here](../../../datafusion/physical-expr/src/datetime_expressions.rs) for datetime functions
256
-
- create a new module [here](../../../datafusion/physical-expr/src) for other functions
257
-
- In [physical-expr/src](../../../datafusion/physical-expr/src/functions.rs), add:
258
-
- a new variant to `BuiltinScalarFunction`
259
-
- a new entry to `FromStr` with the name of the function as called by SQL
260
-
- a new line in `return_type` with the expected return type of the function, given an incoming type
261
-
- a new line in `signature` with the signature of the function (number and types of its arguments)
262
-
- a new line in `create_physical_expr`/`create_physical_fun` mapping the built-in to the implementation
263
-
- tests to the function.
252
+
- Add the actual implementation of the function to a new module file within:
253
+
-[here](../../../datafusion/functions-array/src) for array functions
254
+
-[here](../../../datafusion/functions/src/crypto) for crypto functions
255
+
-[here](../../../datafusion/functions/src/datetime) for datetime functions
256
+
-[here](../../../datafusion/functions/src/encoding) for encoding functions
257
+
-[here](../../../datafusion/functions/src/math) for math functions
258
+
-[here](../../../datafusion/functions/src/regex) for regex functions
259
+
-[here](../../../datafusion/functions/src/string) for string functions
260
+
-[here](../../../datafusion/functions/src/unicode) for unicode functions
261
+
- create a new module [here](../../../datafusion/functions/src) for other functions.
262
+
- New function modules - for example a `vector` module, should use a [rust feature](https://doc.rust-lang.org/cargo/reference/features.html) (for example `vector_expressions`) to allow DataFusion
263
+
users to enable or disable the new module as desired.
264
+
- The implementation of the function is done via implementing `ScalarUDFImpl` trait for the function struct.
265
+
- See the [advanced_udf.rs](../../../datafusion-examples/examples/advanced_udf.rs) example for an example implementation
266
+
- Add tests for the new function
267
+
- To connect the implementation of the function add to the mod.rs file:
268
+
- a `mod xyz;` where xyz is the new module file
269
+
- a call to `make_udf_function!(..);`
270
+
- an item in `export_functions!(..);`
264
271
- In [sqllogictest/test_files](../../../datafusion/sqllogictest/test_files), add new `sqllogictest` integration tests where the function is called through SQL against well known data and returns the expected result.
265
272
- Documentation for `sqllogictest`[here](../../../datafusion/sqllogictest/README.md)
266
-
- In [expr/src/expr_fn.rs](../../../datafusion/expr/src/expr_fn.rs), add:
267
-
- a new entry of the `unary_scalar_expr!` macro for the new function.
0 commit comments