From e14b74fdbf876aeeeea7baa125926dcf719a0098 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 28 Mar 2017 08:45:19 -0700 Subject: [PATCH] [explore] fixing bugs in controls (#2496) --- .../javascripts/explorev2/components/controls/Filter.jsx | 7 ++----- superset/connectors/druid/models.py | 9 ++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/superset/assets/javascripts/explorev2/components/controls/Filter.jsx b/superset/assets/javascripts/explorev2/components/controls/Filter.jsx index 64e19c33ef512..fec66c4d439ec 100644 --- a/superset/assets/javascripts/explorev2/components/controls/Filter.jsx +++ b/superset/assets/javascripts/explorev2/components/controls/Filter.jsx @@ -22,7 +22,6 @@ operatorsArr.forEach(op => { }); const propTypes = { - choices: PropTypes.array, changeFilter: PropTypes.func, removeFilter: PropTypes.func, filter: PropTypes.object.isRequired, @@ -32,7 +31,6 @@ const propTypes = { const defaultProps = { changeFilter: () => {}, removeFilter: () => {}, - choices: [], datasource: null, }; @@ -54,8 +52,7 @@ export default class Filter extends React.Component { type: 'GET', url: `/superset/filter/${datasource.type}/${datasource.id}/${col}/`, success: (data) => { - this.props.changeFilter('choices', data); - this.setState({ valuesLoading: false }); + this.setState({ valuesLoading: false, valueChoices: data }); }, }); } @@ -100,7 +97,7 @@ export default class Filter extends React.Component { name="filter-value" value={filter.val} isLoading={this.state.valuesLoading} - choices={filter.choices} + choices={this.state.valueChoices} onChange={this.changeSelect.bind(this)} /> ); diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py index 645c12cf4aa44..1a4c148a2edc3 100644 --- a/superset/connectors/druid/models.py +++ b/superset/connectors/druid/models.py @@ -709,8 +709,7 @@ def values_for_column(self, client = self.cluster.get_pydruid_client() client.topn(**qry) df = client.export_pandas() - - return [row[0] for row in df.to_records(index=False)] + return [row[column_name] for row in df.to_records(index=False)] def get_query_str( # noqa / druid self, @@ -981,7 +980,11 @@ def get_filters(self, raw_filters): # noqa eq = flt['val'] cond = None if op in ('in', 'not in'): - eq = [types.replace("'", '').strip() for types in eq] + eq = [ + types.replace("'", '').strip() + if isinstance(types, basestring) + else types + for types in eq] elif not isinstance(flt['val'], basestring): eq = eq[0] if len(eq) > 0 else '' if col in self.num_cols: