11

I'm running a query with a

select bar_tbl.thing1
from foo
cross join unnest(bar) as t(bar_tbl)

And got the error Error Query failed: Cannot unnest type: row

Why?

The bar column looks like this {thing1=abc, thing2=def}

Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82
sshevlyagin
  • 1,310
  • 2
  • 16
  • 26

1 Answers1

14

Turns out I was trying to expand a row, which doesn't make sense. I should have just done

select bar.thing1
from foo
sshevlyagin
  • 1,310
  • 2
  • 16
  • 26
  • 4
    Any idea how to get ALL values in the row structure as columns (without specifying every single element)? For example, let's say I have a row structure with 20 elements, and I want to expand each into its own column (hopefully named as the key in the row). How can I do that? Thanks! – Ward W Jul 26 '18 at 18:26
  • 1
    Sorry, I'm not sure – sshevlyagin Aug 07 '18 at 17:19
  • I'm facing the same issue. did you managed to find a solution? @wardw123 – shlomiLan Oct 05 '21 at 10:55