Search code examples
jinja2dbt

Concatenating a variable in Jinja with a single quote


I'm having trouble trying to concatenate variables (one with a single quote) in Jinja. My code looks like this:

{%- set my_quote = "'" -%}
{%- set invocation =  invocation_id -%}

And the output I'm attempting is this:

{{ invocation ~ my_quote }}

The output from this is:

f21f9039-44e5-452f-8d7a-ee64245ada23'

Ok great! Now when I attempt to add the single quote to the beginning as well:

{{ my_quote ~ invocation ~ my_quote }}

The output is the invocation variable value without any single quotes:

f21f9039-44e5-452f-8d7a-ee64245ada23

How can I get this to output both single quotes properly?


Solution

  • Try the following:

    "'{{ invocation_id }}'"