跳转到主内容
跳转到主内容

system.user_defined_functions

描述

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

  • 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)) — 参数类型数组 (例如 ['String', 'UInt64']) 。
  • argument_names (Array(String)) — 参数名称数组。未命名的参数对应空字符串。
  • 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) — 是否在每个数据块前发送行数 (布尔值) 。
  • 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';

另请参阅