Skip to content

Commit

Permalink
Merge pull request apache#26 from michellethomas/cherry_pick_sqllab_n…
Browse files Browse the repository at this point in the history
…umpy

Cherry pick sqllab numpy
  • Loading branch information
michellethomas authored Mar 19, 2018
2 parents 55e20ae + 3971779 commit d48b53a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
12 changes: 10 additions & 2 deletions tests/sqllab_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d48b53a

Please sign in to comment.