mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[explore view] add partition as adhoc filter option (#9637)
* [explore view] add partition as adhoc option * use adhocFilter Simple Tab * simplify conditional check for custom adhoc filter operator * add simple unit tests
This commit is contained in:
@@ -52,6 +52,12 @@ const sumValueAdhocMetric = new AdhocMetric({
|
||||
aggregate: AGGREGATES.SUM,
|
||||
});
|
||||
|
||||
const simpleCustomFilter = new AdhocFilter({
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
subject: 'ds',
|
||||
operator: 'LATEST PARTITION',
|
||||
});
|
||||
|
||||
const options = [
|
||||
{ type: 'VARCHAR(255)', column_name: 'source' },
|
||||
{ type: 'VARCHAR(255)', column_name: 'target' },
|
||||
@@ -155,6 +161,56 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
|
||||
expect(wrapper.instance().isOperatorRelevant('LIKE')).toBe(false);
|
||||
});
|
||||
|
||||
it('will show LATEST PARTITION operator', () => {
|
||||
const { wrapper } = setup({
|
||||
datasource: {
|
||||
type: 'table',
|
||||
datasource_name: 'table1',
|
||||
schema: 'schema',
|
||||
},
|
||||
adhocFilter: simpleCustomFilter,
|
||||
partitionColumn: 'ds',
|
||||
});
|
||||
|
||||
expect(
|
||||
wrapper.instance().isOperatorRelevant('LATEST PARTITION', 'ds'),
|
||||
).toBe(true);
|
||||
expect(
|
||||
wrapper.instance().isOperatorRelevant('LATEST PARTITION', 'value'),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('will generate custom sqlExpression for LATEST PARTITION operator', () => {
|
||||
const testAdhocFilter = new AdhocFilter({
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
subject: 'ds',
|
||||
});
|
||||
const { wrapper, onChange } = setup({
|
||||
datasource: {
|
||||
type: 'table',
|
||||
datasource_name: 'table1',
|
||||
schema: 'schema',
|
||||
},
|
||||
adhocFilter: testAdhocFilter,
|
||||
partitionColumn: 'ds',
|
||||
});
|
||||
|
||||
wrapper.instance().onOperatorChange({ operator: 'LATEST PARTITION' });
|
||||
expect(
|
||||
onChange.lastCall.args[0].equals(
|
||||
testAdhocFilter.duplicateWith({
|
||||
subject: 'ds',
|
||||
operator: 'LATEST PARTITION',
|
||||
comparator: null,
|
||||
clause: 'WHERE',
|
||||
expressionType: 'SQL',
|
||||
sqlExpression:
|
||||
"ds = '{{ presto.latest_partition('schema.table1') }}' ",
|
||||
}),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('expands when its multi comparator input field expands', () => {
|
||||
const { wrapper, onHeightChange } = setup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user