111
社区成员




在使用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');
麻烦有经验的帮忙看下是什么原因