github-actions[bot] commented on code in PR #65853: URL: https://github.com/apache/doris/pull/65853#discussion_r3671863931
########## fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterPartitionColumnResolver.java: ########## @@ -0,0 +1,89 @@ +// 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.doris.planner; + +import org.apache.doris.analysis.Expr; +import org.apache.doris.analysis.SlotRef; +import org.apache.doris.catalog.Column; +import org.apache.doris.catalog.OlapTable; + +import java.util.List; + +/** + * Resolves a selected-index column to its base-table partition column. + */ +public final class RuntimeFilterPartitionColumnResolver { + private RuntimeFilterPartitionColumnResolver() { + } + + /** + * Returns the matching partition-column ordinal, or -1 when the target is + * not a value-preserving representation of a base partition column. + */ + public static int findPartitionColumnIndex(OlapScanNode scanNode, Column targetColumn) { + if (targetColumn == null) { + return -1; + } + OlapTable table = scanNode.getOlapTable(); + List<Column> partitionColumns = table.getPartitionInfo().getPartitionColumns(); + if (targetColumn.isMaterializedViewColumn()) { Review Comment: **[P1] Do not trust inherited MV definitions after a derived rollup** `targetColumn.isAggregated()` is not stable provenance across index construction. For a DUP table partitioned by BIGINT `k`, create `mv_sum AS SELECT grp AS mv_grp, SUM(k) AS sum_k GROUP BY grp`, then `ADD ROLLUP r_sum(sum_k) FROM mv_sum`. The handler copies `sum_k` with its bare `defineExpr=SlotRef(k)`, but DUP-key conversion calls `setIsKey(true)` and clears the copied `SUM` marker. The rollup job reads `mv_sum`, so `r_sum` stores the aggregate value: raw `k=6,7` in partition `[0,10)` becomes `sum_k=13`. This branch now sees a non-aggregated column plus a `SlotRef`, resolves `r_sum.sum_k` to base partition `k`, and serializes `[0,10)` under the `sum_k` RF slot. An RF `{13}` can therefore prune the partition containing the matching row. This is distinct from the existing direct aggregate-MV thread: the direct target retains `SUM` and is rejected, while this second index erases that marker. Please require value-preserving lineage through every index hop (or conservatively reject inherited definitions on derived rollups) and add a direct `r_sum` regression that returns `13` with `0/0` RF partition-pruning counters. -- 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]
