You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/06/27 08:28:36 UTC
(superset) branch msyavuz/feat/add-timeshift-overrides-capability created (now fb64db8829)
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a change to branch msyavuz/feat/add-timeshift-overrides-capability
in repository https://gitbox.apache.org/repos/asf/superset.git
at fb64db8829 feat(Table): add infrastructure to override time shifts
This branch includes the following new commits:
new fb64db8829 feat(Table): add infrastructure to override time shifts
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: feat(Table): add infrastructure to override time shifts
Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/feat/add-timeshift-overrides-capability
in repository https://gitbox.apache.org/repos/asf/superset.git
commit fb64db8829c3caa6b81f64f7c1ef580df1f91024
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Jun 27 11:27:23 2025 +0300
feat(Table): add infrastructure to override time shifts
---
superset-frontend/packages/superset-ui-core/src/query/constants.ts | 1 +
superset-frontend/packages/superset-ui-core/src/query/types/Query.ts | 2 ++
.../packages/superset-ui-core/src/query/types/QueryFormData.ts | 5 +++--
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts | 4 ++++
4 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/query/constants.ts b/superset-frontend/packages/superset-ui-core/src/query/constants.ts
index 7976e87a4a..0c2df20d3a 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/constants.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/constants.ts
@@ -48,6 +48,7 @@ export const EXTRA_FORM_DATA_OVERRIDE_REGULAR_MAPPINGS: Record<
time_column: 'time_column',
time_grain: 'time_grain',
time_range: 'time_range',
+ time_compare: 'time_compare',
};
export const EXTRA_FORM_DATA_OVERRIDE_REGULAR_KEYS = Object.keys(
diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts b/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts
index 49fc4b4363..5929fcec15 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/types/Query.ts
@@ -71,6 +71,8 @@ export type QueryObjectExtras = Partial<{
where?: string;
/** Instant Time Comparison */
instant_time_comparison_range?: string;
+
+ time_compare?: string;
}>;
export type ResidualQueryObjectData = {
diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts
index ddc467b2c4..4982a908f2 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts
@@ -122,7 +122,7 @@ export type ExtraFormDataAppend = {
* filter clauses can't be overridden */
export type ExtraFormDataOverrideExtras = Pick<
QueryObjectExtras,
- 'relative_start' | 'relative_end' | 'time_grain_sqla'
+ 'relative_start' | 'relative_end' | 'time_grain_sqla' | 'time_compare'
>;
/** These parameters override those already present in the form data/query object */
@@ -131,7 +131,7 @@ export type ExtraFormDataOverrideRegular = Partial<
> &
Partial<Pick<SqlaFormData, 'granularity'>> &
Partial<Pick<BaseFormData, 'time_range'>> &
- Partial<Pick<QueryObject, 'time_column' | 'time_grain'>>;
+ Partial<Pick<QueryObject, 'time_column' | 'time_grain' | 'time_compare'>>;
/** These parameters override those already present in the form data/query object */
export type ExtraFormDataOverride = ExtraFormDataOverrideRegular &
@@ -187,6 +187,7 @@ export interface BaseFormData extends TimeRange, FormDataResidual {
series_columns?: QueryFormColumn[];
series_limit?: number;
series_limit_metric?: QueryFormMetric;
+ time_compare?: [string];
}
/**
diff --git a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
index e269dbb370..4e9f5655b3 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
+++ b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
@@ -116,6 +116,10 @@ const buildQuery: BuildQuery<TableChartFormData> = (
}
}
+ if (extra_form_data?.time_compare) {
+ timeOffsets = [extra_form_data.time_compare];
+ }
+
let temporalColumnAdded = false;
let temporalColumn = null;