I have the following data in a json format
create table events (
id_user bigint,
experiments ARRAY <
STRUCT <
id: BIGINT,
impressed: BOOLEAN,
variantId: BIGINT
>
>
)
describe events
returns:
columns | types
id_user | bigint
experiments | array(row(id bigint, impressed boolean, variantid bigint))
I want to unnest the array struct with the following command
select CAST(ROW(array[experiments]) AS ROW(id BIGINT, impressed boolean, variantid bigint)) as test
from events
and presto returns the following error: failed: the size of fromType and toType must match
When I enter dummy data in the array the command runs smoothly.
What is the problem and how i overcome it?
This:
constructs a
ROW
with one field, of type "array
ofrow
"If you want to
unnest
the array, you want something like that:(for older Presto versions use
CROSS JOIN
instead ofLEFT JOIN .. ON true
; mind that this changes semantics)