9951 explained code solutions for 126 technologies


clickhouseHow to create user-defined function


CREATE FUNCTION test AS (date, age) -> CONCAT(toString(age), ', ', toString(toYear(date)))ctrl + c
CREATE FUNCTION

creates specified function

test

name of the function to create (so it can later be used)

(date, age)

arguments list of the function

->

implementation expression goes after this symbol

CONCAT(toString(age), ', ', toString(toYear(date)))

example of extracting a year from date argument and concatenating with age into final string