SQL headers allow you to manipulate the current session settings, such as roles and timezones, or create functions, directly within your asset's run session.
{{ config(
sql_header="alter session set timezone = 'Europe/London';"
) }}
{% call set_sql_header(config) %}
create or replace ssn_mask(ssn STRING)
returns STRING
language SQL
AS '
REGEXP_REPLACE(ssn, ''[0-9]'', ''X'') /* 123-45-6789 -> XXX-XX-XXXX */
';
{%- endcall %}
select ssn_mask(ssn) from {{ ref('model_name') }}