FrankChen021 commented on code in PR #20183:
URL: https://github.com/apache/druid/pull/20183#discussion_r4236460168


##########
server/src/main/java/org/apache/druid/server/system/table/SystemTablePushdownFilter.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.
+ */
+
+package org.apache.druid.server.system.table;
+
+import org.apache.druid.query.Query;
+import org.apache.druid.query.filter.AndDimFilter;
+import org.apache.druid.query.filter.BoundDimFilter;
+import org.apache.druid.query.filter.DimFilter;
+import org.apache.druid.query.filter.EqualityFilter;
+import org.apache.druid.query.filter.InDimFilter;
+import org.apache.druid.query.filter.LikeDimFilter;
+import org.apache.druid.query.filter.NotDimFilter;
+import org.apache.druid.query.filter.OrDimFilter;
+import org.apache.druid.query.filter.RangeFilter;
+import org.apache.druid.query.filter.SelectorDimFilter;
+import org.apache.druid.query.filter.TypedInFilter;
+import org.apache.druid.query.operator.OperatorFactory;
+import org.apache.druid.query.operator.ScanOperatorFactory;
+import org.apache.druid.query.operator.WindowOperatorQuery;
+import org.apache.druid.query.ordering.StringComparators;
+import org.apache.druid.segment.column.ColumnType;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Declares a pushdown-capable system-table column and its optional 
supplier-side name.
+ */
+public record SystemTablePushdownFilter(String key, @Nullable String value)
+{
+  public static List<DimFilter> extract(
+      final Query<?> query,
+      final List<SystemTablePushdownFilter> pushdownFilters
+  )
+  {
+    if (pushdownFilters.isEmpty()) {
+      return Collections.emptyList();
+    }
+    final Map<String, String> columnMappings = 
pushdownFilters.stream().collect(
+        Collectors.toMap(
+            SystemTablePushdownFilter::key,
+            filter -> filter.value() == null ? filter.key() : filter.value()
+        )
+    );
+
+    final List<DimFilter> extracted = new ArrayList<>();
+    extractConjuncts(query.getFilter(), columnMappings, extracted);

Review Comment:
   Fixed in `12d36e8233`.
   
   Reproduced first: the new 
`SystemTableQueryHandlerTest#testFilterOnVirtualColumnShadowingPushdownColumnKeepsMatchingRows`
 runs a local `server_properties` Scan with a constant virtual column `server = 
'alias'` and filter `server = 'alias'`. On the previous head it returned 0 rows 
(expected 1) because the provider compared `alias` against the physical 
host:port; with the fix it returns the expected row.
   
   `SystemTablePushdownFilter.extract` now excludes pushdown columns shadowed 
by query or window leaf-scan virtual columns, so those filters stay in the 
native scan. Non-shadowed conjuncts are still pushed down. Broker fanout 
forwards the virtual columns together with the pushed filter, so the node-side 
extraction applies the same rule. Also added extraction-level regression tests 
in `SystemTablePushdownFilterTest` for the query-level and window leaf-scan 
cases.



-- 
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]

Reply via email to