-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: explicit distribute columns on BoxPlot and apply time grain (#2…
- Loading branch information
1 parent
23cd5c9
commit 93f08e7
Showing
13 changed files
with
466 additions
and
63 deletions.
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
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
64 changes: 64 additions & 0 deletions
64
superset-frontend/packages/superset-ui-chart-controls/src/utils/getTemporalColumns.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,64 @@ | ||
/** | ||
* 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 { | ||
ensureIsArray, | ||
isDefined, | ||
QueryColumn, | ||
ValueOf, | ||
} from '@superset-ui/core'; | ||
import { | ||
ColumnMeta, | ||
ControlPanelState, | ||
isDataset, | ||
isQueryResponse, | ||
} from '@superset-ui/chart-controls'; | ||
|
||
export const getTemporalColumns = ( | ||
datasource: ValueOf<Pick<ControlPanelState, 'datasource'>>, | ||
) => { | ||
const rv: { | ||
temporalColumns: ColumnMeta[] | QueryColumn[]; | ||
defaultTemporalColumn: string | null | undefined; | ||
} = { | ||
temporalColumns: [], | ||
defaultTemporalColumn: undefined, | ||
}; | ||
|
||
if (isDataset(datasource)) { | ||
rv.temporalColumns = ensureIsArray(datasource.columns).filter( | ||
c => c.is_dttm, | ||
); | ||
} | ||
if (isQueryResponse(datasource)) { | ||
rv.temporalColumns = ensureIsArray(datasource.columns).filter( | ||
c => c.is_dttm, | ||
); | ||
} | ||
|
||
if (isDataset(datasource)) { | ||
rv.defaultTemporalColumn = datasource.main_dttm_col; | ||
} | ||
if (!isDefined(rv.defaultTemporalColumn)) { | ||
rv.defaultTemporalColumn = | ||
(rv.temporalColumns[0] as ColumnMeta)?.column_name ?? | ||
(rv.temporalColumns[0] as QueryColumn)?.name; | ||
} | ||
|
||
return rv; | ||
}; |
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
149 changes: 149 additions & 0 deletions
149
superset-frontend/packages/superset-ui-chart-controls/test/fixtures.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,149 @@ | ||
/** | ||
* 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 { Dataset } from '@superset-ui/chart-controls'; | ||
import { DatasourceType } from '@superset-ui/core'; | ||
|
||
export const TestDataset: Dataset = { | ||
column_format: {}, | ||
columns: [ | ||
{ | ||
advanced_data_type: null, | ||
certification_details: null, | ||
certified_by: null, | ||
column_name: 'num', | ||
description: null, | ||
expression: '', | ||
filterable: true, | ||
groupby: true, | ||
id: 332, | ||
is_certified: false, | ||
is_dttm: false, | ||
python_date_format: null, | ||
type: 'BIGINT', | ||
type_generic: 0, | ||
verbose_name: null, | ||
warning_markdown: null, | ||
}, | ||
{ | ||
advanced_data_type: null, | ||
certification_details: null, | ||
certified_by: null, | ||
column_name: 'gender', | ||
description: null, | ||
expression: '', | ||
filterable: true, | ||
groupby: true, | ||
id: 330, | ||
is_certified: false, | ||
is_dttm: false, | ||
python_date_format: null, | ||
type: 'VARCHAR(16)', | ||
type_generic: 1, | ||
verbose_name: '', | ||
warning_markdown: null, | ||
}, | ||
{ | ||
advanced_data_type: null, | ||
certification_details: null, | ||
certified_by: null, | ||
column_name: 'state', | ||
description: null, | ||
expression: '', | ||
filterable: true, | ||
groupby: true, | ||
id: 333, | ||
is_certified: false, | ||
is_dttm: false, | ||
python_date_format: null, | ||
type: 'VARCHAR(10)', | ||
type_generic: 1, | ||
verbose_name: null, | ||
warning_markdown: null, | ||
}, | ||
{ | ||
advanced_data_type: null, | ||
certification_details: null, | ||
certified_by: null, | ||
column_name: 'ds', | ||
description: null, | ||
expression: '', | ||
filterable: true, | ||
groupby: true, | ||
id: 329, | ||
is_certified: false, | ||
is_dttm: true, | ||
python_date_format: null, | ||
type: 'TIMESTAMP WITHOUT TIME ZONE', | ||
type_generic: 2, | ||
verbose_name: null, | ||
warning_markdown: null, | ||
}, | ||
{ | ||
advanced_data_type: null, | ||
certification_details: null, | ||
certified_by: null, | ||
column_name: 'name', | ||
description: null, | ||
expression: '', | ||
filterable: true, | ||
groupby: true, | ||
id: 331, | ||
is_certified: false, | ||
is_dttm: false, | ||
python_date_format: null, | ||
type: 'VARCHAR(255)', | ||
type_generic: 1, | ||
verbose_name: null, | ||
warning_markdown: null, | ||
}, | ||
], | ||
datasource_name: 'birth_names', | ||
description: null, | ||
granularity_sqla: 'ds', | ||
id: 2, | ||
main_dttm_col: 'ds', | ||
metrics: [ | ||
{ | ||
certification_details: null, | ||
certified_by: null, | ||
d3format: null, | ||
description: null, | ||
expression: 'COUNT(*)', | ||
id: 7, | ||
is_certified: false, | ||
metric_name: 'count', | ||
verbose_name: 'COUNT(*)', | ||
warning_markdown: '', | ||
warning_text: null, | ||
}, | ||
], | ||
name: 'public.birth_names', | ||
order_by_choices: [], | ||
owners: [ | ||
{ | ||
first_name: 'admin', | ||
id: 1, | ||
last_name: 'user', | ||
username: 'admin', | ||
}, | ||
], | ||
type: DatasourceType.Dataset, | ||
uid: '2__table', | ||
verbose_map: {}, | ||
}; |
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
Oops, something went wrong.