v.21.11Improvements

Multiple Enhancements to SQL User Defined Functions in ClickHouse

Multiple improvements for SQL UDF. Queries for manipulation of SQL User Defined Functions now support ON CLUSTER clause. Example CREATE FUNCTION test_function ON CLUSTER 'cluster' AS x -> x + 1;. Closes #30666. #30734 (Maksim Kita). Support CREATE OR REPLACE, CREATE IF NOT EXISTS syntaxes. #30454 (Maksim Kita). Added DROP IF EXISTS support. Example DROP FUNCTION IF EXISTS test_function. #30437 (Maksim Kita). Support lambdas. Example CREATE FUNCTION lambda_function AS x -> arrayMap(element -> element * 2, x);. #30435 (Maksim Kita). Support SQL user defined functions for clickhouse-local. #30179 (Maksim Kita).
Multiple enhancements for SQL User Defined Functions (UDFs) in ClickHouse, including support for the ON CLUSTER clause, new syntaxes like CREATE OR REPLACE and CREATE IF NOT EXISTS, DROP IF EXISTS, lambda functions, and compatibility with clickhouse-local.

Why it matters

These improvements enable easier and more flexible management of SQL UDFs across clusters and local environments. They solve limitations in functionality and syntax support, allowing users to create, update, and drop functions more safely and conveniently, use lambdas within UDFs, and apply UDFs in clickhouse-local scenarios, enhancing overall productivity and consistency.

How to use it

Users can now create or manipulate SQL UDFs with enhanced syntax such as:
- CREATE FUNCTION test_function ON CLUSTER 'cluster' AS x -> x + 1; to deploy functions across a cluster.
- Use CREATE OR REPLACE and CREATE IF NOT EXISTS for safer creation.
- Drop functions conditionally with DROP FUNCTION IF EXISTS test_function;.
- Define lambda-based functions like CREATE FUNCTION lambda_function AS x -> arrayMap(element -> element * 2, x);.
- Use SQL UDF support within clickhouse-local for local testing and scripts.