This commit is contained in:
Julius Remigio 2025-05-07 12:48:02 +00:00 committed by GitHub
commit 371a3956ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 112 additions and 1 deletions

View File

@ -6,7 +6,7 @@ version: "1.0.0"
config-version: 2
# This setting configures which "profile" dbt uses for this project.
profile: "livequery"
profile: livequery
# These configurations specify where dbt should look for different types of files.
# The `source-paths` config, for example, states that models in this project can be

View File

@ -14,4 +14,50 @@
options: |
NOT NULL
sql: udf_api
- name: {{ schema }}.udf_rest_api_args_only
signature:
- [method, STRING]
- [url, STRING]
- [headers, OBJECT]
- [DATA, VARIANT]
- [SECRET_NAME, STRING]
return_type: OBJECT
func_type: SECURE
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
sql: |
{
'method': method,
'url': url,
'headers': headers,
'data': data,
'secret_name': SECRET_NAME
}
{# - name: {{ schema }}.udf_api
description: |
This function is used to select the appropriate function to call based on the user_id
signature:
- [method, STRING]
- [url, STRING]
- [headers, OBJECT]
- [DATA, VARIANT]
- [user_id, STRING]
- [SECRET, STRING]
return_type: VARIANT
func_type: SECURE
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
sql: |
SELECT
CASE
WHEN user_id ilike 'AWS_%'
THEN {{ schema }}.udf_rest_api_args_only(method, url, headers, DATA, SECRET)::VARIANT
ELSE {{ schema }}._udf_api(method, url, headers, DATA, user_id, SECRET)
END #}
{% endmacro %}

View File

@ -108,6 +108,24 @@
secret_name
)
- name: {{ schema }}.udf_api
signature:
- [args, OBJECT]
return_type: VARIANT
options: |
NOT NULL
VOLATILE
sql: |
SELECT
_live.UDF_API(
COALESCE(args:method, 'GET'),
args:url,
COALESCE(args:headers, {}),
COALESCE(args:data, {}),
_utils.UDF_WHOAMI(),
COALESCE(args:secret_name, '')
)
- name: {{ schema }}.udf_rpc
signature:
- [blockchain, STRING]

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: _live
columns:
- name: udf_rest_api_args_only
tests:
- test_udf:
name: test___live_udf_rest_api_args_only
args: >
'GET',
'https://api.example.com',
{'Content-Type': 'application/json'},
{'hello': 'world'},
'my_secret'
assertions:
- |
result = {
'method': 'GET',
'url': 'https://api.example.com',
'headers': {'Content-Type': 'application/json'},
'data': {'hello': 'world'},
'secret_name': 'my_secret'
}
- test_udf:
name: test___live_udf_rest_api_args_only_null
args: null, null, null, null, null
assertions:
- result = {}
- test_udf:
name: test___live_udf_api
args: >
'GET',
'https://api.example.com',
{'Content-Type': 'application/json'},
{'hello': 'world'},
'non_streamline_user'
'my_secret'
assertions:
- |
result = {
'method': 'GET',
'url': 'https://httpbin.org/get',
'headers': {'Content-Type': 'application/json'},
'data': {'hello': 'world'},
'user': 'non_streamline_user',
'secret_name': 'my_secret'
}