Skip to content

Commit

Permalink
[VL][DOC] Update udf doc (apache#5814)
Browse files Browse the repository at this point in the history
Update the compile command for build native udf library.
  • Loading branch information
marin-ma authored May 21, 2024
1 parent ef26a2e commit acf3e6d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions docs/developers/VeloxNativeUDF.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@ You can also specify the local or HDFS URIs to the UDF libraries or archives. Lo
## Try the example

We provided Velox UDF examples in file [MyUDF.cc](../../cpp/velox/udf/examples/MyUDF.cc) and UDAF examples in file [MyUDAF.cc](../../cpp/velox/udf/examples/MyUDAF.cc).
After building gluten cpp, you can find the example libraries at /path/to/gluten/cpp/build/velox/udf/examples/
You need to build the gluten cpp project with `--build_example=ON` to get the example libraries.

```shell
## compile Gluten cpp module
cd /path/to/gluten/cpp
## if you use custom velox_home, make sure specified here by --velox_home
./compile.sh --build_velox_backend=ON --build_examples=ON
```

Then, you can find the example libraries at /path/to/gluten/cpp/build/velox/udf/examples/

Start spark-shell or spark-sql with below configuration

Expand All @@ -157,16 +166,16 @@ or
Run query. The functions `myudf1` and `myudf2` increment the input value by a constant of 5

```
select myudf1(1), myudf2(100L)
select myudf1(100L), myudf2(1)
```

The output from spark-shell will be like

```
+----------------+------------------+
|udfexpression(1)|udfexpression(100)|
+----------------+------------------+
| 6| 105|
+----------------+------------------+
+------------------+----------------+
|udfexpression(100)|udfexpression(1)|
+------------------+----------------+
| 105| 6|
+------------------+----------------+
```

0 comments on commit acf3e6d

Please sign in to comment.