Skip to content

Drivers for executable user-defined functions - #105131

Merged
alexey-milovidov merged 56 commits into
masterfrom
add-executable-udf-drivers
Jul 1, 2026
Merged

alexey-milovidov merged 56 commits into
masterfrom
add-executable-udf-drivers

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 16, 2026 •

Copy link
Copy Markdown
Member

Implements the feature requested in #71172 - operator-supplied "drivers" that turn a user code snippet into an executable user-defined function. Supersedes the draft in #77128 (which used a different, mostly-incorrect design).

A driver is described by an XML/YAML file under <user_defined_executable_function_drivers_config>. It declares:

  • name - the driver name as used in CREATE FUNCTION ... ENGINE = <name>(...)
  • create_command - shell script invoked to create a UDF from a code snippet
  • drop_command (optional) - invoked when the function is dropped
  • engine_arguments (optional) - allowed args inside ENGINE = Driver(a='x', b=1), with <required> flag
  • env (optional) - environment variables passed to the driver

New SQL form:

CREATE [OR REPLACE] FUNCTION [IF NOT EXISTS] name [ON CLUSTER c]
    ARGUMENTS (a UInt8, b String) RETURNS UInt64
    ENGINE = DriverName(key1 = 'value1', key2 = 42)
    AS '...code body...'

CREATE FUNCTION invokes create_command with --name, --return, --args, plus any declared engine arguments, sets the configured env vars, sends the user body on stdin, and reads the resulting executable UDF configuration from stdout. Format is auto-detected (XML if it starts with <, otherwise YAML) and written into <dynamic_user_defined_executable_functions_path>; the existing executable UDF loader picks it up. The originating SQL is persisted as ATTACH FUNCTION ... in <user_defined> so it survives restart. On server start, if a persisted ATTACH has no matching file in the dynamic directory, the driver is re-run.

DROP FUNCTION invokes drop_command (if present), removes the dynamic config and the per-function working directory, reloads the UDF loader, and removes the persisted SQL.

If create_command exits non-zero, an exception is thrown that includes the exit code and the full driver stderr; the per-function working directory is removed so failed attempts leave no state.

Includes a proof-of-concept driver c_function_body: takes a C function body, generates a TabSeparated stdin/stdout wrapper, compiles it inside a sandboxed Docker container, and emits an executable_pool UDF that runs the compiled binary inside another sandboxed Docker container (--network=none --read-only --cap-drop=ALL --security-opt=no-new-privileges --user 65534:65534 + memory/cpu/pids limits). CLICKHOUSE_C_DRIVER_FORCE_LOCAL=1 switches to direct compile + run for environments without Docker (used by the tests).

Stateless tests:

  • 04241_executable_udf_driver - create, call, simulated config-loss recreate, drop, file cleanup
  • 04242_executable_udf_driver_errors - non-zero exit code + multi-line stderr propagation, empty driver output detection, unknown driver detection, absence of leftover state on failure

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added "drivers" for executable user-defined functions. A driver declared in <user_defined_executable_function_drivers_config> can be used in CREATE FUNCTION name ARGUMENTS (...) RETURNS T ENGINE = DriverName(...) AS '...code...' to compile or otherwise process a user code snippet at function-creation time and produce a runnable executable UDF. The resulting configuration is stored in <dynamic_user_defined_executable_functions_path>, and the originating query is persisted as ATTACH FUNCTION so the function survives server restarts. A proof-of-concept c_function_body driver compiles and runs C function bodies inside sandboxed Docker containers in executable_pool mode.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features) — added a "Driver-based Executable User Defined Functions" section to docs/en/sql-reference/functions/udf.md.

Note

High Risk
Adds a new SQL pathway that executes operator-configured external driver commands, writes/loads generated UDF configs from disk, and changes startup/reload behavior; this touches execution, filesystem, and security-sensitive surfaces.

Overview
Adds driver-based executable UDFs: a new CREATE/ATTACH FUNCTION ... ENGINE = DriverName(...) AS 'code' SQL form that invokes an operator-configured create_command, persists the generated XML/YAML UDF config under dynamic_user_defined_executable_functions_path, and stores the originating query as ATTACH FUNCTION for restart durability.

Introduces a driver registry loaded from <user_defined_executable_function_drivers_config> (on startup and config reload), wires it into clickhouse-server and clickhouse-local, and adds startup recovery that re-runs drivers for persisted functions whose dynamic configs are missing.

Extends the executable UDF loader to watch the dynamic config directory, supports per-function working directories for direct execution, and adds optional <command_pipe_capacity> plumbing down to ShellCommand pipe sizing.

Includes proof-of-concept C-body drivers/scripts and stateless tests covering create/call/recreate/drop flows plus failure cleanup and error propagation.

Reviewed by Cursor Bugbot for commit 5576b9e. Bugbot is set up for automated code reviews on this repo. Configure here.

alexey-milovidov and others added 3 commits May 16, 2026 17:24
Introduce "drivers" for executable user-defined functions. A driver is a
small adapter program declared in a server config under
`<user_defined_executable_function_drivers_config>` that knows how to take a
user-supplied code snippet and produce a runnable executable user-defined
function configuration.

New CREATE FUNCTION syntax:

    CREATE [OR REPLACE] FUNCTION [IF NOT EXISTS] name [ON CLUSTER c]
        ARGUMENTS (a UInt8, b String) RETURNS UInt64
        ENGINE = DriverName(key1 = 'value1', key2 = 42)
        AS '...code body...'

On CREATE FUNCTION, the corresponding `create_command` of the driver is
invoked: arguments are passed via `--name`, `--return`, `--args` and the
declared engine arguments; the body is sent on stdin; the driver writes the
resulting executable UDF configuration (XML or YAML) to stdout, which is
saved into the new `<dynamic_user_defined_executable_functions_path>` and
picked up by the existing executable UDF loader. The corresponding SQL is
persisted as `ATTACH FUNCTION ...` in `<user_defined>` and re-evaluated on
restart: if the dynamic configuration is still present, the driver is not
invoked; otherwise the driver is re-run to materialize it.

On DROP FUNCTION, the `drop_command` (if any) is invoked, then the dynamic
configuration file and per-function working directory are removed.

Includes a proof-of-concept driver `c_function_body`, which compiles a user
C body into a binary (inside Docker by default for build-time isolation) and
runs it inside Docker at query time with strict sandboxing (`--network=none`,
`--read-only`, dropped capabilities, no-new-privileges, unprivileged user,
resource limits) in `executable_pool` mode for batched per-row evaluation.

See #71172

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When an executable UDF driver returns a non-zero exit code from
`create_command`, the resulting exception now includes the exit code and the
complete stderr the driver produced. Previously the wrapper caught the
generic `CHILD_WAS_NOT_EXITED_NORMALLY` from `ShellCommand::wait` and dropped
the code, so callers only saw a vague "child process was exited with return
code N" without the diagnostic output the driver had written.

The same treatment is applied to `drop_command`. A failing `drop_command` is
still caught by the DROP interpreter so cleanup of the dynamic config and
the user-defined SQL entry continues, with the exit code and stderr logged.

`CREATE FUNCTION` also removes the per-function working directory if the
driver fails, so a failed attempt leaves no state behind.

Added stateless test 04242_executable_udf_driver_errors that exercises:
- non-zero exit code with multi-line stderr (asserts both code and lines)
- silent driver that exits zero but produces no stdout
- reference to an unknown driver
- absence of leftover work-dir, dynamic config, or persisted SQL after
  failed creation

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
A driver describes how to create executable user-defined functions; calling
the surrounding element `<function>` was misleading - it suggested the file
described a single function. Rename to `<driver>` everywhere (example config,
parsing in the registry, the doc comment, both stateless tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7215a3e]

Summary: ✅


AI Review

Summary

This PR adds experimental driver-based executable UDFs: CREATE FUNCTION ... ENGINE = DriverName(...) AS ... invokes an operator-configured driver, stores generated executable UDF config/workdir artifacts, and persists the originating ATTACH FUNCTION for restart recovery. The latest push fixed the missing user documentation; I resolved that bot-authored thread. I found no genuinely new inline issue outside the existing review threads, but several high-impact lifecycle, cleanup, logging, and sandbox concerns remain present in current code and were dismissed/deferred by the author as design tradeoffs for this disabled-by-default experimental feature.

Findings

❌ Blockers

  • [src/Interpreters/InterpreterCreateFunctionQuery.cpp:316] Driver artifacts are still published before the SQL-object storage commit decides whether the statement won. In CREATE OR REPLACE, failures after the config rename or in storeObject can replace/delete the previous working config; racing CREATE FUNCTION IF NOT EXISTS attempts can also overwrite or remove the winner's artifacts. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253343953, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253344045, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253394869, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253420224] This still violates the invariant that failed/no-op creates must not alter an existing runnable function.
  • [src/Interpreters/InterpreterCreateFunctionQuery.cpp:485] CREATE FUNCTION ... ENGINE = ... still logs and swallows executable-loader reload failures after SQL metadata is stored, so the statement can report success while the function is not actually registered. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253344147] The user-visible create contract still diverges from loader state.
  • [src/Interpreters/InterpreterDropFunctionQuery.cpp:46] DROP FUNCTION remains fail-open for driver cleanup: missing driver config, missing/empty .workdir, drop_command failure, loader reload failure, or later SQL metadata failure can all leave external resources unretryable or leave metadata/loader/artifacts inconsistent. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253360062, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253656019, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3277846713, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3377808415, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3493980122] Destructive cleanup should fail close while durable metadata is still available for retry.
  • [src/Interpreters/InterpreterCreateFunctionQuery.cpp:473] CREATE OR REPLACE and DROP remove workdirs immediately even though already planned/running queries may still hold UserDefinedExecutableFunction objects whose execution resolves binaries from those directories. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3377815375] Existing queries can fail after a replace/drop due to artifact lifetime ending before object lifetime.
  • [src/Functions/UserDefined/UserDefinedExecutableFunctionDriverInvoker.cpp:77] Driver env values and engine-argument values are still placed in /usr/bin/env argv and logged verbatim by shared ShellCommand at TRACE, despite the new redacted driver-level debug log. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3448568005] Operator credentials/tokens remain exposed whenever trace logging captures shell command argv.
  • [programs/server/user_defined_executable_function_drivers/c_driver_common.py:852] DockerC still mounts the full driver workdir read/write into the runtime container. That is stronger than a generic read-only mismatch: the mounted directory contains host-executed files such as docker_fifo_runner.sh, and user C code running as the ClickHouse UID/GID can modify files or fill disk under the dynamic UDF path. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3321371091] Keep host-executed scripts outside the writable mount and expose only bounded per-call writable state.

⚠️ Majors

  • [src/Functions/UserDefined/UserDefinedSQLFunctionFactory.cpp:299] RESTORE still persists driver-backed ATTACH FUNCTION objects without running the driver, and recovery/reload paths still log-and-continue instead of deterministically materializing or retrying broken dynamic state. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3321371094, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3368665546, https://github.com/Drivers for executable user-defined functions #105131#discussion_r3389008237] A restored or previously unrecoverable function can remain unavailable until a restart/manual recreate.
  • [programs/server/user_defined_executable_function_drivers/c_driver_common.py:925] GVisorC still advertises CLICKHOUSE_C_DRIVER_MEMORY and CLICKHOUSE_C_DRIVER_CPUS, but the generated runtime command is bare runsc --rootless --network=none do ... with no memory, CPU, or PID limits. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253624126] Operators can believe the runtime is capped when it is not.
  • [programs/server/user_defined_executable_function_drivers/c_driver_common.py:905] stop_docker_container still ignores failures from Docker cleanup, so drop_command can report success even when runtime containers were not removed. [dismissed by author -- https://github.com/Drivers for executable user-defined functions #105131#discussion_r3253656021] Use checked subprocess calls and propagate cleanup failure.
Final Verdict

Status: ❌ Block

Minimum required actions: make the artifact lifecycle transactional or explicitly accepted by the owning maintainers as an experimental-risk tradeoff, make destructive drop/recovery paths fail close or persist retryable cleanup state, and close the remaining secret-log and sandbox/resource-limit gaps before exposing the example drivers to untrusted users.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label May 16, 2026
Validate `CREATE FUNCTION ... ENGINE` against existing user-defined
function storage before invoking driver `create_command`, so failed creates
and `IF NOT EXISTS` no-ops do not run driver side effects. Persist the
normalized `ATTACH FUNCTION` query before reloading the generated executable
UDF configuration.

Drain driver stdout and stderr concurrently in
`UserDefinedExecutableFunctionDriverInvoker` to avoid pipe-buffer deadlocks,
and keep stderr attached to non-zero and abnormal child exits.

Resolve relative `create_command` and `drop_command` paths relative to the
driver config file, fix the example XML for `xmllint`, and clean up the
dynamic executable UDF config repository during context shutdown.

Tests:
`ninja -C build programs/clickhouse`
`./tests/clickhouse-test -b ./build/programs/clickhouse 04241_executable_udf_driver`
`./tests/clickhouse-test -b ./build/programs/clickhouse 04242_executable_udf_driver_errors`

Refs: #105131
Comment thread programs/server/Server.cpp Resolved
Comment thread src/Interpreters/Context.cpp Resolved
Call `loadUserDefinedExecutableFunctionDrivers` during initial
`clickhouse-server` startup before persisted user-defined functions are loaded.
This makes source-tree driver configs such as `c_function_body` available
without waiting for a later config reload.

Resolve driver config directories to absolute paths before applying relative
`create_command` and `drop_command` entries. Driver commands run from a
per-function work directory, so a relative config directory would otherwise make
source-tree example commands relative to the wrong directory.

Improve the unknown-driver exception so it distinguishes an empty driver
registry from a typo in the requested driver name.

Tests:
`ninja -C build programs/clickhouse`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
`clickhouse-server` default-config smoke with `c_function_body`

Refs: #105131
}
catch (...)
{
removeDriverArtifacts(current_context, function_name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeDriverArtifacts here is destructive on failure paths where we may already have a valid function.

If this is CREATE OR REPLACE and storeObject throws (for example metadata write exception), this cleanup removes the existing dynamic config (.xml/.yaml) and working directory of the previous function version. The statement fails, but the old function is now broken.

Please make the replace flow transactional: keep old artifacts untouched until SQL metadata persistence succeeds (e.g. write generated config to temporary paths/workdir, commit metadata, then atomically swap), and only clean artifacts created by the current attempt.


if (!stored)
{
removeDriverArtifacts(current_context, function_name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This !stored branch can be hit under a race (CREATE FUNCTION IF NOT EXISTS on the same name from two sessions): the loser gets stored = false after the winner already committed.

Calling removeDriverArtifacts here then deletes the winner’s just-created dynamic config/working dir, so a successful create in another session gets broken by the no-op path.

Please avoid touching final artifacts when storeObject returns false; at most clean per-attempt temporary files.

}
catch (...) // NOLINT(bugprone-empty-catch)
{
/// Ignore reload errors here - they will be surfaced when the user tries to call the function.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swallowing reloadFunction exceptions here lets CREATE FUNCTION ... ENGINE = ... succeed even when the generated config is invalid/unloadable.

That leaves persisted SQL metadata pointing to a function that was never registered by the executable UDF loader, so the user gets a false-success create and a broken function state.

Can we fail the create on reload exceptions (with rollback of this create attempt) instead of logging-and-continuing?

The source-tree `c_function_body` example driver used Docker with
`--security-opt=no-new-privileges`, but this option prevents containers from
executing on some developer hosts. Keep Docker for the example, but drop that
option from both the build container and the generated runtime command.

Run the Docker containers as the server OS user so they can read and write the
server-created per-function work directory without changing directory
permissions.

Tests:
`python3 -m py_compile programs/server/user_defined_executable_function_drivers/c_function_body_driver.py`
`git diff --check`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
`clickhouse-server` default-config smoke with Docker-backed `c_function_body`

Refs: #105131
{
if (const auto * driver_ast = existing_ast->as<ASTCreateFunctionWithDriverQuery>())
{
handleDriverBasedDrop(*driver_ast, current_context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleDriverBasedDrop is executed before removeObject. If removeObject throws (for example metadata write exception), the statement fails but we have already removed the dynamic config/working directory and reloaded the external UDF loader.

That leaves the function definition still persisted in SQL-object storage while the executable artifacts are gone, so the function is broken despite failed DROP.

Can we make this flow transactional by removing SQL metadata first (or otherwise rolling back artifact deletion on failure), and only then deleting driver artifacts / reloading the loader?

Create driver-owned working directories under
`dynamic_user_defined_executable_functions_path` with random UUID names, as
specified in #71172 (comment).
Keep generated `.xml` and `.yaml` configs named after the function and store a
function-named `.workdir` sidecar so `DROP FUNCTION` can invoke the driver and
remove the UUID directory.

This avoids reusing stale function-named directories such as `test.d` and makes
the source-tree `c_function_body` example match the RFC.

Also reload the executable UDF config repository on drop instead of reloading
the removed function by name, avoiding a normal `not found` exception in logs.

Tests:
- `ninja -C build programs/clickhouse`
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
- default-config smoke with `c_function_body`: `CREATE FUNCTION`, `SELECT` returned `42`, `DROP FUNCTION`

Refs: #105131
Refs: #71172 (comment)
writeString(std::filesystem::path(result.working_dir).filename().string(), working_dir_out);
working_dir_out.finalize();

std::filesystem::rename(tmp_path, final_path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executeCreateFunctionWithDriver can leave a broken function artifact state on an exception in this file-write sequence.

In OR REPLACE, config_exists is true. After rename(tmp_path, final_path) succeeds, a failure in the subsequent .workdir rename enters the catch block, but final_path is not rolled back because cleanup only removes it when !config_exists.

At that point the old config has already been replaced, and we then delete result.working_dir; the statement fails, but the persisted SQL metadata still points to a config that may reference deleted artifacts.

Please make the config + .workdir update atomic as a pair (or restore the previous config on post-rename failures) so failed replace attempts do not corrupt previously working state.

Update the source-tree `c_function_body` example driver to generate an
`executable_pool` function using `RowBinary` with `send_chunk_header` enabled.
The generated wrapper now reads the text chunk row count, consumes that many
`RowBinary` argument rows, writes the same number of `RowBinary` result rows,
and flushes once per chunk.

Remove the generated `setvbuf` call; chunk-level flushing is enough and matches
the executable UDF protocol better than per-row line buffering.

Tests:
- direct generated-wrapper protocol check with one 3-row chunk
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`

Refs: #105131
return BlockIO();

/// 1. Invoke driver, write generated config to dynamic_path.
DriverCreateResult create_result = executeCreateFunctionWithDriver(*create_function_query, current_context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executeCreateFunctionWithDriver publishes the final dynamic config (<name>.xml/.yaml + .workdir) before storeObject decides whether this query actually won.

Under concurrent CREATE FUNCTION IF NOT EXISTS for the same name, both sessions can pass shouldRunCreateFunctionWithDriver, both run the driver, and both rename into the same final paths. The loser then gets stored = false, but by that time it may already have overwritten the winner's artifacts, so a no-op IF NOT EXISTS can still change function behavior.

Can we make artifact publication conditional on successful SQL-object commit (for example by keeping per-attempt temp paths and only atomically swapping to final names after storeObject succeeds)?

Replace the generated wrapper's `stdio`-based `RowBinary` IO with a small
buffered `read` and `write` layer. Parse the text `send_chunk_header` row count
manually and serialize primitive values by copying fixed-width `RowBinary`
values directly to and from the in-memory buffers.

This keeps the example protocol-compatible while avoiding per-value C library
IO and formatting overhead in the generated executable.

Tests:
- generated-wrapper protocol check with one 3-row chunk
- generated-wrapper benchmark: 200000 rows, about 25M rows/sec in this run
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
- `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`

Refs: #105131
Extend the `c_function_body` example driver from #105131 to support the `String` type in `RowBinary`.

`String` arguments and return values are exposed to the C body as `struct buf { const char * data; size_t size; }`. The generated wrapper also provides `alloc`, a simple chunk-scoped bump allocator for returning strings. The allocator keeps buffers stable for the whole chunk and resets after the chunk is flushed.

Also compile generated functions with `-O3 -march=native`, while keeping the Docker build static.

Tests:
* `python3 -m py_compile programs/server/user_defined_executable_function_drivers/c_function_body_driver.py`
* direct `RowBinary` protocol check in `build/test_c_function_body_driver_string_protocol.log`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
* `git diff --check`
Rewrite the `c_function_body` example driver from #105131 to use the `Buffers` format instead of row-wise `RowBinary`.

The generated wrapper now reads one `Buffers` block per `send_chunk_header` chunk, validates the column count and row count, exposes arguments row-by-row to the user body, and writes the result as a single-column `Buffers` block. `String` columns are parsed once per chunk into `struct buf` views over the serialized column buffer, while returned `String` values are serialized into the result column buffer after calls to `alloc`.

Tests:
* `python3 -m py_compile programs/server/user_defined_executable_function_drivers/c_function_body_driver.py`
* direct `Buffers` protocol check in `build/test_c_function_body_driver_buffers_protocol.log`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
* `git diff --check`
Fix executable UDF argument preparation for #105131.

The executable UDF path already called `castColumnAccurate` for arguments whose actual type differs from the declared `ARGUMENTS` type, but then restored the original `ColumnWithTypeAndName`. This made calls such as `SELECT test(1, 2)` pass literal integer columns to a function declared as `UInt64`. With the `Buffers` format the external process receives only raw column buffers, so the generated wrapper sees an `Int8`-sized buffer where it expects `UInt64` and reports `input column read error`.

Keep the casted column and type, and add coverage for a `c_function_body` function declared with `UInt64` arguments but called with integer literals.

Reported query:
`SELECT test(1, 2)`

Tests:
* `ninja -C build programs/clickhouse`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
* `CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
* `git diff --check`
working_directory, engine_argument_values);

auto log = getLogger("UserDefinedExecutableFunctionDriverInvoker");
LOG_DEBUG(log, "Invoking driver '{}' create_command: {}", driver.name, cmd.describe());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd.describe() expands every configured driver env entry as KEY=VALUE into the debug log, and this path is used for both create_command and drop_command. Driver environment values are an operator-facing config surface and can reasonably contain credentials or tokens for compilers, package registries, or sandbox infrastructure; engine argument values may also carry user-supplied data. Logging the fully expanded command leaks those values to server logs whenever debug logging is enabled.

Please redact values here (for example log only env variable names plus the command path, or replace values with <redacted>) and avoid logging raw engine argument values unless they are explicitly non-secret.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redacted the driver-invocation debug log in 8c28b9f: buildCommand now builds a separate redacted_description that replaces every driver env value and engine-argument value with [HIDDEN], while keeping the names and the non-secret structural arguments (command path, --name/--return/--args, working directory) visible. The arguments actually passed to the driver are unchanged. Verified at runtime: a driver with a secret env var and a secret engine argument now logs ... MY_TOKEN=[HIDDEN] ... --apikey [HIDDEN], with the raw values appearing zero times in the LOG_DEBUG.

One caveat I'm flagging rather than silently leaving: because driver env vars are passed as /usr/bin/env KEY=VALUE ... argv tokens, ShellCommand::logCommand still prints the raw KEY=VALUE and engine-argument values at TRACE level (Will start shell command '/usr/bin/env' with arguments ...). Fully closing that would mean either redacting in the shared ShellCommand argv trace (affects every shell-command caller) or passing env through the child's environment instead of as argv — both broader than this log line, so I left them for you to decide and kept this thread open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the debug-log redaction, but the same values are still emitted through ShellCommand at TRACE: buildCommand still appends both driver env values (KEY=value) and engine argument values into cmd.arguments (src/Functions/UserDefined/UserDefinedExecutableFunctionDriverInvoker.cpp:77-105), and ShellCommand::executeImpl calls logCommand, which logs every argv entry verbatim (src/Common/ShellCommand.cpp:139-150). So a server with trace logging still records raw values such as MY_TOKEN=... and --apikey ....

Please either pass driver env through the child environment rather than argv and add a redaction path for engine arguments, or teach ShellCommand::Config which argv positions must be redacted before logCommand.

alexey-milovidov and others added 2 commits June 23, 2026 03:39
The `system.query_log` query added in `04241_executable_udf_driver.sh`
for the executable-UDF classification assertion was missing the
`current_database = currentDatabase()` condition that the dedicated
style check (`ci/jobs/scripts/check_style/various_checks.sh`) requires.
The query runs in an isolated single-process `clickhouse-local`, so the
condition is satisfied and the assertion still matches the expected row.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105131&sha=77cfd0fbd0ba5ba4506a7ccae86d9d0d19d629b6&name_0=PR&name_1=Style%20check

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`UserDefinedExecutableFunctionDriverInvoker` logged the fully expanded
`/usr/bin/env ...` command line at debug level via `DirectCommand::describe`,
which included every driver `env` `KEY=VALUE` entry and every engine
argument value. Driver `env` values and engine-argument values are an
operator/user-facing surface that can carry credentials or tokens, so
this leaked secrets into the server log whenever debug logging was on.

Build the logged form with the values replaced by `[HIDDEN]` while keeping
the variable/argument names and the non-secret structural arguments
visible. The arguments actually passed to the driver keep the real values
and are never logged.

Addresses review feedback: #105131 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed 8c28b9ff0ff (two commits) — addresses the sole red CI plus the one non-dismissed AI finding:

1. Style check (the only failing check), 8ea2add8d04. The system.query_log query I added in the previous push for the executable-UDF classification assertion was missing the current_database = currentDatabase() condition that the dedicated style check (ci/jobs/scripts/check_style/various_checks.sh) requires. Added it. The query runs in an isolated single-process clickhouse-local, so the condition is satisfied and the assertion still matches the expected row. 04241 and 04242 pass locally (diff empty) against a freshly built binary.

2. Redact driver env/engine-argument values in the driver-invocation debug log, 8c28b9ff0ff — the one non-dismissed AI Blocker (thread #discussion_r3448568005). buildCommand now produces a redacted log form that replaces every env value and engine-argument value with [HIDDEN] while keeping the names and the non-secret structural arguments visible; the arguments actually passed to the driver are unchanged. Verified at runtime: a driver with a secret env var and a secret engine argument logs ... MY_TOKEN=[HIDDEN] ... --apikey [HIDDEN] with the raw values appearing zero times in the LOG_DEBUG.

Caveat I'm flagging rather than silently leaving (kept the thread open): because env is passed as /usr/bin/env KEY=VALUE argv tokens, the shared ShellCommand::logCommand still prints the raw values at TRACE level. Fully closing that needs either redaction in shared ShellCommand (all callers) or passing env via the child environment instead of argv — both broader/design-level, left for you.

No master-merge (merge-base b3caf77702b is ~2 days old, well under a week; trial-merge clean). No own-PR approval. All other findings remain as your dismissed/deferred design calls (transactional create/replace/drop, fail-close drop/recovery, replicated + RESTORE materialization, example-driver sandbox hardening, user docs).

As in the previous pushes, the one non-dismissed AI finding is narrow, reviewer-requested, reversible, and happy-path-preserving; happy to revert either commit if you'd prefer a different approach (e.g. resolving the env leak at the ShellCommand/process-env level instead).

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Dear @vdimir, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

alexey-milovidov and others added 3 commits June 24, 2026 05:34
The `query_log` assertion block added to `04241_executable_udf_driver`
used a global `SYSTEM FLUSH LOGS;`, which the `various` style check
(`ci/jobs/scripts/check_style/various_checks.sh`) rejects with
"Please use SYSTEM FLUSH LOGS log_name over global SYSTEM FLUSH LOGS".
The block only reads from `system.query_log`, so flush just that log.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105131&sha=8c28b9ff0ff5bfb268e28ba8b8294bd3ebc6cab1&name_0=PR&name_1=Style%20check

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…drivers

Resolve include-region conflicts in programs/local/LocalServer.cpp and
programs/server/Server.cpp: master added <Functions/pointInPolygon.h>
and this branch added <Functions/UserDefined/UserDefinedSQLFunctionFactory.h>
at the same location; keep both (both are used in each file).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
dynamic_dir.push_back('/');

const String escaped = escapeForFileName(function_name);
const String working_dir = dynamic_dir.empty() ? String() : DriverUtils::readDriverWorkingDirectory(current_context, function_name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DROP FUNCTION needs the persisted .workdir sidecar to run the driver cleanup in the same context that CREATE used. If this file is missing or empty, readDriverWorkingDirectory returns an empty string here, runDropCommand omits env -C, and the drop driver runs from the server's current directory before the code removes the dynamic config and SQL metadata. For DockerC, that makes stop_docker_container derive a different container prefix and exit successfully without removing driver-owned state; after this drop there is no durable metadata left to retry cleanup.

Please fail close when a driver-backed function has no working-directory metadata (or persist enough cleanup state outside the sidecar) before deleting artifacts/SQL metadata.

Startup recovery (`reloadDriverBasedFunctions`) re-runs the driver to rebuild
lost dynamic state and already handles a missing `.workdir` sidecar or working
directory. A *corrupted* sidecar (invalid UUID) was not handled: the recreate
path re-read the same sidecar via `readDriverWorkingDirectory`, which throws on
the invalid UUID before the driver runs, so no replacement config/workdir was
written and the function stayed permanently unavailable.

Make the previous-working-directory read best-effort in
`executeCreateFunctionWithDriver`: the value is only used to clean up the old
artifacts after a successful replace, so an unreadable sidecar is treated as
"no previous working directory" and the fresh config/workdir/sidecar overwrites
the broken state.

Added `04489_executable_udf_driver_invalid_workdir` covering recovery from a
corrupted sidecar.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

/continue-pr 2026-06-29 — pushed 1b69ccd874d..26de57e3ee1.

Fixed the one narrow, non-deferred AI finding (invalid .workdir recovery)

The AI review's recovery Major (UserDefinedSQLFunctionFactory.cpp:350 thread) was a follow-up to the missing-sidecar recovery I already shipped in a38e92acc9a: startup recovery handled a missing .workdir sidecar but not a corrupted one. When the sidecar held an invalid UUID, reloadDriverBasedFunctions correctly decided to recreate, but the recreate path re-read the same sidecar via readDriverWorkingDirectory, which threw on the invalid UUID before the driver ran — so no replacement config/workdir was written and the function stayed permanently unavailable.

Fix: executeCreateFunctionWithDriver now reads the previous working directory best-effort. That value is only used to clean up the old artifacts after a successful replace, so an unparseable sidecar is treated as "no previous working directory" rather than aborting the recreate; the fresh config/workdir/sidecar written below overwrites the broken state. Added 04489_executable_udf_driver_invalid_workdir (corrupt the sidecar with an invalid UUID + drop the working dir → function is recreated, callable, and the sidecar is restored to a valid UUID). Thread resolved.

Verified the changed TU compiles clean (-fsyntax-only -Werror against the repointed compile_commands.json); the feature isn't in the local build/ binary, so the end-to-end 04489 runs in CI.

No re-merge

The branch was merged with master earlier today (1b69ccd8, ~5h ago, well under a week) and CI is green on it; a trial merge of current master is clean (no conflicts), so I did not re-merge.

Deferred (unchanged — author design decisions)

The remaining AI Blockers/Majors are the same architectural and product decisions left open on this experimental, default-off feature: transactional create/replace/drop artifact handling, fail-close drop_command/reload/recovery, RESTORE materialization, the example-driver sandbox model (DockerC writable mount, GVisorC limits), the ShellCommand-level TRACE env/argument leak (needs a shared-ShellCommand or child-environment change), and user documentation. These remain your calls and are untouched.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

/continue-pr 2026-06-30 — no code change, no master re-merge.

CI

Everything is green except one job: Fast test (arm_darwin), failing on 03135_keeper_client_find_commands. This is an unrelated macOS-ARM runner flake, not caused by this PR (which touches no Keeper code):

  • CIDB shows 03135_keeper_client_find_commands failing only on Fast test (arm_darwin), across ~13 unrelated PRs in the last 14 days (e.g. #107826, #107480, #108148, #108765, #108072, #108833, #104965) — a recurring environment-specific flake on the macOS-ARM Fast-test runner.
  • I re-ran the failed job (run 28410063605).

There is no open tracking issue for it. @groeneai, please investigate the flaky 03135_keeper_client_find_commands on Fast test (arm_darwin) and provide a fix in a separate PR; if a fix is already in progress, link it here.

CH Inc sync is green. The Cloud Performance report's single flagged query (Q32 +31%) is off the changed path (the feature is experimental and disabled by default, the standard query path is untouched); the AI verdict itself recommends a re-run rather than treating it as a real regression.

Why no re-merge

The branch is behind master by 250 commits, but the merge-base (f442bc039c2, 2026-06-29 17:58 UTC) is less than a day old, and the sole red is an unrelated flake that a merge would not fix — so re-merging is not warranted.

Review threads

The AI review verdict is ❌ Block, but every finding is marked [dismissed by author] — they are the deferred architectural decisions for this experimental, disabled-by-default feature (transactional create/replace/drop, deterministic recovery/reload/restore, sandbox hardening of the example DockerC/GVisorC drivers, and user documentation). The remaining human-reviewer threads (@vdimir, @antonio2368) are from May/early June, already have replies, and cover the same deferred design surface. The one narrow non-deferred finding (corrupted .workdir recovery) was fixed in the previous push (26de57e3ee1, test 04489).

No new actionable, non-deferred items remain. Blocked only on the maintainer decision on the deferred design items and the arm_darwin flake re-run.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Fix already in progress: #107438 (open, approved by @ alesapin). Tracked since #100651.

Root cause: on macOS, shutdown() on an already-disconnected socket returns ENOTCONN (errno 57), which Poco::Net::SocketImpl::shutdown() turns into NetException("Socket is not connected"). Coordination::ZooKeeper::finalize() catches it and logs via tryLogCurrentException at ERROR, and keeper-client query mode routes ERROR to stderr, so the benign teardown noise lands on stderr at process exit. The command output is correct, but Fast-test treats any stderr as a failure, which is why it fails only on Fast test (arm_darwin) (0 master hits, ~13 unrelated PRs with one hit each).

#107438 downgrades only the ENOTCONN case to TRACE at both socket.shutdown() catch sites (finalize teardown and the connect-failure cleanup path), keeping ERROR for every other shutdown error, mirroring the existing HTTPServerConnection.cpp precedent.

Adds a "Driver-based Executable User Defined Functions" section to
`docs/en/sql-reference/functions/udf.md`, documenting the new public SQL
and configuration surface introduced by this feature:

- the experimental gate (`allow_experimental_executable_udf_drivers`) and
  the `user_defined_executable_function_drivers_config` /
  `dynamic_user_defined_executable_functions_path` configuration keys,
- the driver configuration schema (`name`, `create_command`,
  `drop_command`, `engine_arguments`, `env`),
- the driver invocation contract (`--name`/`--return`/`--args`, declared
  engine arguments, code body on stdin, generated config on stdout with
  XML/YAML auto-detection),
- the `CREATE FUNCTION ... ENGINE = DriverName(...) AS '...'` and
  `DROP FUNCTION` lifecycle,
- persistence as `ATTACH FUNCTION` and restart recovery,
- limitations (experimental, non-replicated storage, `RESTORE` not
  re-running the driver),
- the proof-of-concept `DockerC`/`GVisorC`/`UnsafeC` example drivers and
  their not-installed-by-packages status.

This addresses the missing-documentation review feedback for the new
feature.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

continue-pr status (automated pass)

Action taken: Added the missing user documentation for the feature — pushed 7215a3e38ad, which adds a "Driver-based Executable User Defined Functions" section to docs/en/sql-reference/functions/udf.md and checks the documentation box in the PR description. It covers the driver config schema, the driver invocation contract, the CREATE/DROP lifecycle, the experimental gate, persistence/restart recovery, the limitations (experimental, non-replicated storage, RESTORE not re-running the driver), and the DockerC/GVisorC/UnsafeC examples. This addresses the documentation finding (r3428342102).

CI: Fully green — the PR report shows 151 passed / 0 failed / 19 skipped, and CH Inc sync, Mergeable Check, and Style check are all SUCCESS. State is MERGEABLE / CLEAN. Merge-base is from 2026-06-29, so no re-merge with master is needed.

AI Review verdict (❌ Block): Every blocker and major in the verdict is marked [dismissed by author] with a linked discussion — these are deliberate design decisions for an experimental, disabled-by-default feature (non-transactional artifact handling, fail-open cleanup, example-sandbox tradeoffs, RESTORE/reload recovery, trace-log redaction). I did not override them. Now that docs are added, the verdict's only un-dismissed required action is covered.

Open human-reviewer threads left for your/the reviewer's call (both predate substantial code evolution and @vdimir was unassigned for inactivity):

  • src/Interpreters/Context.cpp:1893 — @vdimir asked for guardrails against a misconfigured path in remove_all(working_dir). The working directory is now a generated UUID under the dynamic path, which mitigates the "arbitrary file matching function name" concern, but the question is still formally open.
  • programs/server/config.xml:1626 — @vdimir asked whether <user_defined_executable_function_drivers_config> should be enabled in the example config by default. The key is active, but harmless by default (example drivers are not packaged and the feature is gated off).

No further code changes were made beyond the documentation. Ready for your review/merge decision.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Clarification on the docs commit: the documentation finding (r3428342102) was itself marked [dismissed by author] in the AI verdict, so strictly it was already a dismissed item, not an open one — my note above was imprecise on that point.

I added the docs anyway because documentation is mandatory for a new feature per the project conventions, and it is purely additive (one isolated commit touching only docs/en/sql-reference/functions/udf.md). If you'd rather author the user docs yourself in your own structure, feel free to revert 7215a3e38ad and uncheck the box — no other change depends on it.

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.50% +0.10%
Functions 92.70% 92.70% +0.00%
Branches 77.70% 77.70% +0.00%

Changed lines: Changed C/C++ lines covered: 785/1022 (76.81%) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

/continue-pr 2026-07-01 — no code change, no master re-merge, no rerun possible yet.

Public CI

Fully green on the current head 7215a3e38ad: the PR report shows 151 passed / 0 failed / 19 skipped, and Style check, Mergeable Check, and PR are all SUCCESS (run 28468460820, completed). The arm_darwin 03135_keeper_client_find_commands flake noted in the previous pass is gone on this head.

CH Inc sync — pending, only a known flake failing

The public CH Inc sync status is pending because the private sync run for this head is still in progress. The sync PR (clickhouse-private#59300) is MERGEABLE/UNSTABLE: it builds clean with no conflicts. Its only failures are the two amd_tsan stress jobs:

  • Stress test (amd_tsan, meta in keeper) and Stress test (amd_tsan, SharedCatalog, meta in keeper) — both FAILURE.
  • Every other stress build on the same sync run passes: amd_debug, amd_msan, arm_asan_ubsan (both meta in keeper and SharedCatalog variants).

Only the TSan variants fail, which is the signature of the chronic Hung check failed, possible deadlock found flake (#107941, open). This is unrelated to the PR: the feature is experimental and disabled by default, so its driver code paths do not run in the stress suite, and a real regression would not fail exclusively under TSan while every other sanitizer build is green. The job's "Dirty repo state" files (short_short.txt, long_short.txt, etc.) come from the unrelated 01903_http_fields.sh, not from this PR's tests.

The 14 Cloud integration jobs (amd_asan_ubsan, db disk ± old analyzer) are still IN_PROGRESS on that run, so I could not rerun --failed the flaky stress jobs yet — that has to wait until the run completes.

Why no re-merge

Merge-base f442bc039c2 is 2026-06-29 17:58 UTC (~1.5 days, well under a week), the branch is MERGEABLE with no conflicts, and public CI is green. The behind-count is just master velocity; a re-merge would not fix the TSan flake, so it is not warranted.

Review threads

The AI verdict is still ❌ Block, but every blocker and major is [dismissed by author] — the deferred architectural/product decisions for this experimental, default-off feature (transactional create/replace/drop, fail-close drop/reload/recovery, RESTORE materialization, the example DockerC/GVisorC sandbox model, and the ShellCommand-level TRACE env/argument redaction). The verdict's own minimum-required-actions text allows these to be "explicitly accepted by the owning maintainers as an experimental-risk tradeoff", which is your call. The human threads (@vdimir, @antonio2368) predate substantial code evolution and already have replies; @vdimir's "why can we ignore Segmentation fault" was already addressed by removing that filter in 5576b9ed5bd (that thread just wasn't resolved).

No new actionable, non-deferred items remain. Blocked only on the maintainer decision on the deferred design items, the flaky amd_tsan stress rerun once the sync run completes, and human approval / merge.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 1, 2026
Merged via the queue into master with commit 1f3d1e8 Jul 1, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the add-executable-udf-drivers branch July 1, 2026 06:08
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
@rienath rienath linked an issue Aug 3, 2026 that may be closed by this pull request
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
`UserDefinedExecutableFunctionDriverInvoker` logged the fully expanded
`/usr/bin/env ...` command line at debug level via `DirectCommand::describe`,
which included every driver `env` `KEY=VALUE` entry and every engine
argument value. Driver `env` values and engine-argument values are an
operator/user-facing surface that can carry credentials or tokens, so
this leaked secrets into the server log whenever debug logging was on.

Build the logged form with the values replaced by `[HIDDEN]` while keeping
the variable/argument names and the non-secret structural arguments
visible. The arguments actually passed to the driver keep the real values
and are never logged.

Addresses review feedback: ClickHouse#105131 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…df-drivers

Drivers for executable user-defined functions
@alexey-milovidov alexey-milovidov mentioned this pull request Sep 20, 2026
47 of 72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drivers for User-Defined Functions

5 participants