Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiveQuery udf_api support for arrays in data arg #83

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macros/core/_live.yaml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [method, STRING]
- [url, STRING]
- [headers, OBJECT]
- [DATA, OBJECT]
- [DATA, VARIANT]
- [user_id, STRING]
- [SECRET, STRING]
return_type: VARIANT
Expand Down
8 changes: 4 additions & 4 deletions macros/core/live.yaml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [method, STRING]
- [url, STRING]
- [headers, OBJECT]
- [data, OBJECT]
- [data, VARIANT]
- [secret_name, STRING]
return_type: VARIANT
options: |
Expand All @@ -27,7 +27,7 @@
- [method, STRING]
- [url, STRING]
- [headers, OBJECT]
- [data, OBJECT]
- [data, VARIANT]
return_type: VARIANT
options: |
NOT NULL
Expand All @@ -46,7 +46,7 @@
- name: {{ schema }}.udf_api
signature:
- [url, STRING]
- [data, OBJECT]
- [data, VARIANT]
return_type: VARIANT
options: |
NOT NULL
Expand All @@ -65,7 +65,7 @@
- name: {{ schema }}.udf_api
signature:
- [url, STRING]
- [data, OBJECT]
- [data, VARIANT]
- [secret_name, STRING]
return_type: VARIANT
options: |
Expand Down
2 changes: 1 addition & 1 deletion macros/tests/udfs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test AS
$${{ context ~ "\n" }}SELECT {{ call ~ "\n" }};$$ AS sql
FROM test
WHERE NOT {{ assertion }}
{%- if not loop.last -%}
{%- if not loop.last %}
UNION ALL
{%- endif -%}
{%- endfor -%}
Expand Down
27 changes: 27 additions & 0 deletions models/deploy/core/live.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
models:
- name: live
columns:
- name: udf_api
tests:
- test_udf:
name: test__live_udf_api_post_data_object
args: |
'https://httpbin.org/post', {'foo': 'bar'}
assertions:
- result:data.json is not null
- result:data.json = OBJECT_CONSTRUCT('foo', 'bar')
- test_udf:
name: test__live_udf_api_post_data_array
args: |
'https://httpbin.org/post', ['foo', 'bar']
assertions:
- result:data.json is not null
- result:data.json = ARRAY_CONSTRUCT('foo', 'bar')
- test_udf:
name: test__live_udf_api_post_data_string
args: |
'https://httpbin.org/post', 'foo'::VARIANT
assertions:
- result:data.json is not null
- result:data.json = 'foo'
2 changes: 1 addition & 1 deletion models/live__allow_list.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- depends_on: {{ ref('live') }}
{{ config(
materialized = 'view',
grants = {'+select': fromyaml(var('ROLES'))}
) }}

SELECT '*.' || t.value AS allowed_domains
FROM table(flatten(input => {{ this.database }}.live.udf_allow_list())) AS t
ORDER BY
Expand Down