mirror of https://github.com/apache/superset.git
[druid] Excluding refreshing verbose name (#4761)
This commit is contained in:
parent
68999b1407
commit
df4ff05441
|
@ -372,7 +372,7 @@ class DruidColumn(Model, BaseColumn):
|
||||||
for metric in metrics.values():
|
for metric in metrics.values():
|
||||||
dbmetric = dbmetrics.get(metric.metric_name)
|
dbmetric = dbmetrics.get(metric.metric_name)
|
||||||
if dbmetric:
|
if dbmetric:
|
||||||
for attr in ['json', 'metric_type', 'verbose_name']:
|
for attr in ['json', 'metric_type']:
|
||||||
setattr(dbmetric, attr, getattr(metric, attr))
|
setattr(dbmetric, attr, getattr(metric, attr))
|
||||||
else:
|
else:
|
||||||
with db.session.no_autoflush:
|
with db.session.no_autoflush:
|
||||||
|
|
|
@ -376,13 +376,19 @@ class DruidTests(SupersetTestCase):
|
||||||
'double{}'.format(agg.capitalize()),
|
'double{}'.format(agg.capitalize()),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Augment a metric.
|
@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 = SEGMENT_METADATA[:]
|
||||||
metadata[0]['columns']['metric1']['type'] = 'LONG'
|
metadata[0]['columns']['metric1']['type'] = 'LONG'
|
||||||
instance = PyDruid.return_value
|
instance = PyDruid.return_value
|
||||||
instance.segment_metadata.return_value = metadata
|
instance.segment_metadata.return_value = metadata
|
||||||
cluster.refresh_datasources()
|
cluster.refresh_datasources()
|
||||||
|
|
||||||
|
for i, datasource in enumerate(cluster.datasources):
|
||||||
metrics = (
|
metrics = (
|
||||||
db.session.query(DruidMetric)
|
db.session.query(DruidMetric)
|
||||||
.filter(DruidMetric.datasource_id == datasource.id)
|
.filter(DruidMetric.datasource_id == datasource.id)
|
||||||
|
@ -397,6 +403,37 @@ class DruidTests(SupersetTestCase):
|
||||||
'long{}'.format(agg.capitalize()),
|
'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):
|
def test_urls(self):
|
||||||
cluster = self.get_test_cluster_obj()
|
cluster = self.get_test_cluster_obj()
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
|
|
Loading…
Reference in New Issue