github-actions[bot] commented on code in PR #65984: URL: https://github.com/apache/doris/pull/65984#discussion_r3649648766
########## fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonScanParams.java: ########## @@ -0,0 +1,113 @@ +// 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.datasource.paimon; + +import org.apache.doris.analysis.TableScanParams; + +import com.google.common.collect.ImmutableSet; +import org.apache.paimon.CoreOptions; +import org.apache.paimon.table.Table; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Validation and application rules for relation-scoped Paimon scan parameters. + */ +public final class PaimonScanParams { + private static final Set<String> QUERY_OPTION_KEYS = CoreOptions.getOptions().stream() + .map(option -> option.key()) + .filter(key -> key.startsWith("scan.")) + .collect(Collectors.toSet()); + + private static final Set<String> SNAPSHOT_SELECTOR_KEYS = ImmutableSet.of( + CoreOptions.SCAN_SNAPSHOT_ID.key(), + CoreOptions.SCAN_TAG_NAME.key(), + CoreOptions.SCAN_TIMESTAMP.key(), + CoreOptions.SCAN_TIMESTAMP_MILLIS.key(), + CoreOptions.SCAN_WATERMARK.key(), + CoreOptions.SCAN_VERSION.key()); + + private static final Set<String> INCREMENTAL_SYSTEM_TABLES = ImmutableSet.of( + "audit_log", "binlog", "row_tracking"); + + private static final Set<String> OPTIONS_SYSTEM_TABLES = ImmutableSet.of( Review Comment: [P2] Include system tables that actually consume snapshot OPTIONS This allowlist rejects `$buckets` and `$table_indexes`, although Paimon 1.3.1 implements `copy(dynamicOptions)` for both by copying the wrapped data table. Their readers then use that selected table snapshot (`newSnapshotReader().bucketEntries()` and `TimeTravelUtil.tryTravelOrLatest`, respectively), just like the accepted metadata readers. As a result, valid historical queries are rejected during binding before Paimon can apply the option. Please derive the capability from the actual system-table behavior or include these parallel readers, with snapshot-sensitive result tests. ########## fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java: ########## @@ -106,6 +106,22 @@ public Table getPaimonTable(Optional<MvccSnapshot> snapshot) { } } + public Table getPaimonTable(TableScanParams scanParams) { + if (scanParams != null && scanParams.isOptions()) { + // Statement MVCC is keyed by table, while OPTIONS belongs to one relation. Start + // from the catalog handle so its schema cannot inherit another relation's selector. + return PaimonScanParams.applyOptions(getBasePaimonTable(), scanParams.getMapParams()); Review Comment: [P1] Resolve mutable tags once for the relation `computeOutput()` calls this method to bind the relation schema, but scan initialization later calls `getPaimonTable(scanParams)` again. A `scan.tag-name` option (or a `scan.version` that resolves to a tag) remains in the copied table options, so Paimon resolves the mutable tag again when planning/reading. If an external writer replaces that tag between the two phases, the query binds snapshot-1 columns but can read snapshot-2 rows (or fail on a schema mismatch), violating statement-level consistency. Please resolve the tag once to an immutable snapshot/schema ID and carry that same relation snapshot through binding and execution. ########## fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonScanNode.java: ########## @@ -269,7 +288,9 @@ private void setPaimonParams(TFileRangeDesc rangeDesc, PaimonSplit paimonSplit) // use jni reader or paimon-cpp reader rangeDesc.setFormatType(TFileFormatType.FORMAT_JNI); // Use Paimon native serialization for paimon-cpp reader - if (sessionVariable.isEnablePaimonCppReader() && split instanceof DataSplit) { + if (sessionVariable.isEnablePaimonCppReader() Review Comment: [P1] Keep schema-selecting OPTIONS off the latest-schema C++ reader Serializing `processedTable` fixes JNI, but ordinary historical OPTIONS scans can still enter `PAIMON_CPP`. That reader sends the bound Doris slot names to `ReadContextBuilder(table_path)` without `SetTableSchema`; the pinned paimon-cpp then loads `SchemaManager.Latest()` and resolves every name there. After `old_name` is renamed, `select old_name from t@options('scan.snapshot-id'='1')` binds successfully in FE but fails in C++ because `old_name` is absent from the latest schema. Please either pass the processed schema to the C++ context or force schema-selecting OPTIONS to JNI/native, and add an evolved-schema OPTIONS test with C++ enabled. -- 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]
