title: Snowflake how can we run an unpivot query over an array of fields instead of explicitly declare each field?
body: <p>I need to unpivot a table using fields specified in an array. I have the following query:</p>
  <pre><code>select
      *
  FROM
      TEMP_TABLE_NAME T unpivot (
          val_col for name_col in (
              array_of_fields
          )
      );
  </code></pre>
  <p>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.</p>
  <p>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 <code>in</code> clause of the <code>unpivot</code>. The query works fine when we specify some fields.</p>