Skip to content

Commit

Permalink
[gaarf-py] Perform jinja expansion only for exisiting template variab…
Browse files Browse the repository at this point in the history
…le in the query

Change-Id: I42b5ab1d46bf2510e58971c66f07480584513992
  • Loading branch information
AVMarkin committed Apr 13, 2023
1 parent 5c6ea71 commit 00cc089
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions py/gaarf/bq_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ def execute(
logger.debug("Original query text:\n%s", query_text)
if params:
if (templates := params.get("template")):
query_text = expand_jinja(query_text, **templates)
logger.debug("Query text after jinja expansion:\n%s",
query_text)
query_templates = {
name: value
for name, value in templates.items() if name in query_text
}
if query_templates:
query_text = expand_jinja(query_text, **query_templates)
logger.debug("Query text after jinja expansion:\n%s",
query_text)
if (macros := params.get("macro")):
query_text = query_text.format(**macros)
logger.debug("Query text after macro substitution:\n%s",
Expand Down

0 comments on commit 00cc089

Please sign in to comment.