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. ExampleCREATE FUNCTION test_function ON CLUSTER 'cluster' AS x -> x + 1;. Closes #30666. #30734 (Maksim Kita). SupportCREATE OR REPLACE,CREATE IF NOT EXISTSsyntaxes. #30454 (Maksim Kita). Added DROP IF EXISTS support. ExampleDROP FUNCTION IF EXISTS test_function. #30437 (Maksim Kita). Support lambdas. ExampleCREATE FUNCTION lambda_function AS x -> arrayMap(element -> element * 2, x);. #30435 (Maksim Kita). Support SQL user defined functions forclickhouse-local. #30179 (Maksim Kita).
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 inclickhouse-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.