mistercrunch closed pull request #4236: Fix msg "'<' not supported between 
instances of 'str' and 'int'"
URL: https://github.com/apache/incubator-superset/pull/4236
 
 
   

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 57038097b7..ab2af88d0f 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -1237,15 +1237,21 @@ def query(self, query_obj):
 
         # Reordering columns
         cols = []
+        groupby = query_obj.get('groupby') or []
+        columns = query_obj.get('columns') or []
+        metrics = query_obj.get('metrics') or []
         if DTTM_ALIAS in df.columns:
             cols += [DTTM_ALIAS]
-        cols += query_obj.get('groupby') or []
-        cols += query_obj.get('columns') or []
-        cols += query_obj.get('metrics') or []
+        cols += groupby
+        cols += columns
+        cols += metrics
 
         cols = [col for col in cols if col in df.columns]
         df = df[cols]
 
+        for col in groupby + columns:
+            df[col] = df[col].astype('str')
+
         time_offset = DruidDatasource.time_offset(query_obj['granularity'])
 
         def increment_timestamp(ts):
diff --git a/tests/druid_tests.py b/tests/druid_tests.py
index c280da790a..209512bc92 100644
--- a/tests/druid_tests.py
+++ b/tests/druid_tests.py
@@ -55,6 +55,7 @@ def __reduce__(self):
         'timestamp': '2012-01-01T00:00:00.000Z',
         'event': {
             'dim1': 'Canada',
+            'dim2': 0,
             'metric1': 12345678,
         },
     },
@@ -63,6 +64,7 @@ def __reduce__(self):
         'timestamp': '2012-01-01T00:00:00.000Z',
         'event': {
             'dim1': 'USA',
+            'dim2': 'false',
             'metric1': 12345678 / 2,
         },
     },
@@ -152,7 +154,7 @@ def test_client(self, PyDruid):
             'row_limit': 5000,
             'include_search': 'false',
             'metrics': ['count'],
-            'groupby': ['dim1', 'dim2d'],
+            'groupby': ['dim1', 'dim2'],
             'force': 'true',
         }
         # two groupby
@@ -162,6 +164,7 @@ def test_client(self, PyDruid):
         )
         resp = self.get_json_resp(url)
         self.assertEqual('Canada', resp['data']['records'][0]['dim1'])
+        self.assertEqual('0', resp['data']['records'][0]['dim2'])
 
     def test_druid_sync_from_config(self):
         CLUSTER_NAME = 'new_druid'


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to