gugoen opened a new issue, #34579: URL: https://github.com/apache/doris/issues/34579
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version 2.1 ### What's Wrong? After updating from 2.0 to 2.1, I found that using a normal SQL statement would result in an error. I simplified the error logic in one SQL statement, and the main issue with the error is that using json_parse in a case when statement would throw an exception. The following SQL (Case-1): ```sql with a as ( select '101' id, 'a' as v_key, '{"k":"k1","v":"v1"}' v_json union all select '101' id, 'a' as v_key, '{"k":"k2","v":"v2"}' v_json union all select '101' id, 'b' as v_key, '{"k":"k3","v":"v3"}' v_json union all select '101' id, 'c' as v_key, '{"k":"k4","v":"v4"}' v_json union all select '102' id, 'a' as v_key, '{"k":"k5","v":"v5"}' v_json ) SELECT id, CASE v_key WHEN 'a' THEN JSON_PARSE_ERROR_TO_NULL( CONCAT( '[', CONCAT_WS( ',', SPLIT_BY_STRING( v_json, '|+|' )), ']' )) ELSE NULL END AS a, CASE v_key WHEN 'b' THEN JSON_PARSE_ERROR_TO_NULL( CONCAT( '[', CONCAT_WS( ',', SPLIT_BY_STRING( v_json, '|+|' )), ']' )) ELSE NULL END AS b FROM a ; ``` Throw exception: ```bash > 1105 - errCode = 2, detailMessage = (172.16.128.95)[INTERNAL_ERROR]Function if get failed, expr is VectorizedFnCall[if](arguments=VectorizedFnCall[eq](arguments=String, String,return=UInt8), VectorizedFnCall[jsonb_parse_error_to_null](arguments=VectorizedFnCall[concat](arguments=String, VectorizedFnCall[concat_ws](arguments=String, VectorizedFnCall[split_by_string](arguments=String, String,return=Array(Nullable(String))),return=String), String,return=String),return=Nullable(JSONB)), Nullable(JSONB),return=Nullabl ``` You can remove the CONCAT statement and simplify it as follows (Case-2): ```sql with a as ( select '101' id, 'a' as v_key, '{"k":"k1","v":"v1"}' v_json union all select '101' id, 'a' as v_key, '{"k":"k2","v":"v2"}' v_json union all select '101' id, 'b' as v_key, '{"k":"k3","v":"v3"}' v_json union all select '101' id, 'c' as v_key, '{"k":"k4","v":"v4"}' v_json union all select '102' id, 'a' as v_key, '{"k":"k5","v":"v5"}' v_json ) SELECT id, CASE v_key WHEN 'a' THEN JSON_PARSE(v_json) ELSE NULL END AS a, CASE v_key WHEN 'b' THEN JSON_PARSE(v_json) ELSE NULL END AS b FROM a ; ``` Still throwing exceptions: ```bash > 1105 - errCode = 2, detailMessage = (172.16.128.97)[INTERNAL_ERROR]Function if get failed, expr is VectorizedFnCall[if](arguments=VectorizedFnCall[eq](arguments=String, String,return=UInt8), VectorizedFnCall[jsonb_parse](arguments=String,return=JSONB), Nullable(JSONB),return=Nullable(Decimal(27, 9))) and return type is Nullable(Decimal(27, 9)). ``` The same SQL can run normally in 2.0, and the output of case-1 is as follows: ```sql +-----+-----------------------+-----------------------+ | id | a | b | +-----+-----------------------+-----------------------+ | 101 | [{"k":"k1","v":"v1"}] | NULL | | 101 | [{"k":"k2","v":"v2"}] | NULL | | 101 | NULL | [{"k":"k3","v":"v3"}] | | 101 | NULL | NULL | | 102 | [{"k":"k5","v":"v5"}] | NULL | +-----+-----------------------+-----------------------+ 5 rows in set (0.11 sec) ``` ### What You Expected? Solve it ### How to Reproduce? _No response_ ### Anything Else? _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
