I have field of type array that contains multiple structs. On of its values look like this:
[{"code":"3","other_field":true,"interesting_field":false},{"code":"2","other_field":true,"interesting_field":true}]
So I would need to build multiple columns from this one, containing the value of interesting_field
. In the explained example I would have the following:
code_1 | code_2 | code_3
null | true |false
I know I have a fixed number of columns, but I don’t know how to figure out how to perform this transformation. Tried with extract and unnest without luck, also with regular expresions, or converting to string.
Actually, my best approach is to extract by position 0,1,2, … into especific columns and after that extract interesting_field
into the end column (so position [0]['interesting_field']
will go to code_3
field), but this does not work if for example I only have a code_1 struct…
Please, could you help me?
Thank you