superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] branch master updated: Fix sqllab numpy array (#4629)
Date Mon, 19 Mar 2018 18:43:07 GMT
This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 5c98f56  Fix sqllab numpy array (#4629)
5c98f56 is described below

commit 5c98f5642b0928f0f496e957b584d97d1d3e7385
Author: michellethomas <michelle.q.thomas@gmail.com>
AuthorDate: Mon Mar 19 11:43:04 2018 -0700

    Fix sqllab numpy array (#4629)
    
    * Fixing error with sqllab numpy array
    
    * Adding tests for failing sqllab data type
---
 superset/sql_lab.py   |  2 +-
 tests/sqllab_tests.py | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index f98231e..12644fc 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 01b10b2..977bbe0 100644
--- a/tests/sqllab_tests.py
+++ b/tests/sqllab_tests.py
@@ -203,8 +203,16 @@ class SqlLabTests(SupersetTestCase):
             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)

-- 
To stop receiving notification emails like this one, please contact
johnbodley@apache.org.

Mime
View raw message