At the moment, various operators support reading templates from given
filenames (for example, `bash_command` of `BashOperator`). However, all of
these operators specify extensions such as .sh, .json etc., so it means
users need to write Jinja2 templates inside .sh, .json files. This is
problematic for 3 reasons:

1. No semantic support when writing templates (major IDEs support this
extension, including Github itself)
2. It's not aligned to widespread convention of naming template files with
.jinja2 extension
3. It's harder to distinguish between template files and non-template files

A better way to do it would be supporting the .jinja2 extension.

The proposition at the moment is to globally accept .jinja2 extension in
`BaseOperator` whenever `template_ext` is defined. It means that all
inheriting operators will now automatically support their already defined
extensions but also with .jinja2 appended to them (i.e. if you have
`template_ext = ('.json', '.yml')` then also .json.jinja2 and .yml.jinja2
will be added)).

Since this affects a vast part of the codebase, this suggestion is open to
discussion. WDYT?

For more info, see https://github.com/apache/airflow/issues/8603

Reply via email to