Skip to content

Commit 0ee2091

Browse files
authored
Update README.md
1 parent 4f1061a commit 0ee2091

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,32 @@ Full documentation can be found on the Couchbase Developer Portal.
1111
<hr>
1212

1313
## UDF Examples
14-
14+
We have two different types of UDFs in Couchbase, using Javascript for the Query service and using Python for the Analytics service. Here, we showcase the same UDF functionality for the two services.
1515
<hr>
16-
### Javascript UDF
16+
17+
### Query Service UDF using Javascript
1718

1819
Couchbase allows you to create User Defined Functions (UDF) with Javascript to include custom business logic inside your SQL++ queries while querying the data stored in Couchbase.
1920

2021
#### Importing the UDF in Couchbase
2122

2223
- The Javascript [code](javascript-udf/distance.js) here can be imported directly using the `add function library` in the Couchbase Query Workbench under the UDF pane as a library.
2324
- The UDFs can be defined using the `add function` in the Couchbase Query Workbench under the UDF pane as a library.
24-
<hr>
2525

2626
#### Testing the UDF in Couchbase
2727

28-
> EXECUTE FUNCTION distance(51.5, 0, 38.8, -77.1)
28+
- `EXECUTE FUNCTION distance(51.5, 0, 38.8, -77.1)`
2929

30-
If the UDF is defined properly, there will be an output like the one shown below:
30+
- If the UDF is defined properly, there will be an output like the one shown below:
3131

32-
```sh
33-
[
34-
5918.185064088764
35-
]
36-
```
32+
```sh
33+
[
34+
5918.185064088764
35+
]
36+
```
37+
<hr>
3738

38-
### Analytics UDF using Python
39+
### Analytics Service UDF using Python
3940

4041
Couchbase Analytics supports creating custom User Defined Functions using Python. Here, we create a custom UDF that calculates the distance between two GPS coordinates using the [Geodesic distance](https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid).
4142

@@ -65,12 +66,13 @@ Couchbase Analytics supports creating custom User Defined Functions using Python
6566

6667
#### Install requirements
6768

68-
`$ pip install -r requirements.txt`
69+
- `$ pip install -r requirements.txt`
6970

7071
#### Testing the UDF
7172

72-
Run the test [code](analytics-udf/test_distance_library.py).
73-
`$ python test_distance_library.py`
73+
- Run the test [code](analytics-udf/test_distance_library.py).
74+
75+
`$ python test_distance_library.py`
7476

7577
#### Importing the UDF into Couchbase
7678

0 commit comments

Comments
 (0)