github-actions[bot] commented on code in PR #65853: URL: https://github.com/apache/doris/pull/65853#discussion_r3675436844
########## fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterPartitionColumnResolver.java: ########## @@ -0,0 +1,92 @@ +// 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()) { + if (table.getIndexMetaByIndexId(scanNode.getSelectedIndexId()).getDefineStmt() == null) { Review Comment: **[P1] Do not trust positional MV definitions after a schema reorder** A direct sync MV can be reordered with `ALTER TABLE ... ORDER BY (...) FROM <mv>`. The schema-change job preserves the MV's `defineStmt`, and `MaterializedIndexMeta.parseStmt()` later assigns the original select-list expressions to the *current* schema by ordinal, while the schema-change data path copies the reordered columns by name. For `SELECT k AS mv_k, v AS mv_v`, reordering the MV to `(mv_v, mv_k)` can therefore leave `mv_v` storing `v` but carrying `SlotRef(k)`. This check accepts that stale definition. A forced scan joining `mv_v = 107` for a row `(k=7, v=107)` then serializes `k`'s `[0,10)` boundary under the `mv_v` slot, so RF `{107}` can prune the partition containing the matching row. Please bind lineage by stable MV output identity/name, or conservatively reject reordered direct-MV metadata, and add a forced-index regression covering this reorder. -- 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]
