Pass a string into a model

The problem I’m having

I want to create a model in a schema related to a customer id -e.g. FOO1_BAR_LND where FOO1 is the customer ID. I also want to pass this customer ID into a column in the view

I have at the moment
{%set customer='FOO1' %}
{{ config(schema=customer+'_BAR_LND') }}

and this works ok to create the schema FOO1_BAR_LND and creates the view in there

But when I want to put ‘FOO1’ into the model itself
, {{customer}} as FOO_CUSTOMER_BKCC

the compiler puts
, FOO1 as FOO_CUSTOMER_BKCC
rather than
'FOO1' as FOO_CUSTOMER_BKCC

What am I missing here! I am new to this so trying to get my head around how the yaml works.

Quote it in the model SQL:
, '{{customer}}' as FOO_CUSTOMER_BKCC

Note: @Owen originally posted this reply in Slack. It might not have transferred perfectly.

ah, you mean outside the curly brackets {{}} so
,'{{customer}}' as FOO_CUSTOMER_BKCC
gives
'FOO1' as FOO_CUSTOMER_BKCC

that works :). thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.