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


##########
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:
   [P2] Exclude virtual columns from provider filter pushdown
   
   **Finding:** The extraction checks only the column name and ignores the 
query's virtual columns. A valid local native Scan of `server_properties` can 
define a constant STRING virtual column named `server` with value `alias` and 
filter `server = alias`. Druid's virtualized selectors give that column 
precedence over the physical `server`, so all rows should match, but this 
method pushes the selector to `ServerPropertiesTableDataProvider`, which 
compares `alias` to the actual host:port and returns no rows before the native 
filter runs. The same issue affects `service_name` and Broker fanout when it 
forwards these virtual columns. This silently changes query results.
   
   **Suggestion:** Exclude columns shadowed by query or leaf-scan virtual 
columns from supplier-side pushdown, and add a regression case for a native 
Scan that shadows a pushdown column.



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