This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 273
fix(plugin-chart-echarts): boxplot groupby incorrect #1448
Merged
villebro
merged 4 commits into
apache-superset:master
from
preset-io:villebro/boxplot-groupby
Nov 1, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
223 changes: 223 additions & 0 deletions
223
packages/superset-ui-core/test/query/types/PostProcessing.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { | ||
Aggregates, | ||
isPostProcessingAggregation, | ||
isPostProcessingBoxplot, | ||
isPostProcessingCompare, | ||
isPostProcessingContribution, | ||
isPostProcessingCum, | ||
isPostProcessingDiff, | ||
isPostProcessingPivot, | ||
isPostProcessingProphet, | ||
isPostProcessingRolling, | ||
isPostProcessingResample, | ||
isPostProcessingSort, | ||
PandasAxis, | ||
PostProcessingAggregation, | ||
PostProcessingBoxplot, | ||
PostProcessingCompare, | ||
PostProcessingContribution, | ||
PostProcessingCum, | ||
PostProcessingDiff, | ||
PostProcessingPivot, | ||
PostProcessingProphet, | ||
PostProcessingResample, | ||
PostProcessingRolling, | ||
PostProcessingSort, | ||
} from '@superset-ui/core/src/query/types/PostProcessing'; | ||
import { ComparisionType, RollingType, TimeGranularity } from '../../../src'; | ||
|
||
const AGGREGATES_OPTION: Aggregates = { | ||
bar: { | ||
operator: 'max', | ||
column: 'bar', | ||
options: {}, | ||
}, | ||
}; | ||
|
||
const AGGREGATE_RULE: PostProcessingAggregation = { | ||
operation: 'aggregation', | ||
options: { | ||
groupby: ['foo'], | ||
aggregates: AGGREGATES_OPTION, | ||
}, | ||
}; | ||
|
||
const BOXPLOT_RULE: PostProcessingBoxplot = { | ||
operation: 'boxplot', | ||
options: { | ||
groupby: ['foo'], | ||
metrics: ['bar'], | ||
whisker_type: 'tukey', | ||
}, | ||
}; | ||
|
||
const COMPARE_RULE: PostProcessingCompare = { | ||
operation: 'compare', | ||
options: { | ||
source_columns: ['foo'], | ||
compare_columns: ['bar'], | ||
compare_type: ComparisionType.Percentage, | ||
drop_original_columns: false, | ||
}, | ||
}; | ||
|
||
const CONTRIBUTION_RULE: PostProcessingContribution = { | ||
operation: 'contribution', | ||
options: { | ||
orientation: 'row', | ||
columns: ['foo'], | ||
}, | ||
}; | ||
|
||
const CUM_RULE: PostProcessingCum = { | ||
operation: 'cum', | ||
options: { | ||
columns: ['foo'], | ||
operator: 'min', | ||
is_pivot_df: true, | ||
}, | ||
}; | ||
|
||
const DIFF_RULE: PostProcessingDiff = { | ||
operation: 'diff', | ||
options: { | ||
columns: ['foo'], | ||
periods: 12, | ||
axis: PandasAxis.Column, | ||
}, | ||
}; | ||
|
||
const PIVOT_RULE: PostProcessingPivot = { | ||
operation: 'pivot', | ||
options: { | ||
index: ['foo'], | ||
columns: ['bar'], | ||
aggregates: AGGREGATES_OPTION, | ||
flatten_columns: true, | ||
reset_index: true, | ||
}, | ||
}; | ||
|
||
const PROPHET_RULE: PostProcessingProphet = { | ||
operation: 'prophet', | ||
options: { | ||
time_grain: TimeGranularity.DAY, | ||
periods: 365, | ||
confidence_interval: 0.8, | ||
yearly_seasonality: false, | ||
weekly_seasonality: false, | ||
daily_seasonality: false, | ||
}, | ||
}; | ||
|
||
const RESAMPLE_RULE: PostProcessingResample = { | ||
operation: 'resample', | ||
options: { | ||
method: 'method', | ||
rule: 'rule', | ||
fill_value: null, | ||
time_column: 'foo', | ||
}, | ||
}; | ||
|
||
const ROLLING_RULE: PostProcessingRolling = { | ||
operation: 'rolling', | ||
options: { | ||
rolling_type: RollingType.Cumsum, | ||
window: 12, | ||
min_periods: 12, | ||
columns: ['foo', 'bar'], | ||
is_pivot_df: true, | ||
}, | ||
}; | ||
|
||
const SORT_RULE: PostProcessingSort = { | ||
operation: 'sort', | ||
options: { | ||
columns: { foo: true }, | ||
}, | ||
}; | ||
|
||
test('PostProcessingAggregation type guard', () => { | ||
expect(isPostProcessingAggregation(AGGREGATE_RULE)).toEqual(true); | ||
expect(isPostProcessingAggregation(BOXPLOT_RULE)).toEqual(false); | ||
expect(isPostProcessingAggregation(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingBoxplot type guard', () => { | ||
expect(isPostProcessingBoxplot(BOXPLOT_RULE)).toEqual(true); | ||
expect(isPostProcessingBoxplot(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingBoxplot(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingCompare type guard', () => { | ||
expect(isPostProcessingCompare(COMPARE_RULE)).toEqual(true); | ||
expect(isPostProcessingCompare(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingCompare(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingContribution type guard', () => { | ||
expect(isPostProcessingContribution(CONTRIBUTION_RULE)).toEqual(true); | ||
expect(isPostProcessingContribution(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingContribution(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingCum type guard', () => { | ||
expect(isPostProcessingCum(CUM_RULE)).toEqual(true); | ||
expect(isPostProcessingCum(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingCum(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingDiff type guard', () => { | ||
expect(isPostProcessingDiff(DIFF_RULE)).toEqual(true); | ||
expect(isPostProcessingDiff(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingDiff(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingPivot type guard', () => { | ||
expect(isPostProcessingPivot(PIVOT_RULE)).toEqual(true); | ||
expect(isPostProcessingPivot(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingPivot(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingProphet type guard', () => { | ||
expect(isPostProcessingProphet(PROPHET_RULE)).toEqual(true); | ||
expect(isPostProcessingProphet(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingProphet(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingResample type guard', () => { | ||
expect(isPostProcessingResample(RESAMPLE_RULE)).toEqual(true); | ||
expect(isPostProcessingResample(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingResample(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingRolling type guard', () => { | ||
expect(isPostProcessingRolling(ROLLING_RULE)).toEqual(true); | ||
expect(isPostProcessingRolling(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingRolling(undefined)).toEqual(false); | ||
}); | ||
|
||
test('PostProcessingSort type guard', () => { | ||
expect(isPostProcessingSort(SORT_RULE)).toEqual(true); | ||
expect(isPostProcessingSort(AGGREGATE_RULE)).toEqual(false); | ||
expect(isPostProcessingSort(undefined)).toEqual(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groupby
is deprecated onQueryObject
and is ambigous withcolumns
, hence we should usegroupby
fromformData
here, as it carries a specific meaning for the Boxplot chart.