Hi Pinot team. Can I create like below data using ...
# troubleshooting
u
Hi Pinot team. Can I create like below data using select SQL? (json array)
Copy code
[{"type": "baseball"}, {"type": "soccer"}]
Copy code
For example,
SELECT 
    ARRAY(
        MAKE_JSON_DATA('type', 'baseball'),
        MAKE_JSON_DATA('type', 'soccer')
    )
b
Hello. What's the goal ? ARRAY creates an array of a given type (aka multi value
column
), e.g.
Copy code
select arrayIndexOfString( ARRAY('a', 'b', 'c'), 'c' ) from dual;
returns 2. You could, in theory, create an array of JSON type but I believe it'd basically be an array of strings :
Copy code
select array(cast( '{ "key": "value"}' as json )) as js_arrr from dual;
u
At first, Thank you so much. My client wants a JSON array data. By the way, The query
select cast('{ "key": "value"}' as json) from dual
works in a non-multi-stage environment but does not work in a multi-stage environment. Additionally, the query
select array(cast('{ "key": "value"}' as json)) as js_arr from dual;
does not work either. Could you provide more help?
b
I might be wrong but I don't think there are functions that'd facilitate creation of a json string (like to_json or json_build_array in PG https://www.postgresql.org/docs/15/functions-json.html#FUNCTIONS-JSON-PROCESSING), so json would need to be created with string functions . Feel free to request such functions at https://github.com/apache/pinot/issues .
u
When unpacking an array, I use
arrayToMv
as mentioned in the documentation you provided. I want to create array(json) when select SQL.