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 Time Filter in 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-unsubscr...@superset.apache.org

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


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

Reply via email to