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

Allow 'Jinja' like functionality in sql queries #14

Open
daranzolin opened this issue Jun 26, 2024 · 1 comment
Open

Allow 'Jinja' like functionality in sql queries #14

daranzolin opened this issue Jun 26, 2024 · 1 comment

Comments

@daranzolin
Copy link
Owner

Jinja:

{% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %}

...
        {% for payment_method in payment_methods -%}
        sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount,
        {% endfor -%}
...

glue:

payment_methods <- c('credit_card', 'coupon', 'bank_transfer', 'gift_card')
glue("sum(case when payment_method = '{payment_methods}' then amount else 0 end as {payment_methods}_amount,")
@daranzolin
Copy link
Owner Author

Think this could work smoothly with the jinjar package: https://github.com/davidchall/jinjar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant