Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to create UDF for clickhouse?

Tags:

clickhouse

In answer to a github ticket regarding UDF of clickhouse, they answered in 2017 that UDF can't be created in clickhouse. I want to know Is there any way to do it now in 2020?

like image 794
MAYANK BHARTI Avatar asked Sep 01 '25 10:09

MAYANK BHARTI


1 Answers

UDFs for ClickHouse came in September, 2021. There are two PRs introducing UDFs:

  • UDF as an SQL expression, example: CREATE FUNCTION plus_one as (a) -> a + 1. I have tested this on ClickHouse v21.10.2.15 and it works (should be supported starting from v21.10).
  • UDF as an executable script. Such a function is defined within ClickHouse server configuration, see an example in the PR. This is an arbitrary script that reads data from stdin and outputs data to stdout in a supported format: CSV, TabSeparated, or others. The example uses clickhouse-local to process data incoming from ClickHouse server.

As a presentation from 2021 says, ClickHouse team considers five ways to define a UDF. One of alternative ways mentioned in an older presentation is a cache dictionary with an executable source.

like image 78
Anton Bryzgalov Avatar answered Sep 06 '25 14:09

Anton Bryzgalov