You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by yo...@apache.org on 2021/07/05 16:01:08 UTC

[superset] branch master updated: feat: supporting jinja templating in saved metrics (#15502)

This is an automated email from the ASF dual-hosted git repository.

yongjiezhao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new bee386e  feat: supporting jinja templating in saved metrics  (#15502)
bee386e is described below

commit bee386e643a202f182a5cffd03c460fc27efe959
Author: Guy Doulberg <gu...@gmail.com>
AuthorDate: Mon Jul 5 19:00:13 2021 +0300

    feat: supporting jinja templating in saved metrics  (#15502)
    
    * 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 <gu...@nexite.io>
---
 superset/connectors/sqla/models.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 7e3811a..a6aeabf 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -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