You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had searched in the issues 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):
with a as (
select'101' id, 'a'as v_key, '{"k":"k1","v":"v1"}' v_json union allselect'101' id, 'a'as v_key, '{"k":"k2","v":"v2"}' v_json union allselect'101' id, 'b'as v_key, '{"k":"k3","v":"v3"}' v_json union allselect'101' id, 'c'as v_key, '{"k":"k4","v":"v4"}' v_json union allselect'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:
> 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):
with a as (
select'101' id, 'a'as v_key, '{"k":"k1","v":"v1"}' v_json union allselect'101' id, 'a'as v_key, '{"k":"k2","v":"v2"}' v_json union allselect'101' id, 'b'as v_key, '{"k":"k3","v":"v3"}' v_json union allselect'101' id, 'c'as v_key, '{"k":"k4","v":"v4"}' v_json union allselect'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:
> 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 returntype is Nullable(Decimal(27, 9)).
The same SQL can run normally in 2.0, and the output of case-1 is as follows:
Search before asking
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):
Throw exception:
You can remove the CONCAT statement and simplify it as follows (Case-2):
Still throwing exceptions:
The same SQL can run normally in 2.0, and the output of case-1 is as follows:
What You Expected?
Solve it
How to Reproduce?
No response
Anything Else?
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: