mirror of https://github.com/apache/superset.git
[druid] Fixing Druid version check (#5028)
This commit is contained in:
parent
915e6e9d40
commit
7d1c035658
|
@ -577,38 +577,6 @@ class DruidDatasource(Model, BaseDatasource):
|
||||||
db.session, i_datasource, lookup_cluster, lookup_datasource,
|
db.session, i_datasource, lookup_cluster, lookup_datasource,
|
||||||
import_time)
|
import_time)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def version_higher(v1, v2):
|
|
||||||
"""is v1 higher than v2
|
|
||||||
|
|
||||||
>>> DruidDatasource.version_higher('0.8.2', '0.9.1')
|
|
||||||
False
|
|
||||||
>>> DruidDatasource.version_higher('0.8.2', '0.6.1')
|
|
||||||
True
|
|
||||||
>>> DruidDatasource.version_higher('0.8.2', '0.8.2')
|
|
||||||
False
|
|
||||||
>>> DruidDatasource.version_higher('0.8.2', '0.9.BETA')
|
|
||||||
False
|
|
||||||
>>> DruidDatasource.version_higher('0.8.2', '0.9')
|
|
||||||
False
|
|
||||||
"""
|
|
||||||
def int_or_0(v):
|
|
||||||
try:
|
|
||||||
v = int(v)
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
v = 0
|
|
||||||
return v
|
|
||||||
v1nums = [int_or_0(n) for n in v1.split('.')]
|
|
||||||
v2nums = [int_or_0(n) for n in v2.split('.')]
|
|
||||||
v1nums = (v1nums + [0, 0, 0])[:3]
|
|
||||||
v2nums = (v2nums + [0, 0, 0])[:3]
|
|
||||||
return (
|
|
||||||
v1nums[0] > v2nums[0] or
|
|
||||||
(v1nums[0] == v2nums[0] and v1nums[1] > v2nums[1]) or
|
|
||||||
(v1nums[0] == v2nums[0] and v1nums[1] == v2nums[1] and
|
|
||||||
v1nums[2] > v2nums[2])
|
|
||||||
)
|
|
||||||
|
|
||||||
def latest_metadata(self):
|
def latest_metadata(self):
|
||||||
"""Returns segment metadata from the latest segment"""
|
"""Returns segment metadata from the latest segment"""
|
||||||
logging.info('Syncing datasource [{}]'.format(self.datasource_name))
|
logging.info('Syncing datasource [{}]'.format(self.datasource_name))
|
||||||
|
@ -627,7 +595,7 @@ class DruidDatasource(Model, BaseDatasource):
|
||||||
# realtime segments, which triggered a bug (fixed in druid 0.8.2).
|
# realtime segments, which triggered a bug (fixed in druid 0.8.2).
|
||||||
# https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ
|
# https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ
|
||||||
lbound = (max_time - timedelta(days=7)).isoformat()
|
lbound = (max_time - timedelta(days=7)).isoformat()
|
||||||
if not self.version_higher(self.cluster.druid_version, '0.8.2'):
|
if LooseVersion(self.cluster.druid_version) < LooseVersion('0.8.2'):
|
||||||
rbound = (max_time - timedelta(1)).isoformat()
|
rbound = (max_time - timedelta(1)).isoformat()
|
||||||
else:
|
else:
|
||||||
rbound = max_time.isoformat()
|
rbound = max_time.isoformat()
|
||||||
|
@ -644,7 +612,7 @@ class DruidDatasource(Model, BaseDatasource):
|
||||||
if not segment_metadata:
|
if not segment_metadata:
|
||||||
# if no segments in the past 7 days, look at all segments
|
# if no segments in the past 7 days, look at all segments
|
||||||
lbound = datetime(1901, 1, 1).isoformat()[:10]
|
lbound = datetime(1901, 1, 1).isoformat()[:10]
|
||||||
if not self.version_higher(self.cluster.druid_version, '0.8.2'):
|
if LooseVersion(self.cluster.druid_version) < LooseVersion('0.8.2'):
|
||||||
rbound = datetime.now().isoformat()
|
rbound = datetime.now().isoformat()
|
||||||
else:
|
else:
|
||||||
rbound = datetime(2050, 1, 1).isoformat()[:10]
|
rbound = datetime(2050, 1, 1).isoformat()[:10]
|
||||||
|
|
Loading…
Reference in New Issue