You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/04/05 00:16:54 UTC

[GitHub] john-bodley closed pull request #4761: [druid] Excluding refreshing verbose name

john-bodley closed pull request #4761: [druid] Excluding refreshing verbose name
URL: https://github.com/apache/incubator-superset/pull/4761
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 9a8d6584d8..25c68acae1 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -372,7 +372,7 @@ def refresh_metrics(self):
         for metric in metrics.values():
             dbmetric = dbmetrics.get(metric.metric_name)
             if dbmetric:
-                for attr in ['json', 'metric_type', 'verbose_name']:
+                for attr in ['json', 'metric_type']:
                     setattr(dbmetric, attr, getattr(metric, attr))
             else:
                 with db.session.no_autoflush:
diff --git a/tests/druid_tests.py b/tests/druid_tests.py
index 7406dacbc3..b0d9caff76 100644
--- a/tests/druid_tests.py
+++ b/tests/druid_tests.py
@@ -376,13 +376,19 @@ def test_refresh_metadata(self, PyDruid):
                     'double{}'.format(agg.capitalize()),
                 )
 
-            # Augment a metric.
-            metadata = SEGMENT_METADATA[:]
-            metadata[0]['columns']['metric1']['type'] = 'LONG'
-            instance = PyDruid.return_value
-            instance.segment_metadata.return_value = metadata
-            cluster.refresh_datasources()
+    @patch('superset.connectors.druid.models.PyDruid')
+    def test_refresh_metadata_augment_type(self, PyDruid):
+        self.login(username='admin')
+        cluster = self.get_cluster(PyDruid)
+        cluster.refresh_datasources()
 
+        metadata = SEGMENT_METADATA[:]
+        metadata[0]['columns']['metric1']['type'] = 'LONG'
+        instance = PyDruid.return_value
+        instance.segment_metadata.return_value = metadata
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
             metrics = (
                 db.session.query(DruidMetric)
                 .filter(DruidMetric.datasource_id == datasource.id)
@@ -397,6 +403,37 @@ def test_refresh_metadata(self, PyDruid):
                     'long{}'.format(agg.capitalize()),
                 )
 
+    @patch('superset.connectors.druid.models.PyDruid')
+    def test_refresh_metadata_augment_verbose_name(self, PyDruid):
+        self.login(username='admin')
+        cluster = self.get_cluster(PyDruid)
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
+            metrics = (
+                db.session.query(DruidMetric)
+                .filter(DruidMetric.datasource_id == datasource.id)
+                .filter(DruidMetric.metric_name.like('%__metric1'))
+            )
+
+            for metric in metrics:
+                metric.verbose_name = metric.metric_name
+
+            db.session.commit()
+
+        # The verbose name should not change during a refresh.
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
+            metrics = (
+                db.session.query(DruidMetric)
+                .filter(DruidMetric.datasource_id == datasource.id)
+                .filter(DruidMetric.metric_name.like('%__metric1'))
+            )
+
+            for metric in metrics:
+                self.assertEqual(metric.verbose_name, metric.metric_name)
+
     def test_urls(self):
         cluster = self.get_test_cluster_obj()
         self.assertEquals(


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services