Skip to content

CLI commands

sqlbabel function

Convert a SQL project function's body into a DuckDB macro body.

sqlbabel function converts the body of a SQL function your project defines into the body of a DuckDB macro, and prints it as JSON.

sqlbabel function --name <NAME> [OPTIONS] <BODY>
sqlbabel function --name NET_TOTAL --no-config net_total.sql

BODY is the file holding the function’s body: a scalar function’s expression, or a table function’s query. Use - to read standard input. The function, its arguments and return type, and the tables its body reads are declared in the project in the current folder.

A converted body prints the macro’s parameters and body, and under macros the statements creating the helper macros the body calls, to run before you create the macro; the list is empty when it calls none. A refused body prints {"converted": false, "name": …, "refusals": [diagnostics]} instead, with the same diagnostics on standard error.

Option Meaning
--name <name> The function’s name, as the project declares it. Required.
--project <folder> The project declaring the function. Default the current folder.
--session NAME=VALUE A Snowflake session parameter of your session. Repeatable.

function also takes the policy flags.

0 when the body converts, 1 when it is refused, 2 when the command can’t run.