mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
[explore] proper filtering of NULLs and '' (#4651)
* [WiP] [explore] proper filtering of NULLs and ''
TODO: handling of Druid equivalents
* Unit tests
* Some refactoring
* [druid] fix 'Unorderable types' when col has nuls
Error "unorderable types: str() < int()" occurs when grouping by a
numerical Druid colummn that contains null values.
* druid/pydruid returns strings in the datafram with NAs for nulls
* Superset has custom logic around get_fillna_for_col that fills in the
NULLs based on declared column type (FLOAT here), so now we have a mixed
bag of type in the series
* pandas chokes on pivot_table or groupby operations as it cannot sorts
mixed types
The approach here is to stringify and fillna('<NULL>') to get a
consistent series.
* typo
* Fix druid_func tests
* Addressing more comments
* last touches
This commit is contained in:
committed by
GitHub
parent
44c2d5bdab
commit
eac97ce9f2
@@ -225,12 +225,13 @@ describe('FilterControl', () => {
|
||||
wrapper.instance().fetchFilterValues(0, 'col1');
|
||||
expect(wrapper.state().activeRequest).to.equal(spyReq);
|
||||
// Sets active to null after success
|
||||
$.ajax.getCall(0).args[0].success('choices');
|
||||
$.ajax.getCall(0).args[0].success(['opt1', 'opt2', null, '']);
|
||||
expect(wrapper.state().filters[0].valuesLoading).to.equal(false);
|
||||
expect(wrapper.state().filters[0].valueChoices).to.equal('choices');
|
||||
expect(wrapper.state().filters[0].valueChoices).to.deep.equal(['opt1', 'opt2', null, '']);
|
||||
expect(wrapper.state().activeRequest).to.equal(null);
|
||||
});
|
||||
|
||||
|
||||
it('cancels active request if another is submitted', () => {
|
||||
const spyReq = sinon.spy();
|
||||
spyReq.abort = sinon.spy();
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('Filter', () => {
|
||||
expect(wrapper.find(Select)).to.have.lengthOf(2);
|
||||
expect(wrapper.find(Button)).to.have.lengthOf(1);
|
||||
expect(wrapper.find(SelectControl)).to.have.lengthOf(1);
|
||||
expect(wrapper.find('#select-op').prop('options')).to.have.lengthOf(8);
|
||||
expect(wrapper.find('#select-op').prop('options')).to.have.lengthOf(10);
|
||||
});
|
||||
|
||||
it('renders five op choices for table datasource', () => {
|
||||
@@ -58,7 +58,7 @@ describe('Filter', () => {
|
||||
filterable_cols: ['country_name'],
|
||||
};
|
||||
const druidWrapper = shallow(<Filter {...props} />);
|
||||
expect(druidWrapper.find('#select-op').prop('options')).to.have.lengthOf(9);
|
||||
expect(druidWrapper.find('#select-op').prop('options')).to.have.lengthOf(11);
|
||||
});
|
||||
|
||||
it('renders six op choices for having filter', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { isTruthy } from '../../../src/utils/common';
|
||||
import { isTruthy, optionFromValue } from '../../../src/utils/common';
|
||||
|
||||
describe('utils/common', () => {
|
||||
describe('isTruthy', () => {
|
||||
@@ -40,4 +40,14 @@ describe('utils/common', () => {
|
||||
expect(isTruthy('false')).to.equal(false);
|
||||
});
|
||||
});
|
||||
describe('optionFromValue', () => {
|
||||
it('converts values as expected', () => {
|
||||
expect(optionFromValue(false)).to.deep.equal({ value: false, label: '<false>' });
|
||||
expect(optionFromValue(true)).to.deep.equal({ value: true, label: '<true>' });
|
||||
expect(optionFromValue(null)).to.deep.equal({ value: '<NULL>', label: '<NULL>' });
|
||||
expect(optionFromValue('')).to.deep.equal({ value: '', label: '<empty string>' });
|
||||
expect(optionFromValue('foo')).to.deep.equal({ value: 'foo', label: 'foo' });
|
||||
expect(optionFromValue(5)).to.deep.equal({ value: 5, label: '5' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user