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
docs: Update HOWTOs for adding new functions (apache#18089)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closesapache#123` indicates that this PR will close issue apache#123.
-->
- Closesapache#12220
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Updating documentation on adding new functions; aggregate instructions
were old, and adding in other types too (window, table)
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
Updated instructions for adding new functions to DataFusion. Also did
some other touchups on the docs.
## Are these changes tested?
Doc changes only.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Are there any user-facing changes?
Doc changes only.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---------
Co-authored-by: Oleks V <comphead@users.noreply.github.com>
Below is a checklist of what you need to do to add a new scalar function to DataFusion:
31
-
32
-
- Add the actual implementation of the function to a new module file within:
33
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions-nested) for arrays, maps and structs functions
34
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/crypto) for crypto functions
35
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/datetime) for datetime functions
36
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/encoding) for encoding functions
37
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/math) for math functions
38
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/regex) for regex functions
39
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/string) for string functions
40
-
-[here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/unicode) for unicode functions
41
-
- create a new module [here](https://github.com/apache/datafusion/tree/main/datafusion/functions/src/) for other functions.
42
-
- 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
43
-
users to enable or disable the new module as desired.
44
-
- The implementation of the function is done via implementing `ScalarUDFImpl` trait for the function struct.
45
-
- See the [advanced_udf.rs] example for an example implementation
46
-
- Add tests for the new function
47
-
- To connect the implementation of the function add to the mod.rs file:
48
-
- a `mod xyz;` where xyz is the new module file
49
-
- a call to `make_udf_function!(..);`
50
-
- an item in `export_functions!(..);`
51
-
- In [sqllogictest/test_files], add new `sqllogictest` integration tests where the function is called through SQL against well known data and returns the expected result.
52
-
- Documentation for `sqllogictest`[here](https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/README.md)
Below is a checklist of what you need to do to add a new aggregate function to DataFusion:
64
-
65
-
- Add the actual implementation of an `Accumulator` and `AggregateExpr`:
66
-
- In [datafusion/expr/src], add:
67
-
- a new variant to `AggregateFunction`
68
-
- a new entry to `FromStr` with the name of the function as called by SQL
69
-
- a new line in `return_type` with the expected return type of the function, given an incoming type
70
-
- a new line in `signature` with the signature of the function (number and types of its arguments)
71
-
- a new line in `create_aggregate_expr` mapping the built-in to the implementation
72
-
- tests to the function.
73
-
- In [sqllogictest/test_files], add new `sqllogictest` integration tests where the function is called through SQL against well known data and returns the expected result.
74
-
- Documentation for `sqllogictest`[here](https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/README.md)
@@ -97,11 +123,13 @@ can be displayed. For example, the following command creates a
97
123
dot -Tpdf < /tmp/plan.dot > /tmp/plan.pdf
98
124
```
99
125
100
-
## How to format `.md`document
126
+
## How to format `.md`documents
101
127
102
-
We are using `prettier` to format `.md` files.
128
+
We use [`prettier`] to format `.md` files.
103
129
104
-
You can either use `npm i -g prettier` to install it globally or use `npx` to run it as a standalone binary. Using `npx` required a working node environment. Upgrading to the latest prettier is recommended (by adding `--upgrade` to the `npm` command).
130
+
You can either use `npm i -g prettier` to install it globally or use `npx` to run it as a standalone binary.
131
+
Using `npx` requires a working node environment. Upgrading to the latest prettier is recommended (by adding
132
+
`--upgrade` to the `npm` command).
105
133
106
134
```bash
107
135
$ prettier --version
@@ -114,19 +142,19 @@ After you've confirmed your prettier version, you can format all the `.md` files
0 commit comments