Skip to content

Commit

Permalink
feat: supporting jinja templating in saved metrics (apache#15502)
Browse files Browse the repository at this point in the history
* feat: supporting jinja templating in saved metrics

* cutting the line length to fit requirements

* follwing PR I should have not created a new insance method

* running precommit locally and fixing the issue

Co-authored-by: Guy <[email protected]>
  • Loading branch information
guydou and Guy authored Jul 5, 2021
1 parent 15796ea commit bee386e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ class SqlMetric(Model, BaseMetric):

def get_sqla_col(self, label: Optional[str] = None) -> Column:
label = label or self.metric_name
sqla_col: ColumnClause = literal_column(self.expression)
tp = self.table.get_template_processor()
sqla_col: ColumnClause = literal_column(tp.process_template(self.expression))
return self.table.make_sqla_column_compatible(sqla_col, label)

@property
Expand Down

0 comments on commit bee386e

Please sign in to comment.