From 7a7eb3334834e014aff0adbec2fd558199827c98 Mon Sep 17 00:00:00 2001 From: Kim Pham Date: Fri, 25 Mar 2016 13:44:35 -0700 Subject: [PATCH 1/3] Disable Datasource sql polymorphism & Fix refresh Druid metadata. --- dashed/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dashed/models.py b/dashed/models.py index 878b5f99f3b93..f67edd77b8003 100644 --- a/dashed/models.py +++ b/dashed/models.py @@ -840,8 +840,12 @@ def latest_metadata(self): return max_time = results[0]['result']['maxTime'] max_time = parse(max_time) - intervals = (max_time - timedelta(seconds=1)).isoformat() + '/' - intervals += (max_time + timedelta(seconds=1)).isoformat() + # Query segmentMetadata for 7 days back. However, due to a bug, + # we need to set this interval to more than 1 day ago to exclude realtime segments, which + # trigged a bug (fixed in druid 0.8.2). + # https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ + intervals = (max_time - timedelta(days=7)).isoformat() + '/' + intervals += (max_time - timedelta(days=1)).isoformat() segment_metadata = client.segment_metadata( datasource=self.datasource_name, intervals=intervals) @@ -1114,7 +1118,8 @@ class DruidColumn(Model): datasource_name = Column( String(250), ForeignKey('datasources.datasource_name')) - datasource = relationship('DruidDatasource', backref='columns') + # Setting enable_typechecks=False disables polymorphic inheritance. + datasource = relationship('DruidDatasource', backref='columns', enable_typechecks=False) column_name = Column(String(256)) is_active = Column(Boolean, default=True) type = Column(String(32)) From 23b6bca89ec70b9543a3c3f49efd4b05c59c9594 Mon Sep 17 00:00:00 2001 From: Kim Pham Date: Fri, 25 Mar 2016 13:49:45 -0700 Subject: [PATCH 2/3] Fix style warning --- dashed/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dashed/models.py b/dashed/models.py index f67edd77b8003..9d623ef9b9797 100644 --- a/dashed/models.py +++ b/dashed/models.py @@ -841,8 +841,8 @@ def latest_metadata(self): max_time = results[0]['result']['maxTime'] max_time = parse(max_time) # Query segmentMetadata for 7 days back. However, due to a bug, - # we need to set this interval to more than 1 day ago to exclude realtime segments, which - # trigged a bug (fixed in druid 0.8.2). + # we need to set this interval to more than 1 day ago to exclude + # realtime segments, which trigged a bug (fixed in druid 0.8.2). # https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ intervals = (max_time - timedelta(days=7)).isoformat() + '/' intervals += (max_time - timedelta(days=1)).isoformat() @@ -1119,7 +1119,8 @@ class DruidColumn(Model): String(250), ForeignKey('datasources.datasource_name')) # Setting enable_typechecks=False disables polymorphic inheritance. - datasource = relationship('DruidDatasource', backref='columns', enable_typechecks=False) + datasource = relationship('DruidDatasource', backref='columns', + enable_typechecks=False) column_name = Column(String(256)) is_active = Column(Boolean, default=True) type = Column(String(32)) From 2378fdf9ce83d8f99672c0b5606c72c02ed9ec37 Mon Sep 17 00:00:00 2001 From: Kim Pham Date: Fri, 25 Mar 2016 16:45:35 -0700 Subject: [PATCH 3/3] Disable polymorphism in DruidMetric as well --- dashed/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dashed/models.py b/dashed/models.py index 9d623ef9b9797..811c70a71e4bb 100644 --- a/dashed/models.py +++ b/dashed/models.py @@ -1096,7 +1096,9 @@ class DruidMetric(Model): datasource_name = Column( String(250), ForeignKey('datasources.datasource_name')) - datasource = relationship('DruidDatasource', backref='metrics') + # Setting enable_typechecks=False disables polymorphic inheritance. + datasource = relationship('DruidDatasource', backref='metrics', + enable_typechecks=False) json = Column(Text) description = Column(Text)