mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
fix(explore): Time comparison in Mixed Chart in GENERIC_CHART_AXES not working (#22945)
This commit is contained in:
parent
b35190783c
commit
ed7b3533bc
@ -67,11 +67,8 @@ export default function buildQuery(formData: QueryFormData) {
|
|||||||
fd,
|
fd,
|
||||||
queryObject,
|
queryObject,
|
||||||
)
|
)
|
||||||
? timeComparePivotOperator(fd, queryObject)
|
? timeComparePivotOperator(fd, { ...queryObject, columns: fd.groupby })
|
||||||
: pivotOperator(fd, {
|
: pivotOperator(fd, { ...queryObject, columns: fd.groupby });
|
||||||
...queryObject,
|
|
||||||
columns: fd.groupby,
|
|
||||||
});
|
|
||||||
|
|
||||||
const tmpQueryObject = {
|
const tmpQueryObject = {
|
||||||
...queryObject,
|
...queryObject,
|
||||||
|
@ -198,6 +198,21 @@ test('should compile AA in query A', () => {
|
|||||||
// time comparison
|
// time comparison
|
||||||
expect(query.time_offsets).toEqual(['1 years ago']);
|
expect(query.time_offsets).toEqual(['1 years ago']);
|
||||||
|
|
||||||
|
// pivot
|
||||||
|
expect(
|
||||||
|
query.post_processing?.find(operator => operator?.operation === 'pivot'),
|
||||||
|
).toEqual({
|
||||||
|
operation: 'pivot',
|
||||||
|
options: {
|
||||||
|
index: ['__timestamp'],
|
||||||
|
columns: ['foo'],
|
||||||
|
drop_missing_columns: false,
|
||||||
|
aggregates: {
|
||||||
|
'sum(sales)': { operator: 'mean' },
|
||||||
|
'sum(sales)__1 years ago': { operator: 'mean' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
// cumsum
|
// cumsum
|
||||||
expect(
|
expect(
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@ -384,20 +399,14 @@ test('should convert a queryObject with x-axis although FF is disabled', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("shouldn't convert a queryObject with axis although FF is enabled", () => {
|
test("shouldn't convert a queryObject with axis although FF is enabled", () => {
|
||||||
let windowSpy: any;
|
const windowSpy = jest
|
||||||
|
.spyOn(window, 'window', 'get')
|
||||||
beforeAll(() => {
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
windowSpy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
|
.mockImplementation(() => ({
|
||||||
featureFlags: {
|
featureFlags: {
|
||||||
GENERIC_CHART_AXES: true,
|
GENERIC_CHART_AXES: true,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
windowSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
const { queries } = buildQuery(formDataMixedChart);
|
const { queries } = buildQuery(formDataMixedChart);
|
||||||
expect(queries[0]).toEqual(
|
expect(queries[0]).toEqual(
|
||||||
@ -468,4 +477,40 @@ test("shouldn't convert a queryObject with axis although FF is enabled", () => {
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
windowSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ensure correct pivot columns with GENERIC_CHART_AXES enabled', () => {
|
||||||
|
const windowSpy = jest
|
||||||
|
.spyOn(window, 'window', 'get')
|
||||||
|
// @ts-ignore
|
||||||
|
.mockImplementation(() => ({
|
||||||
|
featureFlags: {
|
||||||
|
GENERIC_CHART_AXES: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const query = buildQuery({ ...formDataMixedChartWithAA, x_axis: 'ds' })
|
||||||
|
.queries[0];
|
||||||
|
|
||||||
|
expect(query.time_offsets).toEqual(['1 years ago']);
|
||||||
|
|
||||||
|
// pivot
|
||||||
|
expect(
|
||||||
|
query.post_processing?.find(operator => operator?.operation === 'pivot'),
|
||||||
|
).toEqual({
|
||||||
|
operation: 'pivot',
|
||||||
|
options: {
|
||||||
|
index: ['ds'],
|
||||||
|
columns: ['foo'],
|
||||||
|
drop_missing_columns: false,
|
||||||
|
aggregates: {
|
||||||
|
'sum(sales)': { operator: 'mean' },
|
||||||
|
'sum(sales)__1 years ago': { operator: 'mean' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
windowSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user