livequery-models/macros/tests/udtfs.sql
Jensen Yap 629dfe077d Update GitHub Actions workflow to reduce thread count and add extensive API integration documentation
- Changed thread count from 24 to 5 in GitHub Actions workflows for improved performance.
- Added comprehensive README files for various API integrations including Alchemy, NBA All Day, API Layer, Binance, and more.
- Introduced new UDFs and UDTFs for Groq and Slack API integrations, enhancing functionality and usability.
- Implemented tests for new UDFs and UDTFs to ensure reliability and correctness.
- Updated existing UDF definitions and added new tests for enhanced coverage and robustness.
2025-08-05 20:30:21 +09:00

32 lines
657 B
SQL

{% macro base_test_udtf(model, udf, args, assertions) %}
{#
Generates a test for a User-Defined Table Function (UDTF).
Unlike scalar UDFs, UDTFs return a table of results.
#}
{%- set call -%}
SELECT * FROM TABLE({{ udf }}({{ args }}))
{%- endset -%}
WITH test AS
(
SELECT
'{{ udf }}' AS test_name
,[{{ args }}] as parameters
,t.*
FROM TABLE({{ udf }}({{ args }})) t
)
{% for assertion in assertions %}
SELECT
test_name,
parameters,
$${{ assertion }}$$ AS assertion,
$${{ call }}$$ AS sql
FROM test
WHERE NOT {{ assertion }}
{%- if not loop.last %}
UNION ALL
{%- endif -%}
{%- endfor -%}
{% endmacro %}