jtuglu1 commented on code in PR #19718:
URL: https://github.com/apache/druid/pull/19718#discussion_r3634135807
##########
sql/src/main/java/org/apache/druid/sql/calcite/schema/SystemSchema.java:
##########
@@ -517,6 +536,118 @@ private Iterator<AvailableSegmentMetadata>
getAuthorizedAvailableSegments(
return authorizedSegments.iterator();
}
+ /**
+ * Best-effort extraction of an exact-match {@code datasource} constraint
(column
+ * {@link #DATASOURCE_COLUMN}) from the pushed-down filters, so
sys.segments can restrict its scan
+ * to the matching datasources rather than materializing every segment in
the cluster. Handles
+ * {@code datasource = 'x'}, {@code datasource IN (...)} (normalized by
Calcite to SEARCH),
+ * OR-of-equalities, and conjunctions - including a whole {@code WHERE}
passed as a single
+ * {@code AND(...)} RexCall (as Calcite's filter-scan rule may do), where
any non-datasource
+ * conjunct (e.g. {@code is_active = 1}) is simply ignored. Returns {@code
null} when no usable
+ * datasource predicate is present, in which case the previous full-scan
behavior is retained.
+ * Because the filters are not removed from the planner's filter list,
Calcite still applies them
+ * and correctness holds even if this extraction is conservative or
over-broad.
+ */
+ @Nullable
+ static Set<String> getDataSourceFilter(List<RexNode> filters)
Review Comment:
added filter pushdown support for that table as well.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]