https://github.com/canner/canner-udf-example
Canner UDF example
https://github.com/canner/canner-udf-example
Last synced: about 1 year ago
JSON representation
Canner UDF example
- Host: GitHub
- URL: https://github.com/canner/canner-udf-example
- Owner: Canner
- Created: 2023-03-22T03:40:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-20T11:10:05.000Z (over 2 years ago)
- Last Synced: 2025-04-25T11:50:11.416Z (about 1 year ago)
- Language: Java
- Size: 13.7 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# canner-udf-example
canner-udf-example provides example for writing scalar UDF in Canner.
A scalar function is a function that returns one value per invocation; in most cases, you can think of this as returning one value per row
### Example scalar functions in this project
- In DataMasking.java
```text
mask_column(varchar):varchar
mask_email(varchar,bigint):varchar
```
- In EncryptDecryptWithKey.java
```text
encrypt(varchar):varbinary
decrypt(varbinary):varchar
```
In ExtendedHashFunction.java
```text
ripemd_160(varchar):varchar
```
- In MathOperation.java
```text
math_op(bigint,bigint):bigint
```
- In TimestampSeqNo.java
```text
seq_no(timestamp(p)):varchar
```
- In TimestampWithTZSeqNo.java
```text
seq_no(timestamp(p) with time zone):varchar
```
### Notices
- `resources/META-INF/services/io.trino.spi.Plugin` is needed for canner to load the plugin. And the content of this file is the full class name of the plugin class. (i.e.
com.canner.udf.UdfPlugin in this example project)
- Note that all udf classes (i.e. DataMasking.class, EncryptDecryptWithKey, etc.) are added in `UdfPlugin#getFunctions`. Doing this will make the udfs available in Canner.
### How to build and deploy udf to canner ?
- JDK Version: 11+
- run `mvn clean package`
- in `{project-root}/target`, you will find `udf-1.0-SNAPSHOT-jar-with-dependencies.jar` please rename this file (replace `-` with `_`) and upload it to the User-Defined Function (
UDF) page