mirror of
https://github.com/FlipsideCrypto/livequery-models.git
synced 2026-02-06 10:56:46 +00:00
* 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. * Refactor Slack UDFs to use webhook secret names and improve error handling - Updated UDF definitions to replace WEBHOOK_URL and BOT_TOKEN with WEBHOOK_SECRET_NAME for enhanced security. - Improved error messages for required parameters in the SQL logic. - Standardized comments for clarity and consistency across UDFs. - Ensured proper handling of user context for accessing secrets in the vault. * update test * fix test * update slack * remove test * fix tests * fix * fix test args * fix * add .gitignore * Add Slack Notification Macros and Enhance UDFs - Introduced a new dbt macro for sending Slack notifications from GitHub Actions with AI-powered failure analysis. - Added comprehensive README documentation for the new macro, detailing setup, configuration options, and usage examples. - Implemented a SQL macro to handle Slack message formatting and sending, including support for AI analysis and threading. - Updated existing UDFs to utilize webhook secret names for improved security and added detailed comments for clarity. - Enhanced error handling and logging within the macros to ensure robust operation and easier debugging. * update slack alerts * update * remove groq * Enhance Slack Alert Macros with AI Analysis Features - Updated README documentation to clarify AI provider options and added new parameters for model selection and custom prompts. - Modified SQL macros to support the new `model_name` and `ai_prompt` parameters for improved AI analysis capabilities. - Adjusted UDF signatures and comments to reflect the changes in AI provider functionality and requirements. - Improved test cases to validate the new features and ensure robust performance of the Slack alert macros. * update slack_alert * change secret path to data_platform * add backward compatibility for udf_api_v2 * revert to Object return type * update type
66 lines
1.4 KiB
SQL
66 lines
1.4 KiB
SQL
{% macro base_test_udf(model, udf, args, assertions) %}
|
|
{#
|
|
Generates a test for a UDF.
|
|
#}
|
|
{% if execute %}
|
|
{%- set context -%}
|
|
SET LIVEQUERY_CONTEXT = '{"userId":"{{ var("STUDIO_TEST_USER_ID") }}"}';
|
|
{%- endset -%}
|
|
{%- do run_query(context) -%}
|
|
{%- endif -%}
|
|
{%- set call -%}
|
|
{{ target.database }}.{{ udf }}({{ args }})
|
|
{%- endset -%}
|
|
,
|
|
test AS
|
|
(
|
|
SELECT
|
|
'{{ udf }}' AS test_name
|
|
,[{{ args }}] as parameters
|
|
,{{ call }} AS result
|
|
)
|
|
{% for assertion in assertions %}
|
|
SELECT
|
|
test_name,
|
|
parameters,
|
|
result,
|
|
$${{ assertion }}$$ AS assertion,
|
|
$${{ context ~ "\n" }}SELECT {{ call ~ "\n" }};$$ AS sql
|
|
FROM test
|
|
WHERE NOT {{ assertion }}
|
|
{%- if not loop.last %}
|
|
UNION ALL
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- endmacro -%}
|
|
|
|
{% macro base_test_udf_without_context(model, udf, args, assertions) %}
|
|
{#
|
|
Generates a test for a UDF without setting LIVEQUERY_CONTEXT.
|
|
#}
|
|
{%- set call -%}
|
|
{{ target.database }}.{{ udf }}({{ args }})
|
|
{%- endset -%}
|
|
,
|
|
test AS
|
|
(
|
|
SELECT
|
|
'{{ udf }}' AS test_name
|
|
,[{{ args }}] as parameters
|
|
,{{ call }} AS result
|
|
)
|
|
{% for assertion in assertions %}
|
|
SELECT
|
|
test_name,
|
|
parameters,
|
|
result,
|
|
$${{ assertion }}$$ AS assertion,
|
|
$$SELECT {{ call ~ "\n" }};$$ AS sql
|
|
FROM test
|
|
WHERE NOT {{ assertion }}
|
|
{%- if not loop.last %}
|
|
UNION ALL
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- endmacro -%}
|