john-bodley closed pull request #4629: Fix sqllab numpy array
URL: https://github.com/apache/incubator-superset/pull/4629
 
 
   

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/sql_lab.py b/superset/sql_lab.py
index f98231ed77..12644fcf80 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -97,7 +97,7 @@ def convert_results_to_df(cursor_description, data):
     if data:
         first_row = data[0]
         has_dict_col = any([isinstance(c, dict) for c in first_row])
-        df_data = list(data) if has_dict_col else np.array(data)
+        df_data = list(data) if has_dict_col else np.array(data, dtype=object)
     else:
         df_data = []
 
diff --git a/tests/sqllab_tests.py b/tests/sqllab_tests.py
index 01b10b2626..977bbe0d35 100644
--- a/tests/sqllab_tests.py
+++ b/tests/sqllab_tests.py
@@ -203,8 +203,16 @@ def test_alias_duplicate(self):
             raise_on_error=True)
 
     def test_df_conversion_no_dict(self):
-        cols = [['string_col'], ['int_col']]
-        data = [['a', 4]]
+        cols = [['string_col'], ['int_col'], ['float_col']]
+        data = [['a', 4, 4.0]]
+        cdf = convert_results_to_df(cols, data)
+
+        self.assertEquals(len(data), cdf.size)
+        self.assertEquals(len(cols), len(cdf.columns))
+
+    def test_df_conversion_tuple(self):
+        cols = [['string_col'], ['int_col'], ['list_col'], ['float_col']]
+        data = [(u'Text', 111, [123], 1.0)]
         cdf = convert_results_to_df(cols, data)
 
         self.assertEquals(len(data), cdf.size)


 

----------------------------------------------------------------
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