You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/10/17 12:16:06 UTC

[GitHub] [superset] zhaoyongjie commented on a diff in pull request #21767: feat: support mulitple temporal filters in AdhocFilter and move the Time Section away

zhaoyongjie commented on code in PR #21767:
URL: https://github.com/apache/superset/pull/21767#discussion_r996982674


##########
superset-frontend/packages/superset-ui-core/src/query/buildQueryContext.ts:
##########
@@ -48,15 +53,26 @@ export default function buildQueryContext(
       ? { buildQuery: options, queryFields: {} }
       : options || {};
   let queries = buildQuery(buildQueryObject(formData, queryFields));
+  // --- query mutator begin ---
+  // todo(Yongjie): move the query mutator into buildQueryObject instead of buildQueryContext
   queries.forEach(query => {
     if (Array.isArray(query.post_processing)) {
       // eslint-disable-next-line no-param-reassign
       query.post_processing = query.post_processing.filter(Boolean);
     }
+    if (hasGenericChartAxes && query.time_range) {
+      // eslint-disable-next-line no-param-reassign
+      query.filters = ensureIsArray(query.filters).map(flt =>
+        flt?.op === 'DATETIME_BETWEEN'
+          ? ({ ...flt, val: query.time_range } as BinaryQueryObjectFilterClause)
+          : flt,
+      );
+    }

Review Comment:
   Yes, it's for applying native filters to the ad-hoc filter on the Dashboard, this part will override all ad-hoc time filters in the charts of the Dashboard.
   
   In the original design is that the chart only has a single time filter so the native filter was designed only to pass `time_range` to every chart rather than pass `time column`(granularity in the QueryObject) and `time value`(time_range in the QueryObject) to the chart.
   
   To solve this issue, I think we might need to specify the time columns in the native filter so that the user knows which time column would apply. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org