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

Support cache tag could keep result query result to variable like req #153

Closed
Tracked by #150
kokokuo opened this issue Apr 6, 2023 · 0 comments · Fixed by #162
Closed
Tracked by #150

Support cache tag could keep result query result to variable like req #153

kokokuo opened this issue Apr 6, 2023 · 0 comments · Fixed by #162
Assignees

Comments

@kokokuo
Copy link
Contributor

kokokuo commented Apr 6, 2023

What’s the problem you're trying to solve

In #150 In order to enhance our query performance after users send the API request to run our data endpoint to get the result from the data source. We need to provide a Caching (pre-loading) Layer with the duckDB to enhance query performance.

Describe the solution you’d like

We also support {% cache %} … {% endcache %} tag could keep the result from duckDB cache to variable and reuse like req tag

-- omit the setting cache information in YAML by cache key or {% schema set(...) %} in SQL

-- keep the result from {% cache %} ... {% endcache %} and assign to the variable named "prices_range_orders"
# return the result by send the query to duckDB cache data source of the below SQL
{% cache prices_range_orders %}
  select * from order
    where type = {{ context.params.type }}
    and where exists (
        select * from product where price >= {{ context.params.price }}
	and order.product_id = product.id
   )
{% endcache %}

# req main
select * from public.users 
where users.id = {{ prices_range_orders.value()[0].buyer_id }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In process
1 participant