Skip to content

Commit

Permalink
[cccs-2.0] Fixing case sensitivity (#203)
Browse files Browse the repository at this point in the history
* [cccs-2.0] Fixing case sensitivity

* [cccs-2.0] Pusing temp image

* [cccs-2.0] fixing two order bys

* [cccs-2.0] fixing verbose names, fixing sizing, fixing ordering

* [cccs-2.0] fixing build error

* [cccs-2.0] updating image

* [cccs-2.0] fixing time columns

* [cccs-2.0] Fixing build errors

* [cccs-2.0] updating docker file

* [cccs-2.0] Fixing time column to populate default time col

* Fixing default time col

* [cccs-2.0] updating image

* Fix issue where datasets without a date/datetime column would not load in the explore view

* Time column dropdown list is now properly populated with either the default temporal column, or the first temporal column (if a default is not set)

* Temp update to base image tag

* Fixed the bug where when there are no dttm columns, the non-dttm columns were being displayed

* Temp update to base image tag

* Reverting changes to the img

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>
  • Loading branch information
2 people authored and GITHUB_USERNAME committed Feb 7, 2023
1 parent abe32b3 commit 47f857d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,40 @@ const granularity_sqla: SharedControlConfig<'SelectControl', ColumnMeta> = {
mapStateToProps: state => {
const props: Partial<SelectControlConfig<ColumnMeta | QueryColumn>> = {};
const { datasource } = state;
if (datasource?.columns[0]?.hasOwnProperty('main_dttm_col')) {

if (datasource?.hasOwnProperty('main_dttm_col')) {
const dataset = datasource as Dataset;
props.options = dataset.columns.filter((c: ColumnMeta) => c.is_dttm);
props.default = null;
if (dataset.main_dttm_col) {
props.default = dataset.main_dttm_col;
} else if (props?.options) {
props.default = (props.options[0] as ColumnMeta).column_name;
if (dataset.main_dttm_col !== null) {
if (dataset.main_dttm_col) {
props.default = dataset.main_dttm_col;
} else if (props?.options.length > 0) {
props.default = (props.options[0] as ColumnMeta).column_name;
}
} else {
const sortedQueryColumns = (datasource as QueryResponse)?.columns
?.filter(query => query?.is_dttm === true)
.sort();
props.options = sortedQueryColumns;
if (props?.options.length > 0) {
props.default =
'column_name' in props.options[0]
? props.options[0]?.column_name
: props.options[0]?.name;
}
}
} else {
const sortedQueryColumns = (datasource as QueryResponse)?.columns?.sort(
query => (query?.is_dttm ? -1 : 1),
);
const sortedQueryColumns = (datasource as QueryResponse)?.columns
?.filter(query => query?.is_dttm === true)
.sort();
props.options = sortedQueryColumns;
if (props?.options) props.default = props.options[0]?.name;
if (props?.options.length > 0) {
props.default =
'column_name' in props.options[0]
? props.options[0]?.column_name
: props.options[0]?.name;
}
}
return props;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,6 @@ const defineSavedMetrics = (
? (datasource as Dataset)?.metrics || []
: DEFAULT_METRICS;

const columnChoices = (datasource: any) => {
if (datasource?.columns) {
return datasource.columns
.map((col : any) => [col.column_name, col.verbose_name || col.column_name])
.sort((opt1: any, opt2: any) =>
opt1[1].toLowerCase() > opt2[1].toLowerCase() ? 1 : -1,
);
}
return [];
}

const config: ControlPanelConfig = {
// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
Expand Down Expand Up @@ -368,22 +357,6 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'order_by_cols',
config: {
type: 'SelectControl',
label: t('Ordering'),
description: t('Order results by selected columns'),
multi: true,
default: [],
mapStateToProps: ({ datasource }) => ({
choices: columnChoices(datasource),
}),
visibility: isRawMode,
},
},
],
[
{
name: 'timeseries_limit_metric',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const ExploreChartPanel = ({
css={css`
min-height: 0;
flex: 1;
overflow: auto;
overflow: hidden;
`}
ref={chartPanelRef}
>
Expand Down
2 changes: 1 addition & 1 deletion superset/advanced_data_type/plugins/internet_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def port_translate_filter_func(


internet_port: AdvancedDataType = AdvancedDataType(
verbose_name="port",
verbose_name="Port",
description="represents of a port",
valid_data_types=["int"],
translate_filter=port_translate_filter_func,
Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
)

col_advanced_data_type: str = col_obj.advanced_data_type if col_obj else ""

col_advanced_data_type = col_advanced_data_type.lower() if col_advanced_data_type else col_advanced_data_type
if col_spec and not col_advanced_data_type:
target_generic_type = col_spec.generic_type
else:
Expand Down

0 comments on commit 47f857d

Please sign in to comment.