I am trying to write a concise SQL query string in Python, to make use of both f-strings and Jinja at the same time.
Background info: I am writing a query used in Airflow.
This did not work:
query_string = f"""
SELECT
COUNT(DISTINCT case_id) AS counts
FROM
`{{var.value.gcp_project}}.{{var.value.dataset_prefix}}user.person`
WHERE
identified_on = PARSE_DATE('%Y-%m-%d', '{YESTERDAY_DATE_STR}')
"""
It produced the query string as:
SELECT
COUNT(DISTINCT case_id) AS counts
FROM
`{var.value.gcp_project}.{var.value.dataset_prefix}user.person`
WHERE
identified_on = PARSE_DATE('%Y-%m-%d', '2020-09-07')
So it did the f-string value replacement but not the Jinja.
How can I make both f-strings and Jinja work at the same time?