xrmx 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_r176502017
##########
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':
+ sa_metric = sa.func.COUNT(sa.distinct(column(column_name)))
+ if aggregate == 'COUNT':
Review comment:
You can use a bunch of elif here to save some comparisons
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services