# dbt - snowflake - validate function

**URL:** <https://discourse.getdbt.com/t/dbt-snowflake-validate-function/9617>\
**Category:** Help\
**Tags:** jinja, snowflake, macro, macros, dbt-core\
**Created:** [August 19, 2023, 1:02am UTC](https://discourse.getdbt.com/t/dbt-snowflake-validate-function/9617 "2023-08-19T01:02:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roberbonox](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@roberbonox](https://discourse.getdbt.com/u/roberbonox)\
**Post date:** [August 19, 2023, 1:02am UTC](https://discourse.getdbt.com/t/dbt-snowflake-validate-function/9617/1 "2023-08-19T01:02:12Z")

</div>

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:

```auto
{{ 
    config(
        materialized = 'table',
        post_hook = "{{ log_error_validate('db.schema.table', '_last') }}" -- both parameters are strings
    )
}}

SELECT
    ....

```

macros/log\_error\_validate.sql

```auto
{% 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?
