Skip to content

Commit

Permalink
Restore datasource count metric for PandasDatasource - see apache#3302
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunwicks committed Dec 5, 2017
1 parent 0f98a55 commit 7c4a2d8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions contrib/connectors/pandas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,27 @@ def get_metadata(self):
if not any_date_col and dbcol.is_time:
any_date_col = col

# Datasource-level metrics
# Note that column-specific metrics are created by reconcile_column_metrics
# when the column is created.
metrics = [
PandasMetric(
metric_name='count',
verbose_name='count',
metric_type='count',
source=None,
expression='count')]
dbmetrics = (
db.session.query(PandasMetric)
.filter(PandasMetric.datasource == self)
.filter(or_(PandasMetric.metric_name == metric.metric_name
for metric in metrics)))
dbmetrics = {metric.metric_name: metric for metric in dbmetrics}
for metric in metrics:
if not dbmetrics.get(metric.metric_name, None):
metric.pandas_datasource_id = self.id
db.session.add(metric)

if not self.main_dttm_col:
self.main_dttm_col = any_date_col

Expand Down

0 comments on commit 7c4a2d8

Please sign in to comment.