Gabriel39 commented on code in PR #67904:
URL: https://github.com/apache/doris/pull/67904#discussion_r3999318128
##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonPredicateConverter.java:
##########
@@ -329,15 +328,10 @@ private Object convertLiteralValue(ConnectorLiteral
literal, DataType paimonType
}
return null;
case TIMESTAMP_WITHOUT_TIME_ZONE:
- // Zone-free type: interpret the literal's wall-clock in UTC
to match paimon's
- // stored min/max file/partition stats (computed by reading
the wall clock as UTC).
- // Mirrors legacy PaimonValueConverter#visit(TimestampType),
which uses a fixed
- // GMT Calendar. Using the session zone here would shift the
epoch-millis vs the
- // stored stats and risk false file/partition pruning = silent
data loss.
+ // Preserve the complete wall-clock value: narrowing it to
epoch milliseconds can
+ // make Paimon prune every file matching a
non-millisecond-aligned predicate.
if (value instanceof LocalDateTime) {
- LocalDateTime dt = (LocalDateTime) value;
- long millis = dt.toInstant(ZoneOffset.UTC).toEpochMilli();
- return Timestamp.fromEpochMillis(millis);
Review Comment:
Fixed in 75ceac12b8. Comparisons against TIMESTAMP(7..9) remain residual
because Doris truncates to microseconds. The TIMESTAMP(9) test checks every
comparison operator with nonzero sub-microsecond digits.
##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonScanParams.java:
##########
@@ -196,8 +197,12 @@ public static FileStoreTable applyOptionsWithoutTimeTravel(
.filter(key -> !tableOptions.containsKey(key))
.forEach(key -> isolatedOptions.put(key, null));
}
- // The statement fence already selected the schema generation.
Preserve that generation
- // while carrying only the resolved read selector and execution
options into this copy.
+ String schemaId = options.get(BOUND_SCHEMA_ID);
+ if (schemaId != null && table.schema().id() !=
Long.parseLong(schemaId)) {
+ // A cached table can predate binding, and latest can advance
again after binding.
+ // Copy the exact schema while retaining catalog options,
decorators and branch identity.
Review Comment:
Fixed in 75ceac12b8. Main and fallback schemas are restored independently,
retaining each branch identity and the privilege wrapper. The real Paimon test
verifies both branches remain readable and privilege denial still applies.
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/mvcc/PluginDrivenMvccExternalTable.java:
##########
@@ -172,6 +172,14 @@ private PluginDrivenMvccSnapshot materializeLatest(
// legacy listPartitions/LIST/timestamp path below (byte-unchanged;
the no-op applySnapshot for the
// latest pin is side-effect-free for both paimon and iceberg).
ConnectorTableHandle pinnedHandle = metadata.applySnapshot(session,
handle, connectorSnapshot);
+ PluginDrivenSchemaCacheValue pinnedSchema = null;
+ if (connectorSnapshot.getSchemaId() >= 0) {
+ // Latest data and schema can advance independently. Keep the
connector's exact schema
+ // on the statement pin so analysis cannot fall back to a
different cached generation.
+ ConnectorTableSchema atSchema = metadata.getTableSchema(session,
pinnedHandle, connectorSnapshot);
Review Comment:
Fixed in 75ceac12b8. Iceberg schema assembly derives partition columns and
the partition clause from the pinned schema/spec coordinate. The warm
latest-cache test covers a concurrent source-column rename and spec update.
##########
regression-test/suites/external_table_p0/paimon/test_paimon_schema_only_snapshot_precision.groovy:
##########
@@ -0,0 +1,125 @@
+// 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.
+
+suite("test_paimon_schema_only_snapshot_precision", "p0,external,paimon") {
+ String enabled = context.config.otherConfigs.get("enablePaimonTest")
+ if (enabled == null || !enabled.equalsIgnoreCase("true")) {
+ logger.info("disable paimon test")
+ return
+ }
+
+ String minioPort = context.config.otherConfigs.get("iceberg_minio_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String catalogName = "test_paimon_schema_only_snapshot_precision"
+ String dbName = "paimon_schema_only_snapshot_precision_db"
+ String tableName = "schema_only_timeline"
+ String branchName = "schema_only_branch"
+
+ def latestSnapshotId = {
+ List<List<Object>> rows = spark_paimon """
+ select snapshot_id
+ from paimon.${dbName}.`${tableName}\$snapshots`
+ order by snapshot_id desc
+ limit 1
+ """
+ assertEquals(1, rows.size())
+ return rows[0][0].toString()
+ }
+
+ sql """drop catalog if exists ${catalogName}"""
+ sql """
+ create catalog ${catalogName} properties (
+ 'type'='paimon',
+ 'warehouse'='s3://warehouse/wh',
+ 's3.endpoint'='http://${externalEnvIp}:${minioPort}',
+ 's3.access_key'='admin',
+ 's3.secret_key'='password',
+ 's3.path.style.access'='true',
+ 'meta.cache.paimon.table.ttl-second'='0'
+ )
+ """
+
+ try {
+ // Explicit NTZ makes this exercise predicate pushdown instead of LTZ
residual filtering.
+ spark_paimon_multi """
+ create database if not exists paimon.${dbName};
+ drop table if exists paimon.${dbName}.${tableName};
+ create table paimon.${dbName}.${tableName} (
+ id int,
+ old_name string,
+ event_time timestamp_ntz
+ ) using paimon
+ tblproperties ('file.format'='parquet');
+ insert into paimon.${dbName}.${tableName}
+ values (1, 'base', timestamp_ntz '2024-01-01 00:00:00.123456');
+ """
+ String dataSnapshotId = latestSnapshotId()
+ spark_paimon_multi """
+ call paimon.sys.create_tag(
+ table => '${dbName}.${tableName}',
+ tag => 'schema_base'
+ );
+ call paimon.sys.create_branch(
+ '${dbName}.${tableName}',
+ '${branchName}',
+ 'schema_base'
+ );
+ alter table paimon.${dbName}.`${tableName}\$branch_${branchName}`
+ rename column old_name to branch_name;
+ alter table paimon.${dbName}.${tableName}
+ rename column old_name to current_name;
+ """
+
+ // A schema-only rename must leave the data snapshot unchanged;
otherwise these queries
+ // would not exercise the split between current schema binding and
snapshot-pinned data.
+ assertEquals(dataSnapshotId, latestSnapshotId())
+
+ sql """switch ${catalogName}"""
+ sql """use ${dbName}"""
+ sql """refresh table ${tableName}"""
+
+ assertEquals([[1, "base"]], sql("""
Review Comment:
Fixed in 75ceac12b8. All five deterministic result checks use order_qt_
labels. The regression harness generated the output baseline, and a second run
passed all five comparisons, including native and JNI reads.
--
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]