I have a table with a ROW type column that looks like this:
struct<something:double,something_else:double,another_thing:boolean>
So, an actual row of this column in the table looks like this:
{ "something":1.0, "something_else":2.0, "another_thing":false }
I would like to select all of the field names (in this example, something, something_else, another_thing
) either as an array or as rows in the results set.
For example, assuming a table t
and a column name of things
I've tried:
select MAP_FROM_ENTRIES(things) from t limit 1
This gives an "unexpected parameters" error. Same goes for MULTIMAP_FROM_ENTRIES
I also tried
cast(things as JSON) from t limit 1
This gives me the field values rather than the names.
Additionally, I tried using UNNEST()
but this doesn't seem right either.
Using LIMIT 1
seems very hack-y and since the names are built in to the table itself I thought using SHOW COLUMNS
or DESCRIBE OUTPUT
might be able to do this, but I've had no luck.
This seems like it should be a rather simple operation...what am I missing?
Aucun commentaire:
Enregistrer un commentaire