You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by Taylor Edmiston <te...@gmail.com> on 2018/05/05 15:26:14 UTC

Re: Template for Operator' Json Argument

I think you need to convert any non-str type into a string to render it in
the template, i.e., just str(foo).

https://github.com/apache/incubator-airflow/blob/1d3bb5470711a935b36b6a0ab4c7ec414d460d75/airflow/models.py#L2613

But in your template, if I understand correctly that you're building a JSON
object as a string you could render that particular field without quotes
wrapping it, so a JSON parser would detect it as an int, not a str.  Does
that make sense?

Can you share your code?

Best,
Taylor

On Sat, May 5, 2018 at 4:42 AM ramandumcs@gmail.com <ra...@gmail.com>
wrote:

> Hi All,
>
> We have implemented a custom operator which is derived from baseOperator.
> Custom operator takes a JSON argument. Some fields of this Json are string
> and others are integer. We need to templatised the string fields only and
> not integer. But on doing this we are getting the error
> airflow.exceptions.AirflowException: Type '<type 'int'>' used for parameter
> 'json[number]' is not supported for templating.
>
> So is this possible to have both string and integer in templatised field.
>
> Thanks,
> Raman Gupta
>
-- 
*Taylor Edmiston*
Blog <http://blog.tedmiston.com> | Stack Overflow CV
<https://stackoverflow.com/story/taylor> | LinkedIn
<https://www.linkedin.com/in/tedmiston/> | AngelList
<https://angel.co/taylor>