-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Jinja Substitution Within a HiveOperator #257
Comments
@Vandiver247 , you hit something that is not very well documented/intuitive. The key is to pass a dictionary with your parameters to the
Let me know if it doesn't work. |
Ok. That seems to work for passing most things. However, I'm still running into a problem. Basically, what I'm trying to do is set one of the variables to the execution date which is currently the default macro
However, I need the timestamp in a different format so I really want to use something like
When I do this outside of the DAG declaration it works fine returning me the string in the format I want. However, if I attempt to access the macro in the
In other words, this works:
But this does not:
I assume that this is due to how Jinja works when processing the context. That said, is there a way for me to either make this work, or to access the current execution date outside of macros? Finally, one other question. Where are the default variables like Thanks for the help. |
Here is where the context object is created: Jinja doesn't do a multi-pass rendering, so when it resolves So clearly
and in the template: |
This commit clarifies some of this in the docs |
Thank you! I appreciate the help. |
I'm sorry if this is a obvious question since I am not really familiar with Jinja and the documentation has me lost. The HiveOperator allows you to substitute hiveconf templating to jinja templating. What I cant figure out is how to define the jinja template variables within the DAGs context. So for instance if I have the hiveconf variable
${var}
which gets translated to{{ var }}
how do I give{{ var }}
a value? I know I can pass template variables to operators usingparams
, however, if I then go into the hql and change the variable names to${params.var}
then the hiveconf to jinja translation fails completely.The text was updated successfully, but these errors were encountered: