DB::Exception

猿猿的脑袋 猿猿的脑袋 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

在使用clickhouse的UDF函数时,报错: 

DB::Exception: Function 'code_line_count_v2': wrong result, expected 1 row(s), actual 0: While processing code_line_count_v2('111'). (UNSUPPORTED_METHOD) (version 22.8.17.17 (official build))

如下是我的Java脚本:

public static void main(String[] args) {
        //单字符串
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            CodeLineCountV2 codeLineCountV2 = new CodeLineCountV2();
            String markdown;
            while (!(markdown = in.readLine()).isEmpty()) {
                JSONObject jsonObject = JSON.parseObject(markdown);
                Integer result = codeLineCountV2.evaluate(jsonObject.getString("markdown"));
                JSONObject object = new JSONObject();
                object.put("result", result);
                System.out.print(object.toJSONString());
                System.out.flush();
            }
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

如下是我的function脚本code_line_count_v2_function.xml

<functions>
    <function>
        <type>executable</type>
        <name>code_line_count_v2</name>
        <return_type>UInt32</return_type>
        <return_name>result</return_name>
        <argument>
            <type>String</type>
            <name>markdown</name>
        </argument>
        <format>JSONEachRow</format>
        <execute_direct>0</execute_direct>
        <command>java -jar /var/lib/clickhouse/user_scripts/function_code_line_count_v2_udf.jar</command>
    </function>
</functions>

而且脚本里的command里的执行脚本可以在服务器的任意位置执行。

通过如下语句执行函数的刷新和函数执行,第三步报了标题的错:

SYSTEM RELOAD FUNCTIONS;
SELECT * FROM system.functions WHERE name = 'code_line_count_v2';
select code_line_count_v2('111');

麻烦有经验的帮忙看下是什么原因

...全文
评论
收藏 已收藏
分享
返回顶部