-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Feature] Allow args
flag to be passed to run-operation
#9862
Comments
Wanna give this a try?
macros/cowsay.sql {% macro cowsay(message="hi") %}
{% do log(" ________________________________________", info=True) %}
{% do log(" " ~ message, info=True) %}
{% do log(" ----------------------------------------", info=True) %}
{% do log(" \ ^__^", info=True) %}
{% do log(" \ (oo)\_______", info=True) %}
{% do log(" (__)\ )", info=True) %}
{% do log(" ||----w |", info=True) %}
{% do log(" || ||", info=True) %}
{% endmacro %} dbt run-operation cowsay --args '{message: "Arg, I be a pirate"}'
|
Since it looks like we already support this, I'm going to close this as "not planned". But just let me know if I overlooked something and we can re-open it. |
@aranke I overlooked one key piece in your original message 😅 👉 the part where I'm interpreting that the desired behavior is for the While we don't plan on adopting that behavior within
Option 1 - push the Jinja logic into the macroSuppose you have a We'd recommend refactoring the dbt run-operation cowsay
dbt run-operation cowsay --args "{suffix_type: 'standard'}"
dbt run-operation cowsay --args "{suffix_type: 'alternate'}" Toggle for an example.{% macro cowsay(message="hi", suffix_type=none) %}
{% set timestamp = get_timestamp_suffix(suffix_type) %}
{% do log(" ________________________________________", info=True) %}
{% do log(" " ~ timestamp ~ " " ~ message , info=True) %}
{% do log(" ----------------------------------------", info=True) %}
{% do log(" \ ^__^" , info=True) %}
{% do log(" \ (oo)\_______" , info=True) %}
{% do log(" (__)\ )" , info=True) %}
{% do log(" ||----w |" , info=True) %}
{% do log(" || ||" , info=True) %}
{% endmacro %}
{% macro get_timestamp_suffix(suffix_type=none) %}
{% if suffix_type == 'standard' %}
{% do return(run_started_at.strftime('%d-%m-%Y')) %}
{% elif suffix_type == 'alternate' %}
{% do return(run_started_at.strftime('%Y%m%d')) %}
{% else %}
{% do return("") %}
{% endif %}
{% endmacro %} Option 2 - use interactive compilationThe following is a more complicated option. I'm not sure if there are valid use-cases for it or not, but providing it for the sake of completeness. The general pattern is this:
It is a multi-step process that is dependent upon the capabilities of the shell it is operating within (bash, zsh, fsh, PowerShell, etc.), so your mileage may vary. Here's an example that works for me in export message=$(dbt --log-format json compile --inline "{{ get_timestamp_suffix(suffix_type='standard') }}" --output text | jq -r 'select(.data.compiled != null) | .data.compiled')
dbt run-operation cowsay --args "{message: '$message'}"
unset message If #9840 is implemented, then the command in the first step would be a bit more simple: export message=$(dbt compile --inline "{{ get_timestamp_suffix(suffix_type='standard') }}" --quiet)
dbt run-operation cowsay --args "{message: '$message'}"
unset message |
Is this your first time submitting a feature request?
Describe the feature
run-operation
should support theargs
flag so we can run operations like so:Describe alternatives you've considered
N/A
Who will this benefit?
Anyone who wants to dynamically run different branches in a macro
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: