title: Assign value of a column to variable in sql use jinja template language
body: <p>I have a sql file like this to transform a table has a column include a json string</p>
  <pre><code>{{ config(materialized='table') }}
  
  with customer_orders as (
    select
      time,
      data as jsonData,
  
  {% set my_dict = fromjson( jsonData ) %}
  {% do log(&quot;Printout: &quot; ~ my_dict, info=true) %}
  
    from `warehouses.raw_data.customer_orders`
  
    limit 5
  )
  
  select *
  from customer_orders
  </code></pre>
  <p>When I run <code>dbt run</code>, it return like this:</p>
  <pre><code>Running with dbt=0.21.0
  Encountered an error:
  the JSON object must be str, bytes or bytearray, not Undefined
  </code></pre>
  <p>I even can not print out the value of column I want:</p>
  <pre><code>
  {{ config(materialized='table') }}
  
  with customer_orders as (
    select
      time,
      tag,
      data as jsonData,
  
  {% do log(&quot;Printout: &quot; ~ data, info=true) %}
  
    from `warehouses.raw_data.customer_orders`
  
    limit 5
  )
  
  select *
  from customer_orders
  </code></pre>
  <pre><code>22:42:58 | Concurrency: 1 threads (target='dev')
  22:42:58 | 
  Printout: 
  22:42:58 | Done.
  
  </code></pre>
  <p>But if I create another model to printout the values of jsonData:</p>
  <pre><code>{%- set payment_methods = dbt_utils.get_column_values(
      table=ref('customer_orders_model'),
      column='jsonData'
  ) -%}
  
  {% do log(payment_methods, info=true) %}
  
  {% for json in payment_methods %}
  {% set my_dict = fromjson(json) %}
  {% do log(my_dict, info=true) %}
  {% endfor %}
  
  </code></pre>
  <p>It print out the json value I want</p>
  <pre><code>Running with dbt=0.21.0
  This is log
  
  Found 2 models, 0 tests, 0 snapshots, 0 analyses, 372 macros, 0 operations, 0 seed files, 0 sources, 0 exposures
  
  21:41:15 | Concurrency: 1 threads (target='dev')
  21:41:15 |
  
  ['{&quot;log&quot;: &quot;ok&quot;, &quot;path&quot;: &quot;/var/log/containers/...log&quot;, &quot;time&quot;: &quot;2021-10-26T08:50:52.412932061Z&quot;, &quot;offset&quot;: 527, &quot;stream&quot;: &quot;stdout&quot;, &quot;@timestamp&quot;: 1635238252.412932}']
  
  {'log': 'ok', 'path': '/var/log/containers/...log', 'time': '2021-10-26T08:50:52.412932061Z', 'offset': 527, 'stream': 'stdout', '@timestamp': 1635238252.412932}
  
  21:41:21 | Done.
  </code></pre>
  <p>But I want to process this jsonData with in a model file like <code>customer_orders_model</code> above.</p>
  <p>How can I get value of a column and assign it to a variable and continue to process whatever I want (check if in json have a key I want and set it value to new column).</p>
  <p>Notes: <code>My purpose is that: In my table, has a json string column, I want extract this json string column into many columns so I can easily write sql query what I want.</code></p>