I need to unpivot a table using fields specified in an array. I have the following query:
select
*
FROM
TEMP_TABLE_NAME T unpivot (
val_col for name_col in (
array_of_fields
)
);
The issue is that our data is dynamic, we might receive data having 10 fields, or 100 fields depending on the survey we need to upload into Snowflake.
So instead of explicitly declare fields that I need to use, I exported the fields into an array and I need to use them inside the in
clause of the unpivot
. The query works fine when we specify some fields.