跳转到主要内容

描述

包含用户自定义函数 (UDF) 的加载状态、错误信息和配置元数据。

  • name (String) — UDF 名称。
  • load_status (Enum8(‘Success’ = 0, ‘Failed’ = 1)) — 加载状态。可能的值:
    • Success — UDF 已加载并可使用
    • Failed — UDF 加载失败 (详见字段 ‘loading_error_message’) 。
  • loading_error_message (String) — 加载失败时的详细错误信息。若加载成功则为空。
  • last_successful_update_time (Nullable(DateTime)) — 最近一次成功更新的时间戳。若从未成功则为 NULL。
  • loading_duration_ms (UInt64) — 加载 UDF 所耗费的时间,单位为毫秒。
  • type (Enum8(‘executable’ = 0, ‘executable_pool’ = 1)) — UDF 类型:‘executable’ (单进程) 或 ‘executable_pool’ (进程池) 。
  • command (String) — 此 UDF 要执行的脚本或命令。
  • format (String) — I/O 数据格式 (例如 ‘TabSeparated’、‘JSONEachRow’) 。
  • return_type (String) — 函数返回类型 (例如 ‘String’、‘UInt64’) 。
  • return_name (String) — 可选的返回值标识符。若未配置则为空。
  • argument_types (Array(String)) — 参数类型的 Array (例如 [‘String’, ‘UInt64’]) 。
  • argument_names (Array(String)) — 参数名称的 Array。未命名参数对应空字符串。
  • max_command_execution_time (UInt64) — 处理一个数据块的最长时间 (秒) 。仅适用于 ‘executable_pool’ 类型。
  • command_termination_timeout (UInt64) — 向命令进程发送 SIGTERM 前等待的秒数。
  • command_read_timeout (UInt64) — 从命令 stdout 读取的超时时间,单位为毫秒。
  • command_write_timeout (UInt64) — 向命令 stdin 写入的超时时间,单位为毫秒。
  • pool_size (UInt64) — 命令进程实例数量。仅适用于 ‘executable_pool’ 类型。
  • send_chunk_header (UInt8) — 是否在每个数据 chunk 前发送行数 (布尔值) 。
  • execute_direct (UInt8) — 是否直接执行命令 (1) ,还是通过 /bin/bash 执行 (0) 。
  • lifetime (UInt64) — 重新加载间隔,单位为秒。0 表示禁用重新加载。
  • deterministic (UInt8) — 对于相同参数,函数是否返回相同结果 (布尔值) 。

示例

查看所有 UDF 及其加载状态:
SELECT
    name,
    load_status,
    type,
    command,
    return_type,
    argument_types
FROM system.user_defined_functions
FORMAT Vertical;
Row 1:
──────
name:           my_sum_udf
load_status:    Success
type:           executable
command:        /var/lib/clickhouse/user_scripts/sum.py
return_type:    UInt64
argument_types: ['UInt64','UInt64']
查找失败的 UDF:
SELECT
    name,
    loading_error_message
FROM system.user_defined_functions
WHERE load_status = 'Failed';

另请参阅

最后修改于 2026年6月25日