https://github.com/metrico/clickhouse-udf-node
Example NodeJS UDF for Clickhouse
https://github.com/metrico/clickhouse-udf-node
clickhouse cloki javascript node nodejs udf user-defined-function
Last synced: about 1 month ago
JSON representation
Example NodeJS UDF for Clickhouse
- Host: GitHub
- URL: https://github.com/metrico/clickhouse-udf-node
- Owner: metrico
- Created: 2022-02-13T16:02:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-13T21:44:45.000Z (over 4 years ago)
- Last Synced: 2025-05-19T23:08:39.654Z (about 1 year ago)
- Topics: clickhouse, cloki, javascript, node, nodejs, udf, user-defined-function
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# ClickHouse NodeJS UDF
This basic example illustrates a simple `sum` NodeJS powered Clickhouse UDF function
##### ⏱️ Why
> Clickhouse is super fast and already has all the functions one could dream. What is this for?
This example is designed to understand the underlying formats and unleash imagination for integrators.
### NodeJS Function
Create an [executable NodeJS script](https://github.com/metrico/clickhouse-udf-node/blob/main/node-udf-sum.js)
- read input from stdin
- split row values by tabs
- return some output
> In our example we'll just accept two integers and sum them
### ClickHouse UDF
Configure a [UDF Function](https://github.com/metrico/clickhouse-udf-node/blob/main/node_function.xml) to invoke your script
- use directory `/var/lib/clickhouse/user-scripts` to store user-scripts
### Use UDF
```
SELECT node_sum(10, 20)
Query id: f98a5f83-4e94-41d0-9d9f-78b37d3af152
┌─node_sum(10, 20)-─┐
│ 30 │
└───────────────────┘
1 rows in set. Elapsed: 0.054 sec.
```