An open API service indexing awesome lists of open source software.

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

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.
```