mirror of
https://github.com/FlipsideCrypto/livequery-models.git
synced 2026-02-06 10:56:46 +00:00
revert test_udfs to fix schema error.
This commit is contained in:
parent
e46cdbf260
commit
8cb0c8a98e
@ -1,39 +1,12 @@
|
||||
{% test test_udf(model, column_name, args, assertions) %}
|
||||
{#
|
||||
This is a generic test for UDFs.
|
||||
The udfs are deployed using ephemeral models, as of dbt-core > 1.8
|
||||
we need to use `this.identifier` to extract the schema from for base_test_udf().
|
||||
The udfs are deployed using ephemeral models, so we need to
|
||||
use the ephemeral model name to get the udf name.
|
||||
#}
|
||||
|
||||
{% set schema = none %}
|
||||
|
||||
{% if execute %}
|
||||
{# Extract schema based on standard pattern `test__<schema_name>_<test_name> #}
|
||||
{% set test_identifier = this.identifier %}
|
||||
|
||||
{% if test_identifier.startswith('test_') %}
|
||||
{% set test_identifier = test_identifier[5:] %}
|
||||
{% endif %}
|
||||
|
||||
{# Handle schemas with underscore prefix #}
|
||||
{% if test_identifier.startswith('_') %}
|
||||
{# For identifiers like _utils_<test_name> #}
|
||||
{% set parts = test_identifier.split('_') %}
|
||||
{% if parts | length > 2 %}
|
||||
{% set schema = '_' ~ parts[1] %}
|
||||
{% else %}
|
||||
{% set schema = parts[0] %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{# For identifiers without underscore prefix #}
|
||||
{% set parts = test_identifier.split('_') %}
|
||||
{% if parts | length > 0 %}
|
||||
{% set schema = parts[0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set udf = schema ~ "." ~ column_name %}
|
||||
{%- set schema = model | replace("__dbt__cte__", "") -%}
|
||||
{%- set schema = schema.split("__") | first -%}
|
||||
{%- set udf = schema ~ "." ~ column_name -%}
|
||||
|
||||
{{ base_test_udf(model, udf, args, assertions) }}
|
||||
{% endtest %}
|
||||
{% endtest %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user