Skip to content

Commit

Permalink
Revert "feat: apply Time Grain to X-Axis column (apache#21163)"
Browse files Browse the repository at this point in the history
This reverts commit ce3d38d.
  • Loading branch information
jinghua-qa committed Sep 20, 2022
1 parent fef5146 commit a5d2834
Show file tree
Hide file tree
Showing 24 changed files with 29 additions and 705 deletions.
2 changes: 0 additions & 2 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ assists people when migrating to a new version.
- [20606](https://github.com/apache/superset/pull/20606): When user clicks on chart title or "Edit chart" button in Dashboard page, Explore opens in the same tab. Clicking while holding cmd/ctrl opens Explore in a new tab. To bring back the old behaviour (always opening Explore in a new tab), flip feature flag `DASHBOARD_EDIT_CHART_IN_NEW_TAB` to `True`.
- [20799](https://github.com/apache/superset/pull/20799): Presto and Trino engine will now display tracking URL for running queries in SQL Lab. If for some reason you don't want to show the tracking URL (for example, when your data warehouse hasn't enable access for to Presto or Trino UI), update `TRACKING_URL_TRANSFORMER` in `config.py` to return `None`.
- [21002](https://github.com/apache/superset/pull/21002): Support Python 3.10 and bump pandas 1.4 and pyarrow 6.
- [21163](https://github.com/apache/superset/pull/21163): When `GENERIC_CHART_AXES` feature flags set to `True`, the Time Grain control will move below the X-Axis control.


### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ export const echartsTimeSeriesQuery: ControlPanelSectionConfig = {
expanded: true,
controlSetRows: [
[isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? 'x_axis' : null],
[
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)
? 'time_grain_sqla'
: null,
],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '../types';

// A few standard controls sections that are used internally.
Expand All @@ -38,19 +38,6 @@ export const legacyTimeseriesTime: ControlPanelSectionConfig = {
],
};

export const genericTime: ControlPanelSectionConfig = {
...baseTimeSection,
controlSetRows: [
['granularity_sqla'],
[
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)
? null
: 'time_grain_sqla',
],
['time_range'],
],
};

export const legacyRegularTime: ControlPanelSectionConfig = {
...baseTimeSection,
controlSetRows: [['granularity_sqla'], ['time_range']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ import {
ComparisionType,
QueryResponse,
QueryColumn,
isAdhocColumn,
isPhysicalColumn,
} from '@superset-ui/core';

import {
Expand Down Expand Up @@ -325,21 +323,6 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
mapStateToProps: ({ datasource }) => ({
choices: (datasource as Dataset)?.time_grain_sqla || null,
}),
visibility: ({ controls }) => {
if (!isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)) {
return true;
}

const xAxis = controls?.x_axis;
const xAxisValue = xAxis?.value;
if (xAxisValue === undefined || isAdhocColumn(xAxisValue)) {
return true;
}
if (isPhysicalColumn(xAxisValue)) {
return !!xAxis?.options?.[xAxisValue]?.is_dttm;
}
return false;
},
};

const time_range: SharedControlConfig<'DateFilterControl'> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { QueryFieldAliases, QueryFormData } from './types/QueryFormData';
import { QueryContext, QueryObject } from './types/Query';
import { SetDataMaskHook } from '../chart';
import { JsonObject } from '../connection';
import { isFeatureEnabled, FeatureFlag } from '../utils';
import { normalizeTimeColumn } from './normalizeTimeColumn';

const WRAP_IN_ARRAY = (baseQueryObject: QueryObject) => [baseQueryObject];

Expand All @@ -47,16 +45,13 @@ export default function buildQueryContext(
typeof options === 'function'
? { buildQuery: options, queryFields: {} }
: options || {};
let queries = buildQuery(buildQueryObject(formData, queryFields));
const queries = buildQuery(buildQueryObject(formData, queryFields));
queries.forEach(query => {
if (Array.isArray(query.post_processing)) {
// eslint-disable-next-line no-param-reassign
query.post_processing = query.post_processing.filter(Boolean);
}
});
if (isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)) {
queries = queries.map(query => normalizeTimeColumn(formData, query));
}
return {
datasource: new DatasourceKey(formData.datasource).toObject(),
force: formData.force || false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export { default as getColumnLabel } from './getColumnLabel';
export { default as getMetricLabel } from './getMetricLabel';
export { default as DatasourceKey } from './DatasourceKey';
export { default as normalizeOrderBy } from './normalizeOrderBy';
export { normalizeTimeColumn } from './normalizeTimeColumn';

export * from './types/AnnotationLayer';
export * from './types/QueryFormData';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export interface AdhocColumn {
optionName?: string;
sqlExpression: string;
expressionType: 'SQL';
columnType?: 'BASE_AXIS' | 'SERIES';
timeGrain?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
import { buildQueryContext } from '@superset-ui/core';
import * as queryModule from '../../src/query/normalizeTimeColumn';

describe('buildQueryContext', () => {
it('should build datasource for table sources and apply defaults', () => {
Expand Down Expand Up @@ -123,50 +122,4 @@ describe('buildQueryContext', () => {
},
]);
});
it('should call normalizeTimeColumn if GENERIC_CHART_AXES is enabled', () => {
// @ts-ignore
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
featureFlags: {
GENERIC_CHART_AXES: true,
},
}));
const spyNormalizeTimeColumn = jest.spyOn(
queryModule,
'normalizeTimeColumn',
);

buildQueryContext(
{
datasource: '5__table',
viz_type: 'table',
},
() => [{}],
);
expect(spyNormalizeTimeColumn).toBeCalled();
spy.mockRestore();
spyNormalizeTimeColumn.mockRestore();
});
it("shouldn't call normalizeTimeColumn if GENERIC_CHART_AXES is disabled", () => {
// @ts-ignore
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
featureFlags: {
GENERIC_CHART_AXES: false,
},
}));
const spyNormalizeTimeColumn = jest.spyOn(
queryModule,
'normalizeTimeColumn',
);

buildQueryContext(
{
datasource: '5__table',
viz_type: 'table',
},
() => [{}],
);
expect(spyNormalizeTimeColumn).not.toBeCalled();
spy.mockRestore();
spyNormalizeTimeColumn.mockRestore();
});
});
Loading

0 comments on commit a5d2834

Please sign in to comment.