How to specify target schema for udfs?

Hi all,

I started implementing the approach illustrated in this post for BigQuery.

-- macros/udfs/file_name.sql
{% set schema = 'schema_name' %}

{% macro macro_name() %}
CREATE OR REPLACE FUNCTION {{target.schema}}.function_name(input STRING) 
RETURNS 
...

I was hoping the schema variable defined at the top could be passed into {{ target.schema}} block, but it seem didn’t work as expected (no function created in my target schema).

Two questions here:

  • How to set target schema for udf macro like how we did for model config?
  • Does compiled macro go into somewhere like target/?
1 Like

As @claire replied in this thread

After surrounding macro name with run_query block like this

{% macro create_udfs() %}
...
{% do run_query(fn_metadata_header()) %}
...
{% endmacro %}

The macro is successfully executed.

1 Like

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