# \[core v1.3.2\] Different variable behavior exhibited using same implementation between macro and model

**URL:** <https://discourse.getdbt.com/t/core-v1-3-2-different-variable-behavior-exhibited-using-same-implementation-between-macro-and-model/8409>\
**Category:** Help\
**Tags:** jinja\
**Created:** [May 24, 2023, 1:56am UTC](https://discourse.getdbt.com/t/core-v1-3-2-different-variable-behavior-exhibited-using-same-implementation-between-macro-and-model/8409 "2023-05-24T01:56:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Turbine](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/turbine/32/2454_2.png) [@Turbine](https://discourse.getdbt.com/u/Turbine)\
**Post date:** [May 24, 2023, 1:56am UTC](https://discourse.getdbt.com/t/core-v1-3-2-different-variable-behavior-exhibited-using-same-implementation-between-macro-and-model/8409/1 "2023-05-24T01:56:03Z")

</div>

I’ve having quite a lot of trouble running seemingly valid Jinja code.

## The problem I’m having

When I try to return the first element in a list or access data from the model’s schema - it appears to contain the data for printing, but not accessing.

## The context of why I’m trying to do this

Context 1) Retrieve a column meeting certain criteria in the schema.  
Context 2) Access a field’s value from the model’s schema and use it to reference a model.

## What I’ve already tried (simplified example which exhibits the same issue)

Example 1)

```auto
{%- set column = model.columns.values() | first -%}

{{ column }} /* Works, displaying an object "{'name': '_object_key', 'description'..." */
{{ column.name }} /* Errors only if it's within in a macro */

```

Example 2)

```auto
  {{model.meta.raw_model_name }} /* Works, prints out full string */
  from {{ ref(model.meta.raw_model_name) }} /* Errors, in both model and macro, seems to be undefined. Writing the same result as printed out above as a string does work. */

```

## Some example code or error messages

Error 1)

> Compilation Error in model refined\_…(models\Refined\refined\_…sql)  
> No first item, sequence was empty.
> 
> > in macro transform\_… (macros\transform\_…)  
> > called by model refined\_… (models\Refined\wms\_ctd\refined\_…sql)

Error 2)

> Compilation Error in model refined\_… (models\Refined\wms\_ctd\refined\_…sql)  
> The name argument to ref() must be a string, got \<class ‘jinja2.runtime.Undefined’\>
> 
> > in macro transform\_… (macros\transform\_…sql)  
> > called by model refined\_wms\_ctd\_dbo\_pckwrk\_dtl (models\Refined\refined\_…sql)

Are there some Jinja limitations I should be aware of, or have I stumbled upon a bug? Both of my issues seem likely to share the same root cause.
