From cf8a72b5db1718bac4a417d5b002a63609cf9b8a Mon Sep 17 00:00:00 2001 From: Michelle Thomas Date: Thu, 15 Mar 2018 19:06:36 -0700 Subject: [PATCH 1/2] Fixing error with sqllab numpy array --- superset/sql_lab.py | 2 +- tests/sqllab_tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/superset/sql_lab.py b/superset/sql_lab.py index f98231ed775c9..12644fcf808c1 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 01b10b262681f..ecaa23ca52f72 100644 --- a/tests/sqllab_tests.py +++ b/tests/sqllab_tests.py @@ -203,8 +203,8 @@ 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) From 12caf6565df2b4259b993833d4d0132a1dfe5933 Mon Sep 17 00:00:00 2001 From: Michelle Thomas Date: Fri, 16 Mar 2018 11:09:02 -0700 Subject: [PATCH 2/2] Adding tests for failing sqllab data type --- tests/sqllab_tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/sqllab_tests.py b/tests/sqllab_tests.py index ecaa23ca52f72..977bbe0d35554 100644 --- a/tests/sqllab_tests.py +++ b/tests/sqllab_tests.py @@ -210,6 +210,14 @@ def test_df_conversion_no_dict(self): 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) + self.assertEquals(len(cols), len(cdf.columns)) + def test_df_conversion_dict(self): cols = [['string_col'], ['dict_col'], ['int_col']] data = [['a', {'c1': 1, 'c2': 2, 'c3': 3}, 4]]