Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Fix] Fix sqllab numpy array #4629

Merged
merged 2 commits into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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