Skip to content

Commit

Permalink
fix: BigQuery cannot accept Time Grain (apache#21489)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie authored Sep 16, 2022
1 parent 324e997 commit 33509ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
DEFAULT_NUMBER_FORMAT,
} from '../utils';
import { TIME_FILTER_LABELS } from '../constants';
import { SharedControlConfig, Dataset } from '../types';
import { SharedControlConfig, Dataset, ColumnMeta } from '../types';

import {
dndAdhocFilterControl,
Expand Down Expand Up @@ -197,12 +197,10 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
if (isAdhocColumn(xAxisValue)) {
return true;
}
if (isPhysicalColumn(xAxisValue) && Array.isArray(xAxis?.options)) {
for (let i = 0; i < xAxis.options.length; i += 1) {
if (xAxis.options[i].column_name === xAxisValue) {
return !!xAxis.options[i].is_dttm;
}
}
if (isPhysicalColumn(xAxisValue)) {
return !!(xAxis?.options ?? []).find(
(col: ColumnMeta) => col?.column_name === xAxisValue,
)?.is_dttm;
}
return false;
},
Expand Down
7 changes: 4 additions & 3 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,9 +1144,10 @@ def adhoc_column_to_sqla(
and (time_grain := col.get("timeGrain"))
):
sqla_column = self.db_engine_spec.get_timestamp_expr(
sqla_column,
None,
time_grain,
col=sqla_column,
pdf=None,
time_grain=time_grain,
type_=str(getattr(sqla_column, "type", "")),
)
return self.make_sqla_column_compatible(sqla_column, label)

Expand Down

0 comments on commit 33509ab

Please sign in to comment.