Angryshark128 opened a new issue, #14374:
URL: https://github.com/apache/druid/issues/14374
### Affected Version
26.0.0
### Description
`
with nested_data as (
SELECT
JSON_OBJECT('k1':ARRAY['v1','v2'],'k2':'v3','k3':4) json_arr
)
SELECT
JSON_VALUE(json_arr,'$.k1') k1,
JSON_VALUE(json_arr,'$.k1' RETURNING VARCHAR ARRAY) k1_string_arr,
JSON_VALUE(json_arr,'$.k1' RETURNING INTEGER ARRAY) k1_int_arr,
JSON_VALUE(json_arr,'$.k2') k2,
JSON_VALUE(json_arr,'$.k2' RETURNING VARCHAR ARRAY) k2_string_arr,
JSON_VALUE(json_arr,'$.k2' RETURNING INTEGER ARRAY) k2_int_arr,
JSON_VALUE(json_arr,'$.k3') k3,
JSON_VALUE(json_arr,'$.k3' RETURNING VARCHAR ARRAY) k3_string_arr,
JSON_VALUE(json_arr,'$.k3' RETURNING INTEGER ARRAY) k3_int_arr
from nested_data
`
When i want to extract values from a json object ( SQL as above ), it will
get some unexpected and weird values.
In order to understand more easily, the object can be equivalent to json as
below:
`
{
"k1": [
"v1",
"v2"
],
"k2": "v3",
"k3": 4
}
`
What i expect is as below:
#1 - `JSON_VALUE(json_arr,'$.k1')` = `['v1','v2']`, actual is `empty`
#2 - `JSON_VALUE(json_arr,'$.k1' RETURNING VARCHAR ARRAY)` = `['v1','v2']`,
actual is `null`
#3 - `JSON_VALUE(json_arr,'$.k2' RETURNING VARCHAR ARRAY)` = `null`, actual
is `['v3']`
#4 - `JSON_VALUE(json_arr,'$.k2' RETURNING INTEGER ARRAY)` = `null`, actual
is `[null]`
#5 - `JSON_VALUE(json_arr,'$.k3' RETURNING VARCHAR ARRAY)` = `null`, actual
is `['4']`
#6 - `JSON_VALUE(json_arr,'$.k3' RETURNING INTEGER ARRAY)` = `null`, actual
is `[4]`
I can understand results of #3#4#5#6 might be converted for type implicitly,
but what's the cause for #1 and #2?
--
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]