ClickHouse / ClickHouse

ClickHouse® is a real-time analytics DBMS
https://clickhouse.com
Apache License 2.0
37.36k stars 6.88k forks source link

DB::Exception:wrong result, expected 1 row(s), actual 0 #71001

Open ggww opened 3 days ago

ggww commented 3 days ago

Company or project name

No response

Question

when i used the clickhouse function to implement complex calculations,the function get error message: 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))

and i can not get the reference valid answers in issues.

the below is related code:

the function implements with java language: 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 script: code_line_count_v2_function.xml `

executable code_line_count_v2 UInt32 result String markdown JSONEachRow 0 java -jar /var/lib/clickhouse/user_scripts/function_code_line_count_v2_udf.jar

`

the command instruction in the script can run anywhere the server. the below sql script is successful to execute in clickhouse: SYSTEM RELOAD FUNCTIONS; SELECT * FROM system.functions WHERE name = 'code_line_count_v2';

Algunenano commented 3 days ago

when i used the clickhouse function to implement complex calculations,the function get error message: 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))

and i can not get the reference valid answers in issues.

This error means that CH sent 1 row to the UDF, so it expected to get one row back, but it got 0 rows back.

Please make sure your function returns exactly one row of output per one row of input. Empty rows cannot be ignored.