Custom Functions

Hydrolix provides the ability to create user defined functions

Custom Functions

Hydrolix custom functions are created using the API and are scoped to specific Projects (to avoid namespace collision).

Custom function configuration follows a similar method as can be found here - https://clickhouse.com/docs/en/sql-reference/statements/create/function/.

To Specify your function with the API you should define it as follows:

πŸ“˜

The sql section of the function config corresponds to the expression which immediately follows:
CREATE FUNCTION <function name> AS ...

POST https://{hostname}.hydrolix.live/config/v1/orgs/{org_id}/projects/{project_id}/functions/
Authorization: Bearer {{access_token}}
Content-Type: application/json

{
     "sql": "(x, k, b) -> k*x + b;",
     "name": "linear_equation"
}
NameDefinition
sqlThe functions specification.
nameThe name of the function

Example Custom Function usage

SELECT
    number,
    {{projectname}}_linear_equation(number, 2, 1)
FROM numbers(3)

β”Œβ”€number─┬─plus(multiply(2, number), 1)─┐
β”‚      0 β”‚                            1 β”‚
β”‚      1 β”‚                            3 β”‚
β”‚      2 β”‚                            5 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜