hughhhh commented on a change in pull request #4663: [Request For Comments][Explore] Streamlined metric definitions for SQLA and Druid URL: https://github.com/apache/incubator-superset/pull/4663#discussion_r176654238
########## File path: superset/connectors/sqla/models.py ########## @@ -436,6 +436,25 @@ def get_from_clause(self, template_processor=None, db_engine_spec=None): return TextAsFrom(sa.text(from_sql), []).alias('expr_qry') return self.get_sqla_table() + def adhoc_metric_to_sa(self, metric): + column_name = metric.get('column').get('column_name') + aggregate = metric.get('aggregate') + label = metric.get('label') + if aggregate == 'COUNT_DISTINCT': Review comment: nit: I would make this a `dict()` mapping for instance: ``` aggregate_dict = { 'SUM' : sa.func.COUNT(column(column_name)) ... } sa_metric = aggregate_dict.get(aggregate) ``` I think this is much cleaner and would allow others to add more metrics easily later. PS: This is so dope! i can't wait till this lands so we can had some geo functions! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services