+In the dataset editor's **Columns** tab, use **Default time filter** beside
+**Default datetime column** to set the range of the time filters Explore adds
+for this dataset, for example on a new chart or when you add a datetime column
+to the filters. Opening a saved chart doesn't change its range.
+**Use instance default** inherits the administrator's setting, and **No filter**
+means an unbounded range. Chart authors can change the range before saving
+their charts.
+
#### Snowflake column name casing
For physical Snowflake datasets, Superset uses the dialect's automatic identifier
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/dndControls.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/dndControls.tsx
index 6a7ad9f2658d..5fdb71ba15b5 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/dndControls.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/dndControls.tsx
@@ -34,10 +34,12 @@ import {
ColumnOption,
ColumnMeta,
FilterOption,
+} from '..';
+import {
temporalColumnMixin,
datePickerInAdhocFilterMixin,
xAxisMixin,
-} from '..';
+} from './mixins';
type Control = {
savedMetrics?: Metric[] | null;
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/mixins.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/mixins.tsx
index 840dfc3a35f1..683e93f67e17 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/mixins.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/mixins.tsx
@@ -29,7 +29,7 @@ import {
ControlState,
ExtraControlProps,
} from '../types';
-import { getTemporalColumns } from '../utils';
+import { getDatasetDefaultTimeFilter, getTemporalColumns } from '../utils';
const getAxisLabel = (
formData: QueryFormData,
@@ -114,7 +114,11 @@ export const datePickerInAdhocFilterMixin: Pick<
clause: 'WHERE',
subject: temporalColumn,
operator: 'TEMPORAL_RANGE',
- comparator: state?.common?.conf?.DEFAULT_TIME_FILTER || NO_TIME_RANGE,
+ comparator:
+ state?.initialTimeRange ||
+ getDatasetDefaultTimeFilter(state?.datasource) ||
+ state?.common?.conf?.DEFAULT_TIME_FILTER ||
+ NO_TIME_RANGE,
expressionType: 'SIMPLE',
},
];
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts
index 5bc38c190ece..8d726f8eeb61 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts
@@ -164,6 +164,7 @@ export interface ControlPanelState {
controls: ControlStateMapping;
common: JsonObject;
metadata?: JsonObject | null;
+ initialTimeRange?: string | null;
}
/**
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/utils/getDatasetDefaultTimeFilter.ts b/superset-frontend/packages/superset-ui-chart-controls/src/utils/getDatasetDefaultTimeFilter.ts
new file mode 100644
index 000000000000..f8ea79fd2fe8
--- /dev/null
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/utils/getDatasetDefaultTimeFilter.ts
@@ -0,0 +1,40 @@
+/**
+ * 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 '../types';
+
+/**
+ * Returns the dataset's `extra.default_time_filter`, which Explore uses instead
+ * of the instance `DEFAULT_TIME_FILTER` when it adds a time filter. Unparseable
+ * metadata counts as unset.
+ */
+export function getDatasetDefaultTimeFilter(
+ dataset?: Pick