The problem i have is that i call from a model a macro with parameter as a post_hook .
I’m doing this because i have ingestions as COPY INTO in snowflake with on_error = continue condition and i want to retrieve all the rows that have failed from being loaded.
This is my code:
models/model_1.sql:
{{
config(
materialized = 'table',
post_hook = "{{ log_error_validate('db.schema.table', '_last') }}" -- both parameters are strings
)
}}
SELECT
....
macros/log_error_validate.sql
{% macro log_error_validate(table_to_validate, job_id) %}
MERGE INTO db2.schema2.LOG_ERROR log_erro USING
(
WITH log_error AS (
SELECT
...
FROM
TABLE(VALIDATE(IDENTIFIER({{ table_to_validate }}), JOB_ID => '{{ job_id }}'))
)
SELECT
....
error:
002018 (22023): SQL compilation error:
00:45:26 Invalid argument [We couldn’t find a copy for this table which occurred during this session ] for table function. Table function argument is required to be a constant.
00:45:26 compiled Code at …
I’ve already tried almost every combination that i’m aware of for the two parameters inside the validate function but everyone had show me different errors,
Thoughts?