This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new b7ce2d24147 branch-4.2: [improvement](fe) Upgrade Paimon to 2.1.0
(#70103)
b7ce2d24147 is described below
commit b7ce2d2414738081c38dd78bded244630ecbf812
Author: Socrates <[email protected]>
AuthorDate: Tue Nov 24 15:41:10 2026 +0800
branch-4.2: [improvement](fe) Upgrade Paimon to 2.1.0 (#70103)
### What problem does this PR solve?
Issue Number: N/A
Related PR: #69343
Backport master commit `949a8061bfcabf51579f1892a5ffb18343aa42bf` to
branch-4.2. Upgrade the shared Paimon Java SDK from 1.4.2 to 2.1.0 for
both FE and the BE JNI connector.
The release branch predates the connector/plugin split on master. Adapt
the changes to its existing `fe-core` Paimon catalog, `paimon-connector`
JNI module, and `PaimonMergePlanner`; do not introduce the master
connector SPI or its module layout.
- Upgrade `hive-catalog-shade` to 4.1.0, which still embeds Hive 3.1.3
but carries Paimon 2.1.0. The old shade bundle embeds Paimon 1.4.2
classes that would otherwise shadow the upgraded SDK.
- Remove references and fixtures for the SDK's removed file-based
privilege APIs, retaining catalog query authorization and existing
fallback-branch coverage.
- Preserve NULL-safe MERGE UPDATE/DELETE with nullable primary keys.
MATCHED-only plans use INNER JOIN semantics; MERGE with INSERT uses a
target-presence marker before the outer join. Keep user expression
binding outside that private marker's scope.
- Preserve deferred `$file_indexes` query authorization on FE, including
each fallback branch. The existing 4.2 MVCC projection supplies the
retained source snapshot to both system-table payloads.
- Reject unsupported `scan.mode=latest-delta` OPTIONS instead of pinning
it as a full snapshot; explicit `@incr` ranges remain available.
- Mirror the existing Hadoop S3 configuration into catalog options for
the 2.1 S3FileIO, while retaining explicit Paimon option precedence.
Apply the shared mapping to filesystem, HMS, JDBC, and DLF catalog
construction.
- Adapt schema-manager and snapshot fixtures, cover default/checked
integer overflow and pre-epoch timestamp-to-date behavior, and enable
the existing BE `java.nio` access in JNI tests.
- Carry over the original nullable-key/SDK regression suites and
runner-generated expected outputs. New vector/full-text/ANN SQL features
remain outside this backport.
The 4.2 MERGE command now shares `MergeUtils.buildMergeJoin` with the
planner's target-left/source-right layout. Previously, the command put
the source on the left, so the planner attached its target-presence
marker to the preserved source. An unmatched row then selected MATCHED
and wrote a NULL target key instead of INSERT.
```text
Before: source LEFT OUTER JOIN target
marker=1 -> unmatched source is classified as
MATCHED
After: target RIGHT OUTER JOIN source
marker=1 -> missing target produces a NULL marker
and selects INSERT
```
The compatibility regression keeps logical splits enabled when asserting
Rust-reader execution, and nullable-key MERGE error expectations use the
4.2 implementation's Paimon diagnostics.
### Release note
Upgrade the Paimon Java SDK to 2.1.0. Fix NULL-safe MERGE matched
UPDATE/DELETE for nullable primary keys; preserve `$file_indexes`
authorization and reject unsupported `latest-delta` OPTIONS reads.
Paimon 2.1 supports opt-in checked integer aggregation and corrects
pre-epoch timestamp-to-date casts. Its legacy file-based privilege APIs
have been removed; users of that upstream authorization mechanism must
migrate before upgrading.
FE and BE Java extensions must deploy the same SDK. Mixed 1.4.2/2.1.0
rolling-upgrade compatibility is not established.
### Check List (For Author)
- Build/style: FE and JNI packaging completed with `build.sh` using the
latest Linux third-party prebuilt. Checkstyle and `git diff --check`
passed.
- FE unit tests: `run-fe-ut.sh --run 'Paimon*Test,MergeIntoCommandTest'`
completed with 490 passed, 2 environment-gated catalog tests skipped,
and no failures. Both new command-layout tests failed on the original
implementation and passed after the fix.
- Regression framework: rebuilt on branch-4.2; all 47 framework unit
tests passed.
- Local cluster regression: all six affected suites passed against their
existing golden outputs:
- `test_paimon_nullable_key_merge`
- `test_paimon_2_1_compatibility`
- `test_paimon_write_boundary`
- `test_paimon_write_row_level_dml`
- `test_paimon_write_deletion_vector`
- `test_paimon_write_merge_semantics`
- Runtime: locally built FE/JNI with the ASAN BE from this PR's
successful compile job 1092066, MinIO, and the repository's Spark
4.0.0/Paimon 1.4.2 fixtures. FE/JNI use Paimon 2.1.0. The FE-only
follow-up does not include a native C++ change.
- Previous backport validation also covered 100 JNI connector unit
tests.
- Behavior changed: Yes, Paimon 2.1.0 SDK behavior and correct INSERT
classification for unmatched MERGE source rows.
- Does this need documentation: compatibility changes are recorded in
the release note.
### Self-review
- Goal and scope: backport the SDK upgrade and directly affected
behavior to the existing 4.2 layout. No master connector refactor or
search feature is included.
- Concurrency: no new threads, shared mutable state, or lock ordering.
Existing cache/transaction locks are unchanged.
- Lifecycle: no new resource owners or static initialization
dependencies. Tests close local catalog, writer, commit, and reader
resources.
- Configuration: no new configuration key. Existing S3 settings now
reach the SDK's catalog-option reader; explicit Paimon settings retain
precedence.
- Compatibility: the upstream legacy privilege API removal and same-SDK
deployment requirement are documented. Mixed-SDK rolling upgrades are
unverified.
- Protocol: no Thrift/Protobuf schema or field IDs are changed. FE and
BE dependency versions share one property.
- Parallel paths: FE catalog and BE JNI dependencies move together.
Shared S3 mapping covers all Hadoop-backed catalog constructors;
fallback authorization checks both branches.
- Conditions: Command and planner share the target-left/source-right
join contract. The target marker distinguishes a real nullable-key row
from an outer join's null-extension; both branch layouts have
command-level tests. Unsupported delta mode fails explicitly.
- Tests: SDK serialization/nullable-key behavior, MERGE branch selection
and marker-name collisions, deferred authorization, S3 option
precedence, and existing Paimon reader/cache tests are included. Cluster
regression files and goldens are copied from the original PR, not
hand-generated.
- Results: see validation above; original master test totals are not
represented as results for this backport.
- Observability: unsupported delta mode returns an actionable
diagnostic; existing scan error propagation is retained. No new metric
is needed for this adaptation.
- Persistence/transactions: no EditLog or recovery changes. Existing
MERGE cardinality and transaction atomicity logic remains in place;
nullable-key regression coverage includes duplicate-match rejection.
- Writes: only MERGE target-presence classification changes. Writer
commit/abort and storage ownership are unchanged.
- FE/BE variables: none added.
- Performance: no performance improvement is claimed; MERGE adds one
constant target projection only when INSERT branches require an outer
join. S3 options are copied at catalog construction.
- Other concerns: the inspected OBS/S3 CI failures were connection
timeouts and require rerunning CI against those endpoints. Mixed-SDK
upgrades remain unverified.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
---
fe/be-java-extensions/paimon-connector/pom.xml | 7 +
.../org/apache/doris/paimon/PaimonJniScanner.java | 6 +-
.../doris/paimon/PaimonArrowBatchAdapterTest.java | 4 +-
.../apache/doris/paimon/PaimonJniScannerTest.java | 58 +-------
.../PaimonLatestSnapshotProjectionLoader.java | 2 +-
.../paimon/PaimonCacheSizeEstimator.java | 4 +-
.../datasource/paimon/PaimonExternalTable.java | 9 +-
.../datasource/paimon/PaimonReaderOptions.java | 20 +--
.../doris/datasource/paimon/PaimonScanParams.java | 5 +
.../datasource/paimon/PaimonSysExternalTable.java | 21 +++
.../datasource/paimon/PaimonTableDecorators.java | 2 +-
.../source/PaimonRustReaderCapabilities.java | 4 +-
.../metastore/AbstractPaimonProperties.java | 12 ++
.../nereids/rules/analysis/PaimonMergePlanner.java | 27 +++-
.../trees/plans/commands/PaimonMergeCommand.java | 9 +-
.../paimon/PaimonExternalMetaCacheTest.java | 20 ---
.../paimon/PaimonHistoricalSchemaOptionsTest.java | 7 -
.../paimon/PaimonNullableKeyCompatibilityTest.java | 115 +++++++++++++++
.../datasource/paimon/PaimonReaderOptionsTest.java | 88 ++++--------
.../datasource/paimon/PaimonRowCountTest.java | 28 +---
.../datasource/paimon/PaimonScanParamsTest.java | 9 ++
.../source/PaimonRustReaderCompatibilityTest.java | 41 ++++--
.../source/PaimonRustReaderLegacySchemaTest.java | 4 +-
.../metastore/AbstractPaimonPropertiesTest.java | 31 +++++
.../rules/analysis/PaimonMergePlannerTest.java | 154 +++++++++++++++++++++
.../plans/commands/PaimonMergeCommandTest.java | 63 +++++++++
.../PaimonTableValuedFunctionTest.java | 7 +-
fe/pom.xml | 7 +-
.../paimon/paimon_system_table.out | 8 +-
.../paimon/test_paimon_2_1_compatibility.out | 19 +++
.../paimon/test_paimon_nullable_key_merge.out | 83 +++++++++++
.../paimon/test_paimon_2_1_compatibility.groovy | 103 ++++++++++++++
.../paimon/test_paimon_nullable_key_merge.groovy | 133 ++++++++++++++++++
.../write/test_paimon_write_transaction.groovy | 2 +-
34 files changed, 869 insertions(+), 243 deletions(-)
diff --git a/fe/be-java-extensions/paimon-connector/pom.xml
b/fe/be-java-extensions/paimon-connector/pom.xml
index 717b3e6f2ce..52e4962467c 100644
--- a/fe/be-java-extensions/paimon-connector/pom.xml
+++ b/fe/be-java-extensions/paimon-connector/pom.xml
@@ -118,6 +118,13 @@ under the License.
<finalName>paimon-connector</finalName>
<directory>${project.basedir}/target/</directory>
<plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Match the BE JVM access required by Paimon 2.1
Variant buffers. -->
+ <argLine>--add-opens=java.base/java.nio=ALL-UNNAMED
@{argLine}</argLine>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
diff --git
a/fe/be-java-extensions/paimon-connector/src/main/java/org/apache/doris/paimon/PaimonJniScanner.java
b/fe/be-java-extensions/paimon-connector/src/main/java/org/apache/doris/paimon/PaimonJniScanner.java
index 9169e4ac8d2..5fd593f7b1d 100644
---
a/fe/be-java-extensions/paimon-connector/src/main/java/org/apache/doris/paimon/PaimonJniScanner.java
+++
b/fe/be-java-extensions/paimon-connector/src/main/java/org/apache/doris/paimon/PaimonJniScanner.java
@@ -792,8 +792,8 @@ public class PaimonJniScanner extends JniScanner {
if (normalized == wrapped) {
return table;
}
- // FE planning already enforced privilege delegates. Keeping one
here would hide the
- // fallback tree and force a single copied cap onto branches with
independent values.
+ // An outer delegate would hide the fallback tree and force a
single copied cap onto
+ // branches with independent values.
return normalized;
}
@@ -864,7 +864,7 @@ public class PaimonJniScanner extends JniScanner {
private static FileStoreTable unwrapSystemPlanningSource(FileStoreTable
table) {
FileStoreTable current = table;
// System wrappers dispatch fallback reads only when the fallback pair
is their direct
- // source; FE authorization has already run, so privilege-only
delegates must not hide it.
+ // source; outer delegates must not hide the fallback pair from the
system wrapper.
while (current instanceof DelegatedFileStoreTable
&& !(current instanceof FallbackReadFileStoreTable)) {
current = ((DelegatedFileStoreTable) current).wrapped();
diff --git
a/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonArrowBatchAdapterTest.java
b/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonArrowBatchAdapterTest.java
index ba07f0e2ed5..a39582969e3 100644
---
a/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonArrowBatchAdapterTest.java
+++
b/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonArrowBatchAdapterTest.java
@@ -41,7 +41,7 @@ import org.apache.paimon.data.InternalRow;
import org.apache.paimon.data.variant.GenericVariant;
import org.apache.paimon.data.variant.Variant;
import org.apache.paimon.fs.local.LocalFileIO;
-import org.apache.paimon.schema.SchemaManager;
+import org.apache.paimon.schema.FileSystemSchemaManager;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.Table;
import org.apache.paimon.table.sink.BatchTableCommit;
@@ -289,7 +289,7 @@ public class PaimonArrowBatchAdapterTest {
.column("ts", DataTypes.TIMESTAMP(precision).notNull())
.column("detail", DataTypes.ROW(DataTypes.FIELD(0,
"t", DataTypes.TIMESTAMP(precision))))
.primaryKey("ts").option("bucket",
"1").option("file.format", format).build();
- new SchemaManager(fileIO, path).createTable(schema);
+ new FileSystemSchemaManager(fileIO, path).createTable(schema);
Table table = FileStoreTableFactory.create(fileIO, path);
PaimonWriteSchema writeSchema =
PaimonWriteSchema.create(table.rowType(), new String[] {"ts", "detail"});
BatchWriteBuilder builder = table.newBatchWriteBuilder();
diff --git
a/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonJniScannerTest.java
b/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonJniScannerTest.java
index bce0c5950e7..8024bc15cc7 100644
---
a/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonJniScannerTest.java
+++
b/fe/be-java-extensions/paimon-connector/src/test/java/org/apache/doris/paimon/PaimonJniScannerTest.java
@@ -28,18 +28,14 @@ import
org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.Property;
import org.apache.paimon.CoreOptions;
-import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.disk.BufferFileReader;
import org.apache.paimon.disk.BufferFileWriter;
import org.apache.paimon.disk.FileIOChannel;
import org.apache.paimon.disk.IOManager;
import org.apache.paimon.disk.IOManagerImpl;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.schema.TableSchema;
-import org.apache.paimon.table.DelegatedFileStoreTable;
import org.apache.paimon.table.FallbackReadFileStoreTable;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.Table;
@@ -340,34 +336,6 @@ public class PaimonJniScannerTest {
Assert.assertTrue(PaimonJniScanner.isWrappedFirst(fallbackTable(Collections.emptyMap())));
}
- @Test
- public void testBackendCapTraversesPrivilegeDelegate() {
- FileStoreTable main =
serializableFileStoreTable(Collections.singletonMap(
- CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "1"));
- FileStoreTable fallback =
serializableFileStoreTable(Collections.singletonMap(
- CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "128"));
- PrivilegeChecker checker = (PrivilegeChecker) Proxy.newProxyInstance(
- PrivilegeChecker.class.getClassLoader(),
- new Class<?>[] {PrivilegeChecker.class},
- (proxy, method, args) -> null);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- new FallbackReadFileStoreTable(main, fallback, true), checker,
- Identifier.create("db", "table"));
-
- Table safe = PaimonJniScanner.applyBackendManifestParallelism(
- privileged, null, 64);
- FileStoreTable planningTable = safe instanceof DelegatedFileStoreTable
- && !(safe instanceof FallbackReadFileStoreTable)
- ? ((DelegatedFileStoreTable) safe).wrapped() :
(FileStoreTable) safe;
-
- Assert.assertTrue(planningTable instanceof FallbackReadFileStoreTable);
- FallbackReadFileStoreTable pair = (FallbackReadFileStoreTable)
planningTable;
- Assert.assertEquals("1", pair.wrapped().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assert.assertEquals("64", pair.other().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- }
-
@Test
public void testOldFeSystemWrapperPreservesIndependentFallbackLimits()
throws Exception {
FileStoreTable main =
serializableFileStoreTable(Collections.singletonMap(
@@ -389,29 +357,6 @@ public class PaimonJniScannerTest {
.get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
}
- @Test
- public void testSystemWrapperExposesSafeFallbackBehindPrivilegeDelegate()
throws Exception {
- FileStoreTable main =
serializableFileStoreTable(Collections.singletonMap(
- CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "1"));
- FileStoreTable fallback =
serializableFileStoreTable(Collections.singletonMap(
- CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "2"));
- PrivilegeChecker checker = (PrivilegeChecker) Proxy.newProxyInstance(
- PrivilegeChecker.class.getClassLoader(),
- new Class<?>[] {PrivilegeChecker.class},
- (proxy, method, args) -> null);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- new FallbackReadFileStoreTable(main, fallback, true), checker,
- Identifier.create("db", "table"));
- Table wrapper = SystemTableLoader.load("partitions", privileged);
-
- Table safe = PaimonJniScanner.applyBackendManifestParallelism(
- wrapper, null, 64);
- Field storeTable = safe.getClass().getDeclaredField("storeTable");
- storeTable.setAccessible(true);
-
- Assert.assertTrue(storeTable.get(safe) instanceof
FallbackReadFileStoreTable);
- }
-
@Test
public void testBackendCapRebuildsWrapperFromTransportedSystemSource()
throws Exception {
FileStoreTable source =
serializableFileStoreTable(Collections.singletonMap(
@@ -956,6 +901,9 @@ public class PaimonJniScannerTest {
if ("options".equals(method.getName())) {
return options;
}
+ if ("coreOptions".equals(method.getName())) {
+ return CoreOptions.fromMap(options);
+ }
if ("rowType".equals(method.getName())) {
return new RowType(Collections.emptyList());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
index 3164b873819..12e9e12ba9e 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
@@ -134,7 +134,7 @@ public final class PaimonLatestSnapshotProjectionLoader {
private PaimonSnapshot resolveLatestSnapshot(Table paimonTable, boolean
normalizeForPartitionLoad) {
FileStoreTable selectedTable = (FileStoreTable) paimonTable;
- // The SDK guards tagManager() as a writer API; read selectors must
not require INSERT.
+ // Resolve selectors against the underlying metadata handle without
hiding fallback readers.
FileStoreTable metadataTable =
PaimonTableDecorators.unwrapToFallbackOrBase(selectedTable);
Optional<Snapshot> selectedSnapshot =
PaimonScanParams.hasStartupOptions(selectedTable.options())
?
TimeTravelUtil.tryTravelToSnapshot(Options.fromMap(selectedTable.options()),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonCacheSizeEstimator.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonCacheSizeEstimator.java
index 75d187fba07..53b284901a0 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonCacheSizeEstimator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonCacheSizeEstimator.java
@@ -69,7 +69,7 @@ final class PaimonCacheSizeEstimator {
// One schema/table-level entry: option map node, key list slot and boxes.
private static final long OPTION_WEIGHT = 192L;
private static final long KEY_WEIGHT = 192L;
- // Wrapper tables (privileged, fallback-read) around the concrete
FileStoreTable.
+ // Delegated tables (including fallback-read) around the concrete
FileStoreTable.
private static final long WRAPPER_WEIGHT = 512L;
// Each concrete FileStoreTable strongly owns its FileIO graph
(configuration, and for REST
// catalogs the lazily fetched, periodically rotated vended token).
Paimon's FileIO exposes
@@ -139,7 +139,7 @@ final class PaimonCacheSizeEstimator {
return null;
}
- // Realistic wrapper chains (privileged, fallback-read) are one or two
levels deep; the cap
+ // Realistic delegated table chains are one or two levels deep; the cap
// only guards pathological chains from unbounded work or stack overflow
before fail-closed.
private static final int MAX_WRAPPER_DEPTH = 16;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
index d56f85b2380..8f9025803f9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
@@ -57,7 +57,6 @@ import org.apache.paimon.Snapshot;
import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.partition.Partition;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.BucketMode;
import org.apache.paimon.table.DataTable;
@@ -278,7 +277,7 @@ public class PaimonExternalTable extends ExternalTable
implements MTMVRelatedTab
@Override
public long fetchRowCount() {
makeSureInitialized();
- // Keep the reader policy consistent with scan planning, including
privilege wrappers.
+ // Keep the reader policy consistent with scan planning, including
fallback readers.
Table effectiveTable =
PaimonReaderOptions.runtimeSafeTable(getBasePaimonTable());
PaimonReaderOptions.validateEffectiveTable(effectiveTable);
if (!(effectiveTable instanceof FileStoreTable)
@@ -307,12 +306,6 @@ public class PaimonExternalTable extends ExternalTable
implements MTMVRelatedTab
// the complete snapshot selected by TimeTravelUtil.
return UNKNOWN_ROW_COUNT;
}
- if (table instanceof PrivilegedFileStoreTable) {
- // Preserve SELECT authorization without planning. TimeTravelUtil
calls tagManager(),
- // which would incorrectly require INSERT permission on the
privilege wrapper.
- table.newScan();
- table = PaimonTableDecorators.unwrapToFallbackOrBase(table);
- }
if (options.queryAuthEnabled()) {
table.catalogEnvironment().tableQueryAuth(options).auth(null);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonReaderOptions.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonReaderOptions.java
index c97133fd19f..de843f29528 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonReaderOptions.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonReaderOptions.java
@@ -22,7 +22,6 @@ import org.apache.paimon.CoreOptions;
import org.apache.paimon.options.ConfigOption;
import org.apache.paimon.options.MemorySize;
import org.apache.paimon.options.Options;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.table.DelegatedFileStoreTable;
import org.apache.paimon.table.FallbackReadFileStoreTable;
import org.apache.paimon.table.FileStoreTable;
@@ -192,23 +191,6 @@ public final class PaimonReaderOptions {
main, other, isWrappedFirst(pair));
}
- if (table instanceof DelegatedFileStoreTable) {
- if (!(table instanceof PrivilegedFileStoreTable)) {
- throw new IllegalArgumentException("Unsupported Paimon
planning table delegate: "
- + table.getClass().getName());
- }
- FileStoreTable wrapped = ((DelegatedFileStoreTable)
table).wrapped();
- FileStoreTable normalized = normalizeManifestParallelism(
- wrapped, safeBound, materializeAbsent);
- if (normalized == wrapped) {
- return table;
- }
- // A delegate copy broadcasts one value to every fallback branch.
Check authorization
- // before peeling the privilege-only layer so branch-local limits
remain independent.
- ((FileStoreTable) table).newScan();
- return normalized;
- }
-
if (!(table instanceof FileStoreTable)) {
// System-table wrappers hide the already-normalized source.
Treating the wrapper as a
// planning leaf would broadcast one cap through its private
fallback tree on copy().
@@ -262,7 +244,7 @@ public final class PaimonReaderOptions {
validateEffectiveTable(((FallbackReadFileStoreTable)
table).other());
}
if (table instanceof DelegatedFileStoreTable) {
- // Privilege and other supported delegates can hide a fallback
planner behind their
+ // Delegates can hide a fallback planner behind their
// own visible main options, so traverse the complete
planning-handle chain.
validateEffectiveTable(((DelegatedFileStoreTable)
table).wrapped());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonScanParams.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonScanParams.java
index dd0ac25512d..fb6622a9a31 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonScanParams.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonScanParams.java
@@ -143,6 +143,11 @@ public final class PaimonScanParams {
PaimonReaderOptions.validateReaderOptions(options);
String scanMode = options.get(CoreOptions.SCAN_MODE.key());
+ if ("latest-delta".equalsIgnoreCase(scanMode)) {
+ // A pinned scan.snapshot-id selects a full snapshot rather than a
delta range.
+ throw new IllegalArgumentException("Paimon scan mode
'latest-delta' is not supported by Doris "
+ + "OPTIONS. Use @incr with an explicit snapshot range for
incremental reads.");
+ }
if ("from-creation-timestamp".equalsIgnoreCase(scanMode)
&& options.get(CoreOptions.SCAN_CREATION_TIME_MILLIS.key()) ==
null) {
// Paimon 1.4.2 does not validate this mode, but its starting
scanner
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
index b8a62dc4282..49a8fc37000 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
@@ -36,7 +36,9 @@ import org.apache.doris.thrift.TTableType;
import com.google.common.collect.Lists;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.paimon.CoreOptions;
import org.apache.paimon.table.DataTable;
+import org.apache.paimon.table.FallbackReadFileStoreTable;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.Table;
import org.apache.paimon.table.system.SystemTableLoader;
@@ -185,6 +187,25 @@ public class PaimonSysExternalTable extends ExternalTable {
} else {
PaimonReaderOptions.validateEffectiveTable(PaimonReaderOptions.runtimeSafeTable(dataTable));
}
+ if ("file_indexes".equalsIgnoreCase(sysTableType)) {
+ // This wrapper defers the data scan to BE. Check catalog query
authorization on FE
+ // while the catalog loader is available, as ordinary FE-planned
scans do.
+ authorizeDeferredScan(dataTable);
+ }
+ }
+
+ static void authorizeDeferredScan(FileStoreTable dataTable) {
+ FileStoreTable undecorated =
PaimonTableDecorators.unwrapToFallbackOrBase(dataTable);
+ if (undecorated instanceof FallbackReadFileStoreTable) {
+ FallbackReadFileStoreTable pair = (FallbackReadFileStoreTable)
undecorated;
+ authorizeDeferredScan(pair.wrapped());
+ authorizeDeferredScan(pair.other());
+ return;
+ }
+ CoreOptions options = undecorated.coreOptions();
+ if (options.queryAuthEnabled()) {
+
undecorated.catalogEnvironment().tableQueryAuth(options).auth(null);
+ }
}
public OptionalInt runtimeSafeManifestParallelism(TableScanParams
scanParams) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonTableDecorators.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonTableDecorators.java
index a8dff827af7..c47d6dc84dd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonTableDecorators.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonTableDecorators.java
@@ -34,7 +34,7 @@ public final class PaimonTableDecorators {
public static FileStoreTable unwrapToFallbackOrBase(FileStoreTable table) {
FileStoreTable current = table;
// Fallback dispatch requires the pair to be the system wrapper's
immediate child. Paimon
- // does not privilege-wrap system tables, so peeling privilege-only
delegates matches its
+ // builds system tables directly over the data source, so peeling
outer delegates matches its
// catalog semantics while retaining the one decorator that changes
read routing.
while (current instanceof DelegatedFileStoreTable
&& !(current instanceof FallbackReadFileStoreTable)) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCapabilities.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCapabilities.java
index d45ff4ac70c..e6eb006b331 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCapabilities.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCapabilities.java
@@ -182,7 +182,7 @@ final class PaimonRustReaderCapabilities {
return oldPrecision > newPrecision || (oldPrecision <= 6 &&
newPrecision > 6);
}
// Only established cast equivalence may use Rust. Java's temporal
casts use the
- // default zone and truncate negative epochs; its string casts
format/pad values.
+ // default zone; its string casts format/pad values.
// Arrow differs there, in numeric narrowing/decimal rounding, and in
supported
// constructed casts. This allowlist applies at every nested leaf and
map key.
return true;
@@ -251,7 +251,7 @@ final class PaimonRustReaderCapabilities {
DataTypeRoot root = type.getTypeRoot();
switch (function) {
case "sum":
- // Java wraps integer arithmetic and retains compact-decimal
intermediate
+ // Java wraps integer aggregates by default and retains
compact-decimal intermediate
// sums beyond declared precision. Rust errors or resets the
accumulator.
return root == DataTypeRoot.FLOAT || root ==
DataTypeRoot.DOUBLE
|| (type instanceof DecimalType && ((DecimalType)
type).getPrecision() > 18);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AbstractPaimonProperties.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AbstractPaimonProperties.java
index 89dea6d3107..abe350d1ff2 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AbstractPaimonProperties.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AbstractPaimonProperties.java
@@ -121,6 +121,18 @@ public abstract class AbstractPaimonProperties extends
MetastoreProperties {
protected void appendUserHadoopConfig(Configuration conf) {
normalizeS3Config().forEach(conf::set);
+ mirrorHadoopS3OptionsToCatalogOptions(conf);
+ }
+
+ /** Paimon 2.1 S3FileIO reads these values from catalog options rather
than Hadoop conf. */
+ protected void mirrorHadoopS3OptionsToCatalogOptions(Configuration conf) {
+ conf.forEach(entry -> {
+ String key = entry.getKey();
+ // Explicit Paimon options, including assumed-role providers, keep
precedence.
+ if (key.startsWith(FS_S3A_PREFIX) && catalogOptions.get(key) ==
null) {
+ catalogOptions.set(key, entry.getValue());
+ }
+ });
}
public Map<String, String> getCatalogOptionsMap() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlanner.java
index cb02f95b03f..cb1297a6269 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlanner.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlanner.java
@@ -39,6 +39,7 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.scalar.AssertTrue;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.ShortCircuitIf;
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
@@ -80,13 +81,34 @@ final class PaimonMergePlanner {
private final PaimonRowChangeSpec.Merge merge;
private final LogicalPlan child;
private final ExpressionAnalyzer analyzer;
+ private final Expression targetPresent;
private final RowChangeOutputLayout outputLayout;
private PaimonMergePlanner(PaimonWriteTarget target,
PaimonRowChangeSpec.Merge merge,
LogicalPlan child, CascadesContext cascadesContext) {
this.target = target;
this.merge = merge;
- this.child = child;
+ if (merge.getNotMatchedClauses().isEmpty()) {
+ // MATCHED-only MERGE uses an INNER JOIN, including NULL-safe key
matches.
+ this.child = child;
+ this.targetPresent = BooleanLiteral.TRUE;
+ } else {
+ if (!(child instanceof LogicalJoin)) {
+ throw new AnalysisException("Paimon MERGE input must be a
logical join");
+ }
+ LogicalJoin<?, ?> join = (LogicalJoin<?, ?>) child;
+ // A nullable primary key cannot distinguish a target row from
null-extension.
+ Alias present = new Alias(new TinyIntLiteral((byte) 1),
"__DORIS_CHANGELOG_TARGET_PRESENT__");
+ List<NamedExpression> targetOutput = new
ArrayList<>(join.left().getOutput());
+ targetOutput.add(present);
+ this.child = join.withChildren(ImmutableList.of(
+ new LogicalProject<>(targetOutput, join.left()),
join.right()));
+ Slot marker = this.child.getOutput().stream()
+ .filter(slot ->
slot.getExprId().equals(present.getExprId())).findFirst()
+ .orElseThrow(() -> new IllegalStateException("Paimon MERGE
lost its target marker"));
+ this.targetPresent = new Not(new IsNull(marker));
+ }
+ // User expressions retain the original scope, including same-named
user columns.
this.analyzer = new ExpressionAnalyzer(
child, new Scope(child.getOutput()), cascadesContext, true,
false);
this.outputLayout = RowChangeOutputLayout.from(target);
@@ -116,9 +138,6 @@ final class PaimonMergePlanner {
}
private Alias bindBranchLabel() {
- String primaryKey = target.getTable().primaryKeys().get(0);
- Slot targetKey = findTargetSlot(primaryKey);
- Expression targetPresent = new Not(new IsNull(targetKey));
return new Alias(analyzer.analyze(
generateBranchLabel(targetPresent).child()), BRANCH_LABEL);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommand.java
index d85d68777ad..3c7b6a4e83d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommand.java
@@ -22,19 +22,17 @@ import
org.apache.doris.nereids.analyzer.UnboundPaimonTableSink;
import org.apache.doris.nereids.analyzer.UnboundRelation;
import org.apache.doris.nereids.analyzer.UnboundSlot;
import org.apache.doris.nereids.parser.LogicalPlanBuilderAssistant;
-import org.apache.doris.nereids.rules.exploration.join.JoinReorderContext;
import org.apache.doris.nereids.trees.expressions.EqualTo;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
import org.apache.doris.nereids.trees.plans.Explainable;
-import org.apache.doris.nereids.trees.plans.JoinType;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.commands.info.PaimonRowChangeSpec;
import
org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand;
import org.apache.doris.nereids.trees.plans.commands.merge.MergeMatchedClause;
import
org.apache.doris.nereids.trees.plans.commands.merge.MergeNotMatchedClause;
-import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.commands.merge.MergeUtils;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
@@ -100,10 +98,7 @@ public class PaimonMergeCommand extends Command implements
ForwardWithSync, Expl
if (targetAlias.isPresent()) {
target = new LogicalSubQueryAlias<>(targetAlias.get(), target);
}
- JoinType joinType = notMatchedClauses.isEmpty()
- ? JoinType.INNER_JOIN : JoinType.LEFT_OUTER_JOIN;
- return new LogicalJoin<>(joinType, ImmutableList.of(),
ImmutableList.of(onClause),
- source, target, JoinReorderContext.EMPTY);
+ return MergeUtils.buildMergeJoin(target, source, onClause,
!notMatchedClauses.isEmpty());
}
@Override
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCacheTest.java
index 4608013b5fb..5bd2337a3f4 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCacheTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCacheTest.java
@@ -54,8 +54,6 @@ import org.apache.paimon.fs.Path;
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.options.CatalogOptions;
import org.apache.paimon.options.Options;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.schema.TableSchema;
@@ -1828,24 +1826,6 @@ public class PaimonExternalMetaCacheTest {
}
}
- @Test
- public void testSnapshotEstimateSupportsPrivilegedTableWrapper() throws
Exception {
- FileStoreTable table = newPartitionedTable("privileged_estimate",
Collections.emptyMap());
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- table, Mockito.mock(PrivilegeChecker.class),
Identifier.create("db", "tbl"));
- NameMapping mapping = new NameMapping(1L, "db", "tbl", "db", "tbl");
- PaimonSnapshotEntryKey key = new PaimonSnapshotEntryKey(
- mapping, 1L, table.schema().id(), 1L);
- PaimonSnapshotCacheValue value = new PaimonSnapshotCacheValue(
- PaimonPartitionInfo.EMPTY,
- new PaimonSnapshot(1L, table.schema().id(), privileged));
-
- value.prepareForCachePublication(key);
-
- Assert.assertTrue(value.getSizeEstimate().getIncompleteReason(),
- value.getSizeEstimate().isComplete());
- }
-
@Test
public void testSnapshotEstimateDoesNotMaterializeNestedRowTypeIndexes()
throws Exception {
RowType nested = DataTypes.ROW(
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonHistoricalSchemaOptionsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonHistoricalSchemaOptionsTest.java
index a4a133a848f..bb5f5502c76 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonHistoricalSchemaOptionsTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonHistoricalSchemaOptionsTest.java
@@ -27,8 +27,6 @@ import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.fs.local.LocalFileIO;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaChange;
@@ -46,7 +44,6 @@ import org.apache.paimon.utils.InstantiationUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import org.mockito.Mockito;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -86,10 +83,6 @@ public class PaimonHistoricalSchemaOptionsTest {
Collections.singletonMap("scan.snapshot-id", "1"),
Collections.singletonMap("scan.tag-name",
"before_rename"))) {
FileStoreTable selected = (FileStoreTable)
PaimonScanParams.applyOptions(latest, selector);
- PrivilegeChecker checker =
Mockito.mock(PrivilegeChecker.class);
- Mockito.doThrow(new SecurityException("read-only
principal")).when(checker)
- .assertCanInsert(Mockito.any());
- selected = PrivilegedFileStoreTable.wrap(selected, checker,
id);
PaimonSnapshotCacheValue projection = loader.load(
NameMapping.createForTest("db", "projection_history"),
selected);
Assertions.assertEquals(1L,
projection.getSnapshot().getSnapshotId());
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonNullableKeyCompatibilityTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonNullableKeyCompatibilityTest.java
new file mode 100644
index 00000000000..9bd98a1728d
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonNullableKeyCompatibilityTest.java
@@ -0,0 +1,115 @@
+// 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.paimon.CoreOptions;
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.FileSystemCatalog;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.fs.local.LocalFileIO;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.CatalogEnvironment;
+import org.apache.paimon.table.FallbackReadFileStoreTable;
+import org.apache.paimon.table.FileStoreTable;
+import org.apache.paimon.table.Table;
+import org.apache.paimon.table.sink.BatchTableCommit;
+import org.apache.paimon.table.sink.BatchTableWrite;
+import org.apache.paimon.table.sink.BatchWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.Split;
+import org.apache.paimon.table.source.TableQueryAuth;
+import org.apache.paimon.types.DataTypes;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.mockito.Mockito;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class PaimonNullableKeyCompatibilityTest {
+ @Test
+ public void fileIndexesPreservesDeferredAuthorizationForEveryBranch() {
+ CoreOptions options = Mockito.mock(CoreOptions.class);
+ Mockito.when(options.queryAuthEnabled()).thenReturn(true);
+ FileStoreTable main = Mockito.mock(FileStoreTable.class);
+ FileStoreTable fallback = Mockito.mock(FileStoreTable.class);
+ CatalogEnvironment environment =
Mockito.mock(CatalogEnvironment.class);
+ TableQueryAuth auth = Mockito.mock(TableQueryAuth.class);
+ Mockito.when(main.coreOptions()).thenReturn(options);
+ Mockito.when(fallback.coreOptions()).thenReturn(options);
+ Mockito.when(main.catalogEnvironment()).thenReturn(environment);
+ Mockito.when(fallback.catalogEnvironment()).thenReturn(environment);
+ Mockito.when(environment.tableQueryAuth(options)).thenReturn(auth);
+ PaimonSysExternalTable.authorizeDeferredScan(
+ new FallbackReadFileStoreTable(main, fallback, true));
+ Mockito.verify(auth, Mockito.times(2)).auth(null);
+ Mockito.doThrow(new SecurityException("denied file
indexes")).when(auth).auth(null);
+ Assertions.assertThrows(SecurityException.class,
+ () -> PaimonSysExternalTable.authorizeDeferredScan(main));
+ }
+
+ @Test
+ public void
nullablePrimaryKeyPreservesNullabilityAndMergeSemantics(@TempDir Path
warehouse) throws Exception {
+ try (Catalog catalog = new FileSystemCatalog(LocalFileIO.create(),
+ new org.apache.paimon.fs.Path(warehouse.toUri()))) {
+ catalog.createDatabase("db", false);
+ Identifier id = Identifier.create("db", "nullable_keys");
+ catalog.createTable(id, Schema.newBuilder()
+ .column("id", DataTypes.INT())
+ .column("val", DataTypes.INT())
+ .primaryKey("id")
+ .option("bucket", "1")
+ .option("primary-key.nullable", "true")
+ .build(), false);
+ Table table = catalog.getTable(id);
+ Assertions.assertTrue(table.rowType().getTypeAt(0).isNullable());
+ Assertions.assertTrue(PaimonUtil.parseSchema(table, false,
false).get(0).isAllowNull());
+
+ for (int value : new int[] {10, 20}) {
+ BatchWriteBuilder builder = table.newBatchWriteBuilder();
+ try (BatchTableWrite write = builder.newWrite();
BatchTableCommit commit = builder.newCommit()) {
+ write.write(GenericRow.of(null, value));
+ write.write(GenericRow.of(1, 100));
+ commit.commit(write.prepareCommit());
+ }
+ }
+
+ Table backend =
PaimonUtil.deserializeObject(PaimonUtil.serializeObject(table));
+ Assertions.assertTrue(backend.rowType().getTypeAt(0).isNullable());
+ ReadBuilder builder = backend.newReadBuilder();
+ List<String> rows = new ArrayList<>();
+ for (Split split : builder.newScan().plan().splits()) {
+ try (RecordReader<InternalRow> reader =
builder.newRead().createReader(split)) {
+ reader.forEachRemaining(row -> rows.add(
+ (row.isNullAt(0) ? "NULL" :
Integer.toString(row.getInt(0))) + ":" + row.getInt(1)));
+ }
+ }
+ Collections.sort(rows);
+ Assertions.assertEquals(Arrays.asList("1:100", "NULL:20"), rows,
+ "Repeated NULL primary keys must merge as the same key
across commits");
+ }
+ }
+
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonReaderOptionsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonReaderOptionsTest.java
index aa1d6415ade..9995c12bcdf 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonReaderOptionsTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonReaderOptionsTest.java
@@ -22,11 +22,8 @@ import
org.apache.doris.datasource.property.metastore.AbstractPaimonProperties;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.paimon.CoreOptions;
-import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.AppendOnlyFileStoreTable;
import org.apache.paimon.table.CatalogEnvironment;
@@ -45,6 +42,31 @@ import java.util.Map;
public class PaimonReaderOptionsTest {
+ @Test
+ void testRuntimeCapNormalizesEveryPlanningLeafIndependently() {
+ FileStoreTable empty = newFileStoreTable("empty",
Collections.emptyMap());
+ FileStoreTable explicit = newFileStoreTable("explicit",
ImmutableMap.of(
+ CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "1"));
+
+ FileStoreTable safeEmpty = (FileStoreTable)
PaimonReaderOptions.runtimeSafeTable(empty, 512);
+ FallbackReadFileStoreTable explicitThenEmpty =
(FallbackReadFileStoreTable)
+ PaimonReaderOptions.runtimeSafeTable(
+ new FallbackReadFileStoreTable(explicit, empty, true),
512);
+ FallbackReadFileStoreTable emptyThenExplicit =
(FallbackReadFileStoreTable)
+ PaimonReaderOptions.runtimeSafeTable(
+ new FallbackReadFileStoreTable(empty, explicit, true),
512);
+ Assertions.assertEquals("256", safeEmpty.options()
+ .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
+ Assertions.assertEquals("1", explicitThenEmpty.wrapped().options()
+ .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
+ Assertions.assertEquals("256", explicitThenEmpty.other().options()
+ .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
+ Assertions.assertEquals("256", emptyThenExplicit.wrapped().options()
+ .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
+ Assertions.assertEquals("1", emptyThenExplicit.other().options()
+ .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
+ }
+
@Test
void testSupportsSafeBatchReadOptions() {
Assertions.assertEquals(ImmutableSet.of(
@@ -117,39 +139,6 @@ public class PaimonReaderOptionsTest {
Assertions.assertDoesNotThrow(() ->
PaimonReaderOptions.validateCatalogProperties(persisted));
}
- @Test
- void testRuntimeCapNormalizesEveryPlanningLeafIndependently() {
- FileStoreTable empty = newFileStoreTable("empty",
Collections.emptyMap());
- FileStoreTable explicit = newFileStoreTable("explicit",
ImmutableMap.of(
- CoreOptions.SCAN_MANIFEST_PARALLELISM.key(), "1"));
-
- FileStoreTable safeEmpty = (FileStoreTable)
PaimonReaderOptions.runtimeSafeTable(empty, 512);
- FallbackReadFileStoreTable explicitThenEmpty =
(FallbackReadFileStoreTable)
- PaimonReaderOptions.runtimeSafeTable(
- new FallbackReadFileStoreTable(explicit, empty, true),
512);
- FallbackReadFileStoreTable emptyThenExplicit =
(FallbackReadFileStoreTable)
- PaimonReaderOptions.runtimeSafeTable(
- new FallbackReadFileStoreTable(empty, explicit, true),
512);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- new FallbackReadFileStoreTable(explicit, empty, true),
- Mockito.mock(PrivilegeChecker.class), Identifier.create("db",
"table"));
- Table normalizedDelegate =
PaimonReaderOptions.runtimeSafeTable(privileged, 512);
-
- Assertions.assertEquals("256", safeEmpty.options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assertions.assertEquals("1", explicitThenEmpty.wrapped().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assertions.assertEquals("256", explicitThenEmpty.other().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assertions.assertEquals("256", emptyThenExplicit.wrapped().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assertions.assertEquals("1", emptyThenExplicit.other().options()
- .get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- Assertions.assertInstanceOf(FallbackReadFileStoreTable.class,
normalizedDelegate);
- Assertions.assertEquals("256", ((FallbackReadFileStoreTable)
normalizedDelegate)
-
.other().options().get(CoreOptions.SCAN_MANIFEST_PARALLELISM.key()));
- }
-
@Test
void testRuntimeCapPreservesPrimaryBranchPriority() throws Exception {
FileStoreTable main = newFileStoreTable("main", ImmutableMap.of(
@@ -181,18 +170,6 @@ public class PaimonReaderOptionsTest {
fallbackTable(Collections.emptyMap())));
}
- @Test
- void testSystemSourceKeepsFallbackAsOutermostPlanningDecorator() {
- FileStoreTable main = newFileStoreTable("main",
Collections.emptyMap());
- FileStoreTable fallback = newFileStoreTable("fallback",
Collections.emptyMap());
- FallbackReadFileStoreTable pair = new FallbackReadFileStoreTable(main,
fallback, true);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- pair, Mockito.mock(PrivilegeChecker.class),
- Identifier.create("db", "privileged_fallback"));
-
- Assertions.assertSame(pair,
PaimonTableDecorators.unwrapToFallbackOrBase(privileged));
- }
-
@Test
void testUnnormalizedEffectiveTableCannotGrowPaimonGlobalPool() {
int localCapacity = Runtime.getRuntime().availableProcessors();
@@ -281,21 +258,6 @@ public class PaimonReaderOptionsTest {
new FallbackReadFileStoreTable(main, fallback,
true)).getAsInt());
}
- @Test
- void testRejectUnsafeFallbackHiddenByPrivilegeDelegate() {
- FileStoreTable main = newFileStoreTable("privileged_main",
Collections.emptyMap());
- FileStoreTable fallback = newFileStoreTable(
- "privileged_fallback",
ImmutableMap.of("scan.manifest.parallelism", "0"));
- FileStoreTable fallbackReadTable = new
FallbackReadFileStoreTable(main, fallback, true);
- FileStoreTable privilegedTable = PrivilegedFileStoreTable.wrap(
- fallbackReadTable,
- Mockito.mock(PrivilegeChecker.class),
- Identifier.create("db", "table"));
-
- Assertions.assertThrows(IllegalArgumentException.class,
- () ->
PaimonReaderOptions.validateEffectiveTable(privilegedTable));
- }
-
private FileStoreTable newFileStoreTable(String name, Map<String, String>
options) {
TableSchema schema = new TableSchema(
0,
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonRowCountTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonRowCountTest.java
index bba3e27f3ac..2b8191db512 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonRowCountTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonRowCountTest.java
@@ -22,13 +22,10 @@ import org.apache.doris.catalog.TableIf;
import com.google.common.collect.ImmutableMap;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.Snapshot;
-import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.fs.Path;
import org.apache.paimon.fs.local.LocalFileIO;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
+import org.apache.paimon.schema.FileSystemSchemaManager;
import org.apache.paimon.schema.Schema;
-import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.table.CatalogEnvironment;
import org.apache.paimon.table.FallbackReadFileStoreTable;
import org.apache.paimon.table.FileStoreTable;
@@ -124,23 +121,6 @@ public class PaimonRowCountTest {
rowCount(new FallbackReadFileStoreTable(main, other, true)));
}
- @Test
- public void testSelectOnlyPrivilegeWrapper() throws Exception {
- FileStoreTable table = newTable(false);
- snapshot(table, 1, 10L);
- PrivilegeChecker checker = Mockito.mock(PrivilegeChecker.class);
- Identifier identifier = Identifier.create("db", "tbl");
- Mockito.doThrow(new IllegalStateException("INSERT is not granted"))
- .when(checker).assertCanInsert(identifier);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(table,
checker, identifier);
- Assert.assertEquals(10L, rowCount(privileged));
- Mockito.verify(checker).assertCanSelect(identifier);
- Mockito.verify(checker, Mockito.never()).assertCanInsert(identifier);
- Mockito.doThrow(new IllegalStateException("SELECT is not granted"))
- .when(checker).assertCanSelect(identifier);
- Assert.assertThrows(IllegalStateException.class, () ->
rowCount(privileged));
- }
-
@Test
public void testCatalogQueryAuthorizationWithoutPlanning() throws
Exception {
FileStoreTable table =
Mockito.spy(newTable(false).copy(ImmutableMap.of("query-auth.enabled",
"true")));
@@ -175,15 +155,15 @@ public class PaimonRowCountTest {
schema.primaryKey("id").option("bucket", "1");
}
options.forEach(schema::option);
- new SchemaManager(fileIO, path).createTable(schema.build());
+ new FileSystemSchemaManager(fileIO, path).createTable(schema.build());
return FileStoreTableFactory.create(fileIO, path);
}
private void snapshot(FileStoreTable table, long id, long count) throws
Exception {
// No manifest files exist: accidentally returning to split planning
must fail.
Snapshot snapshot = new Snapshot(id, 0L, "unused-base", null,
"unused-delta", null,
- null, null, null, "test", id, Snapshot.CommitKind.APPEND, id *
1000,
- count, count, null, null, null, Collections.emptyMap(), null);
+ null, null, null, null, "test", id,
Snapshot.CommitKind.APPEND, id * 1000,
+ count, count, null, null, null, Collections.emptyMap(), null,
Snapshot.Operation.WRITE);
table.fileIO().mkdirs(table.snapshotManager().snapshotPath(id).getParent());
table.fileIO().overwriteFileUtf8(table.snapshotManager().snapshotPath(id),
snapshot.toJson());
table.snapshotManager().commitLatestHint(id);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonScanParamsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonScanParamsTest.java
index 905cd9d6c43..c891e07417d 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonScanParamsTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/PaimonScanParamsTest.java
@@ -37,6 +37,15 @@ import java.util.Map;
public class PaimonScanParamsTest {
+ @Test
+ public void testRejectLatestDeltaInsteadOfReadingFullSnapshot() {
+ IllegalArgumentException error =
Assert.assertThrows(IllegalArgumentException.class,
+ () ->
PaimonScanParams.validateOptions(ImmutableMap.of("scan.mode", "latest-delta")));
+ Assert.assertTrue(error.getMessage().contains("latest-delta' is not
supported by Doris"));
+ Assert.assertThrows(IllegalArgumentException.class,
+ () ->
PaimonScanParams.pinOptionsToSnapshot(ImmutableMap.of("scan.mode",
"latest-delta"), 2L));
+ }
+
@Test
public void testValidateKnownScanOptions() {
PaimonScanParams.validateOptions(ImmutableMap.of(
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCompatibilityTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCompatibilityTest.java
index 4e44aa67809..a76f1a2a957 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCompatibilityTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderCompatibilityTest.java
@@ -30,9 +30,9 @@ import org.apache.paimon.data.Timestamp;
import org.apache.paimon.fs.Path;
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.FileSystemSchemaManager;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.sink.BatchTableCommit;
@@ -136,9 +136,9 @@ public class PaimonRustReaderCompatibilityTest {
@Test
public void testPersistedTimestampToDateBeforeEpoch() throws Exception {
- // Java divides toward zero; Arrow takes the preceding calendar date
before the epoch.
+ // Paimon 2.1 uses the preceding calendar date for timestamps before
the epoch.
assertPersistedEvolution(DataTypes.TIMESTAMP(3), DataTypes.DATE(),
Timestamp.fromEpochMillis(-1),
- false, row -> row.getInt(1), 0);
+ false, row -> row.getInt(1), -1);
}
@Test
@@ -372,20 +372,28 @@ public class PaimonRustReaderCompatibilityTest {
public void testPersistedIntegerSumAndProductOverflow() throws Exception {
DataType[] types = {DataTypes.TINYINT(), DataTypes.SMALLINT(),
DataTypes.INT(), DataTypes.BIGINT()};
Object[] maximums = {(byte) 127, (short) 32767, Integer.MAX_VALUE,
Long.MAX_VALUE};
+ Object[] minimums = {(byte) -128, (short) -32768, Integer.MIN_VALUE,
Long.MIN_VALUE};
Object[] ones = {(byte) 1, (short) 1, 1, 1L};
Object[] halves = {(byte) 64, (short) 16384, 1073741824,
4611686018427387904L};
Object[] twos = {(byte) 2, (short) 2, 2, 2L};
for (String function : Arrays.asList("sum", "product")) {
for (int i = 0; i < types.length; i++) {
- FileStoreTable table = table(types[i], aggregate(function));
- commit(table, GenericRow.of(1, "sum".equals(function) ?
maximums[i] : halves[i]));
- commit(table, GenericRow.of(1, "sum".equals(function) ?
ones[i] : twos[i]));
- InternalRow.FieldGetter getter =
InternalRow.createFieldGetter(types[i], 1);
- Object minimum = i == 0 ? (byte) -128 : i == 1 ? (short) -32768
- : i == 2 ? Integer.MIN_VALUE : Long.MIN_VALUE;
- // Compare decimal strings to avoid Java's conditional numeric
promotion.
- assertRead(table, false, row ->
getter.getFieldOrNull(row).toString(),
- Collections.singletonList(minimum.toString()));
+ for (boolean failOnOverflow : new boolean[] {false, true}) {
+ Map<String, String> options = new
HashMap<>(aggregate(function));
+ if (failOnOverflow) {
+ options.put("fields.v." + function +
".fail-on-overflow", "true");
+ }
+ FileStoreTable table = table(types[i], options);
+ commit(table, GenericRow.of(1, "sum".equals(function) ?
maximums[i] : halves[i]));
+ commit(table, GenericRow.of(1, "sum".equals(function) ?
ones[i] : twos[i]));
+ if (failOnOverflow) {
+ assertReadOverflows(table);
+ } else {
+ InternalRow.FieldGetter getter =
InternalRow.createFieldGetter(types[i], 1);
+ assertRead(table, false, row ->
getter.getFieldOrNull(row).toString(),
+
Collections.singletonList(minimums[i].toString()));
+ }
+ }
}
}
}
@@ -461,7 +469,7 @@ public class PaimonRustReaderCompatibilityTest {
.option("file.format",
"parquet").option("deletion-vectors.enabled", "false")
.option("read.batch-size",
"16").option("scan.manifest.parallelism", "1");
options.forEach(schema::option);
- new SchemaManager(fileIO, path).createTable(schema.build());
+ new FileSystemSchemaManager(fileIO, path).createTable(schema.build());
return FileStoreTableFactory.create(fileIO, path);
}
@@ -476,6 +484,13 @@ public class PaimonRustReaderCompatibilityTest {
}
}
+ private static void assertReadOverflows(FileStoreTable table) {
+ // Paimon 2.1 checks integer sum/product overflow when explicitly
enabled per field.
+ ArithmeticException overflow =
Assert.assertThrows(ArithmeticException.class,
+ () -> assertRead(table, false, row -> row.getInt(0),
Collections.emptyList()));
+ Assert.assertTrue(overflow.getMessage().contains("overflow"));
+ }
+
private static <T> void assertRead(FileStoreTable table, boolean
rustExpected,
Function<InternalRow, T> extract, List<T> expected) throws
Exception {
ReadBuilder builder = table.newReadBuilder();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderLegacySchemaTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderLegacySchemaTest.java
index 1ed35e94007..4c436852bdf 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderLegacySchemaTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/paimon/source/PaimonRustReaderLegacySchemaTest.java
@@ -25,9 +25,9 @@ import org.apache.paimon.data.InternalRow;
import org.apache.paimon.fs.Path;
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.FileSystemSchemaManager;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.sink.BatchTableCommit;
@@ -56,7 +56,7 @@ public class PaimonRustReaderLegacySchemaTest {
java.nio.file.Path directory = temporaryFolder.newFolder().toPath();
Path location = new Path(directory.toUri());
LocalFileIO fileIO = LocalFileIO.create();
- new SchemaManager(fileIO, location).createTable(Schema.newBuilder()
+ new FileSystemSchemaManager(fileIO,
location).createTable(Schema.newBuilder()
.column("id", DataTypes.INT()).option("bucket", "-1")
.option("file.format", "parquet").build());
FileStoreTable table = FileStoreTableFactory.create(fileIO, location);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AbstractPaimonPropertiesTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AbstractPaimonPropertiesTest.java
index 24b82556035..713848e450e 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AbstractPaimonPropertiesTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AbstractPaimonPropertiesTest.java
@@ -73,6 +73,37 @@ public class AbstractPaimonPropertiesTest {
props = new TestPaimonProperties(input);
}
+ @Test
+ public void testHadoopS3MirrorDoesNotOverwriteExplicitProvider() {
+ // Static S3 keys plus an explicit assumed-role credentials provider:
the
+ // Hadoop configuration carries the SimpleAWSCredentialsProvider the
static
+ // keys produce, but the user's provider entry is already in the
catalog
+ // options — the mirror must fill only absent options, or the warehouse
+ // re-opens under the base identity and fails AccessDenied.
+ Map<String, String> input = new HashMap<>();
+ input.put("warehouse", "s3://tmp/warehouse");
+ input.put("paimon.fs.s3a.aws.credentials.provider",
+ "org.apache.hadoop.fs.s3a.auth.AssumedRoleCredentialProvider");
+ TestPaimonProperties testProps = new TestPaimonProperties(input);
+ testProps.buildCatalogOptions();
+
+ // The Hadoop side only knows the Simple provider generated from the
static
+ // keys, plus defaults the catalog has not set yet. Mirror BEFORE the
first
+ // getCatalogOptionsMap() call: the map is memoized once read.
+ org.apache.hadoop.conf.Configuration conf = new
org.apache.hadoop.conf.Configuration(false);
+ conf.set("fs.s3a.aws.credentials.provider",
+ "org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider");
+ conf.set("fs.s3a.connection.maximum", "100");
+ testProps.mirrorHadoopS3OptionsToCatalogOptions(conf);
+
+ Map<String, String> options = testProps.getCatalogOptionsMap();
+
Assertions.assertEquals("org.apache.hadoop.fs.s3a.auth.AssumedRoleCredentialProvider",
+ options.get("fs.s3a.aws.credentials.provider"),
+ "the explicit user provider must survive the Hadoop mirror");
+ Assertions.assertEquals("100",
options.get("fs.s3a.connection.maximum"),
+ "absent defaults are still filled");
+ }
+
@Test
void testNormalizeS3Config() {
Map<String, String> input = new HashMap<>();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlannerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlannerTest.java
new file mode 100644
index 00000000000..eae255c4fc9
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/PaimonMergePlannerTest.java
@@ -0,0 +1,154 @@
+// 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.nereids.rules.analysis;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.datasource.paimon.PaimonWriteTarget;
+import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.analyzer.UnboundSlot;
+import org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnFE;
+import org.apache.doris.nereids.trees.expressions.Alias;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.commands.info.PaimonRowChangeSpec;
+import org.apache.doris.nereids.trees.plans.commands.merge.MergeMatchedClause;
+import
org.apache.doris.nereids.trees.plans.commands.merge.MergeNotMatchedClause;
+import org.apache.doris.nereids.trees.plans.commands.merge.MergeUtils;
+import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.util.ExpressionUtils;
+import org.apache.doris.nereids.util.MemoTestUtils;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.paimon.table.FileStoreTable;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+class PaimonMergePlannerTest {
+ @Test
+ void matchedMergeAcceptsNullPrimaryKeyForUpdateAndDelete() {
+ for (boolean delete : new boolean[] {false, true}) {
+ LogicalPlan child = targetRow(true);
+ MergeMatchedClause clause = new
MergeMatchedClause(Optional.empty(), delete ? ImmutableList.of()
+ : ImmutableList.of(new EqualTo(new UnboundSlot("value"),
new IntegerLiteral(99))), delete);
+ PaimonRowChangeSpec.Merge spec = new PaimonRowChangeSpec.Merge(
+ ImmutableList.of("target"), ImmutableList.of(clause),
ImmutableList.of());
+ LogicalPlan result = PaimonMergePlanner.build(
+ writeTarget(), spec, child, context(child));
+ Map<Expression, Expression> nullRow = new HashMap<>();
+ child.getOutput().forEach(slot -> nullRow.put(slot, new
NullLiteral(slot.getDataType())));
+
+ Assertions.assertEquals(new IntegerLiteral(0), fold(
+ ExpressionUtils.replace(branchLabel(result), nullRow)));
+ }
+ }
+
+ @Test
+ void mergeDistinguishesNullTargetValuesFromNullExtendedRows() {
+ LogicalPlan target = targetRow(true);
+ LogicalPlan source = new LogicalEmptyRelation(new RelationId(2),
ImmutableList.of(
+ new SlotReference("id", IntegerType.INSTANCE, true,
ImmutableList.of("source")),
+ new SlotReference("__DORIS_CHANGELOG_TARGET_PRESENT__",
IntegerType.INSTANCE, true,
+ ImmutableList.of("source"))));
+ LogicalPlan child = MergeUtils.buildMergeJoin(target, source,
+ new EqualTo(target.getOutput().get(0),
source.getOutput().get(0)), true);
+ MergeMatchedClause update = new MergeMatchedClause(Optional.empty(),
ImmutableList.of(
+ new EqualTo(new UnboundSlot("value"),
+ new
UnboundSlot("__DORIS_CHANGELOG_TARGET_PRESENT__"))), false);
+ MergeNotMatchedClause insert = new
MergeNotMatchedClause(Optional.empty(), ImmutableList.of(),
+ ImmutableList.copyOf(source.getOutput()));
+ PaimonRowChangeSpec.Merge spec = new PaimonRowChangeSpec.Merge(
+ ImmutableList.of("target"), ImmutableList.of(update),
ImmutableList.of(insert));
+ LogicalPlan result = PaimonMergePlanner.build(
+ writeTarget(), spec, child, context(child));
+ LogicalJoin<?, ?> join = result.<LogicalJoin<?,
?>>collectToList(LogicalJoin.class::isInstance).get(0);
+ Slot marker = join.getOutput().get(target.getOutput().size());
+ Assertions.assertTrue(marker.nullable(), "the marker must inherit
outer-join null-extension");
+ Map<Expression, Expression> nullRow = new HashMap<>();
+ join.getOutput().forEach(slot -> nullRow.put(slot, new
NullLiteral(slot.getDataType())));
+ Expression label = branchLabel(result);
+
+ Assertions.assertEquals(new IntegerLiteral(1), fold(
+ ExpressionUtils.replace(label, nullRow)));
+ nullRow.put(marker, new TinyIntLiteral((byte) 1));
+ Assertions.assertEquals(new IntegerLiteral(0), fold(
+ ExpressionUtils.replace(label, nullRow)));
+ // A source column sharing the private marker's name must still supply
the UPDATE value.
+ nullRow.put(source.getOutput().get(1), new IntegerLiteral(555));
+ Expression value =
result.<LogicalProject<?>>collectToList(LogicalProject.class::isInstance).stream()
+ .flatMap(project -> project.getProjects().stream())
+ .filter(project -> project instanceof Alias &&
project.getName().equals("value"))
+ .findFirst().get().child(0);
+ value.getInputSlots().stream().filter(slot ->
slot.getName().equals("__DORIS_PAIMON_MERGE_BRANCH__"))
+ .forEach(slot -> nullRow.put(slot, new IntegerLiteral(0)));
+ Assertions.assertEquals(new IntegerLiteral(555), fold(
+ ExpressionUtils.replace(value, nullRow)));
+ }
+
+ private Expression branchLabel(LogicalPlan plan) {
+ return
plan.<LogicalProject<?>>collectToList(LogicalProject.class::isInstance).stream()
+ .flatMap(project -> project.getProjects().stream())
+ .filter(project ->
project.getName().equals("__DORIS_PAIMON_MERGE_BRANCH__"))
+ .findFirst().get().child(0);
+ }
+
+ private Expression fold(Expression expression) {
+ return FoldConstantRuleOnFE.evaluate(expression, null);
+ }
+
+ private PaimonWriteTarget writeTarget() {
+ PaimonWriteTarget target = Mockito.mock(PaimonWriteTarget.class);
+ FileStoreTable table = Mockito.mock(FileStoreTable.class);
+ Mockito.when(target.getTable()).thenReturn(table);
+ Mockito.when(table.primaryKeys()).thenReturn(ImmutableList.of("id"));
+ Mockito.when(target.getSchema()).thenReturn(ImmutableList.of(
+ new Column("id", ScalarType.createType(PrimitiveType.INT)),
+ new Column("value",
ScalarType.createType(PrimitiveType.INT))));
+ return target;
+ }
+
+ private LogicalPlan targetRow(boolean nullableKey) {
+ SlotReference id = new SlotReference("id", IntegerType.INSTANCE,
nullableKey,
+ ImmutableList.of("target"));
+ SlotReference value = new SlotReference("value", IntegerType.INSTANCE,
true,
+ ImmutableList.of("target"));
+ return new LogicalEmptyRelation(new RelationId(1),
ImmutableList.of(id, value));
+ }
+
+ private CascadesContext context(LogicalPlan child) {
+ CascadesContext context = MemoTestUtils.createCascadesContext(child);
+ context.getConnectContext().setDatabase("test");
+ return context;
+ }
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommandTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommandTest.java
new file mode 100644
index 00000000000..8df5e7db4ab
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/PaimonMergeCommandTest.java
@@ -0,0 +1,63 @@
+// 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.nereids.trees.plans.commands;
+
+import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.commands.merge.MergeMatchedClause;
+import
org.apache.doris.nereids.trees.plans.commands.merge.MergeNotMatchedClause;
+import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
+import org.apache.doris.qe.ConnectContext;
+
+import com.google.common.collect.ImmutableList;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Optional;
+
+class PaimonMergeCommandTest {
+ @Test
+ void matchedOnlyMergeKeepsTargetOnLeft() {
+ assertMergeJoin(false, JoinType.INNER_JOIN);
+ }
+
+ @Test
+ void mergeWithInsertPreservesSourceOnRight() {
+ assertMergeJoin(true, JoinType.RIGHT_OUTER_JOIN);
+ }
+
+ private void assertMergeJoin(boolean hasInsert, JoinType expectedType) {
+ LogicalPlan source = new LogicalEmptyRelation(new RelationId(1),
ImmutableList.of());
+ PaimonMergeCommand command = new
PaimonMergeCommand(ImmutableList.of("target"),
+ Optional.of("t"), Optional.empty(), source,
BooleanLiteral.TRUE,
+ ImmutableList.of(new MergeMatchedClause(Optional.empty(),
ImmutableList.of(), true)),
+ hasInsert ? ImmutableList.of(new
MergeNotMatchedClause(Optional.empty(),
+ ImmutableList.of(), ImmutableList.of())) :
ImmutableList.of());
+ LogicalJoin<?, ?> join = (LogicalJoin<?, ?>)
command.getExplainPlan(new ConnectContext()).child(0);
+
+ Assertions.assertEquals(expectedType, join.getJoinType());
+ Assertions.assertSame(source, join.right());
+ Assertions.assertInstanceOf(LogicalSubQueryAlias.class, join.left());
+ Assertions.assertEquals("t", ((LogicalSubQueryAlias<?>)
join.left()).getAlias());
+ Assertions.assertEquals(ImmutableList.of(BooleanLiteral.TRUE),
join.getOtherJoinConjuncts());
+ }
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/tablefunction/PaimonTableValuedFunctionTest.java
b/fe/fe-core/src/test/java/org/apache/doris/tablefunction/PaimonTableValuedFunctionTest.java
index f6752074f0a..44469c9df69 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/tablefunction/PaimonTableValuedFunctionTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/tablefunction/PaimonTableValuedFunctionTest.java
@@ -20,9 +20,6 @@ package org.apache.doris.tablefunction;
import org.apache.doris.datasource.paimon.PaimonReaderOptions;
import org.apache.paimon.CoreOptions;
-import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.privilege.PrivilegeChecker;
-import org.apache.paimon.privilege.PrivilegedFileStoreTable;
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.FallbackReadFileStoreTable;
import org.apache.paimon.table.FileStoreTable;
@@ -74,10 +71,8 @@ public class PaimonTableValuedFunctionTest {
Mockito.when(main.options()).thenReturn(Collections.emptyMap());
Mockito.when(fallback.options()).thenReturn(Collections.emptyMap());
FallbackReadFileStoreTable pair = new FallbackReadFileStoreTable(main,
fallback, true);
- FileStoreTable privileged = PrivilegedFileStoreTable.wrap(
- pair, Mockito.mock(PrivilegeChecker.class),
Identifier.create("db", "table"));
- Table systemTable =
PaimonTableValuedFunction.createRuntimeSafeSystemTable(privileged, "ro");
+ Table systemTable =
PaimonTableValuedFunction.createRuntimeSafeSystemTable(pair, "ro");
Assertions.assertInstanceOf(ReadOptimizedTable.class, systemTable);
Field wrapped = ReadOptimizedTable.class.getDeclaredField("wrapped");
diff --git a/fe/pom.xml b/fe/pom.xml
index 5473a64943f..570dca61f09 100644
--- a/fe/pom.xml
+++ b/fe/pom.xml
@@ -231,7 +231,8 @@ under the License.
<module>fe-authentication</module>
</modules>
<properties>
-
<doris.hive.catalog.shade.version>3.1.3</doris.hive.catalog.shade.version>
+ <!-- This bundle embeds Paimon classes; keep its embedded SDK at 2.1.0
too. -->
+
<doris.hive.catalog.shade.version>4.1.0</doris.hive.catalog.shade.version>
<!-- iceberg 1.9.1 depends avro on 1.12 -->
<avro.version>1.12.1</avro.version>
<!-- Disable file-controlled KMS URLs by default (CVE-2026-73334). -->
@@ -422,7 +423,9 @@ under the License.
<quartz.version>2.3.2</quartz.version>
<aircompressor.version>2.0.3</aircompressor.version>
<!-- paimon -->
- <paimon.version>1.4.2</paimon.version>
+ <!-- FE and the BE JNI connector must use the same SDK: Table/Split
payloads
+ cross the FE/BE boundary using Paimon serialization. -->
+ <paimon.version>2.1.0</paimon.version>
<disruptor.version>3.4.4</disruptor.version>
<!-- arrow flight sql -->
<arrow.vector.classifier>shade-format-flatbuffers</arrow.vector.classifier>
diff --git
a/regression-test/data/external_table_p0/paimon/paimon_system_table.out
b/regression-test/data/external_table_p0/paimon/paimon_system_table.out
index 3d11cf0874d..310fa1dd072 100644
--- a/regression-test/data/external_table_p0/paimon/paimon_system_table.out
+++ b/regression-test/data/external_table_p0/paimon/paimon_system_table.out
@@ -1,6 +1,6 @@
-- This file is automatically generated. You should know what you did if you
want to edit this
-- !direct_query__snapshots_result --
-1 0 87d5f82b-5368-418d-91e6-58d01545e29e 9223372036854775807
APPEND 2024-07-11T16:01:57.425
manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-0
manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-1 \N 1 1
0 -9223372036854775808 \N
+1 0 87d5f82b-5368-418d-91e6-58d01545e29e 9223372036854775807
APPEND 2024-07-11T16:01:57.425
manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-0
manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-1 \N 1 1
0 -9223372036854775808 \N \N \N
-- !paimon_snapshots_core_fields_direct_query --
1 0 87d5f82b-5368-418d-91e6-58d01545e29e 9223372036854775807
APPEND manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-0
manifest-list-102a9c07-edbc-4cde-a2bf-a4253a232e10-1 \N 1 1 0
@@ -35,6 +35,8 @@ delta_record_count bigint Yes true \N NONE
changelog_record_count bigint Yes true \N NONE
watermark bigint Yes true \N NONE
next_row_id bigint Yes true \N NONE
+operation text Yes true \N NONE
+writer_version text Yes true \N NONE
-- !desc_direct_query_db_table --
snapshot_id bigint Yes true \N NONE
@@ -51,6 +53,8 @@ delta_record_count bigint Yes true \N NONE
changelog_record_count bigint Yes true \N NONE
watermark bigint Yes true \N NONE
next_row_id bigint Yes true \N NONE
+operation text Yes true \N NONE
+writer_version text Yes true \N NONE
-- !desc_direct_query_table --
snapshot_id bigint Yes true \N NONE
@@ -67,6 +71,8 @@ delta_record_count bigint Yes true \N NONE
changelog_record_count bigint Yes true \N NONE
watermark bigint Yes true \N NONE
next_row_id bigint Yes true \N NONE
+operation text Yes true \N NONE
+writer_version text Yes true \N NONE
-- !files_without_options --
3
diff --git
a/regression-test/data/external_table_p0/paimon/test_paimon_2_1_compatibility.out
b/regression-test/data/external_table_p0/paimon/test_paimon_2_1_compatibility.out
new file mode 100644
index 00000000000..da666b1e6cd
--- /dev/null
+++
b/regression-test/data/external_table_p0/paimon/test_paimon_2_1_compatibility.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !nullable_keys_jni --
+\N 20
+1 200
+
+-- !nullable_single_jni --
+\N 20
+1 200
+
+-- !nullable_keys_rust --
+\N 20
+1 200
+
+-- !file_indexes --
+id bitmap 2 0
+
+-- !wrapping_sum --
+1 -9223372036854775808
+
diff --git
a/regression-test/data/external_table_p0/paimon/test_paimon_nullable_key_merge.out
b/regression-test/data/external_table_p0/paimon/test_paimon_nullable_key_merge.out
new file mode 100644
index 00000000000..a8ba9e76ead
--- /dev/null
+++
b/regression-test/data/external_table_p0/paimon/test_paimon_nullable_key_merge.out
@@ -0,0 +1,83 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !null_key_update --
+\N 99
+1 200
+3 300
+
+-- !null_key_equal_no_match --
+\N 99
+1 200
+3 300
+
+-- !matched_and_insert --
+\N 99
+1 111
+2 222
+3 300
+
+-- !null_key_delete --
+1 111
+2 222
+3 300
+
+-- !missing_null_key_no_match --
+1 111
+2 222
+3 300
+
+-- !insert_null_key --
+\N 77
+1 111
+2 222
+3 300
+
+-- !null_key_branch_priority --
+\N 88
+1 111
+2 222
+3 300
+
+-- !null_key_false_condition --
+\N 88
+1 111
+2 222
+3 300
+
+-- !null_key_duplicate_unchanged --
+\N 88
+1 111
+2 222
+3 300
+
+-- !duplicate_null_insert_unchanged --
+\N 88
+1 111
+2 222
+3 300
+
+-- !insert_only --
+\N 88
+1 111
+2 222
+3 300
+4 444
+
+-- !marker_name_collision --
+\N 88
+1 111
+2 222
+3 300
+4 444
+5 555
+
+-- !composite_update --
+\N \N 130
+\N 1 110
+1 \N 120
+1 1 140
+
+-- !composite_delete --
+\N 1 110
+1 \N 120
+1 1 140
+
diff --git
a/regression-test/suites/external_table_p0/paimon/test_paimon_2_1_compatibility.groovy
b/regression-test/suites/external_table_p0/paimon/test_paimon_2_1_compatibility.groovy
new file mode 100644
index 00000000000..4f037e6e201
--- /dev/null
+++
b/regression-test/suites/external_table_p0/paimon/test_paimon_2_1_compatibility.groovy
@@ -0,0 +1,103 @@
+// 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.
+
+import org.apache.doris.regression.action.ProfileAction
+
+suite("test_paimon_2_1_compatibility", "p0,external,paimon") {
+ if
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enablePaimonTest")))
{
+ return
+ }
+ def endpoint = context.config.otherConfigs.get("externalEnvIp")
+ def port = context.config.otherConfigs.get("iceberg_minio_port")
+ def settings = ["enable_paimon_rust_reader", "force_jni_scanner",
+ "enable_file_scanner_v2", "enable_profile"]
+ def saved = settings.collectEntries { [(it): sql("select @@${it}")[0][0]] }
+
+ sql "DROP CATALOG IF EXISTS paimon_2_1_compatibility"
+ sql """CREATE CATALOG paimon_2_1_compatibility PROPERTIES (
+ 'type'='paimon', 'paimon.catalog.type'='filesystem',
'fs.s3.support'='true',
+ 'warehouse'='s3://warehouse/wh',
's3.endpoint'='http://${endpoint}:${port}',
+ 's3.access_key'='admin', 's3.secret_key'='password',
+ 's3.region'='us-east-1', 'use_path_style'='true')"""
+ sql "SWITCH paimon_2_1_compatibility"
+ sql "DROP DATABASE IF EXISTS paimon_2_1_compatibility_db FORCE"
+ sql "CREATE DATABASE paimon_2_1_compatibility_db"
+ sql "USE paimon_2_1_compatibility_db"
+
+ try {
+ sql "set enable_file_scanner_v2=true"
+ sql "set enable_profile=true"
+ sql "set force_jni_scanner=true"
+ sql "set enable_paimon_rust_reader=false"
+
+ sql """CREATE TABLE nullable_keys (id INT NULL, v INT) ENGINE=paimon
+ PROPERTIES ('primary-key'='id', 'primary-key.nullable'='true',
+ 'bucket'='1', 'write-only'='true',
'deletion-vectors.enabled'='false')"""
+ sql "INSERT INTO nullable_keys VALUES (NULL,10), (1,100)"
+ sql "INSERT INTO nullable_keys VALUES (NULL,20), (1,200)"
+ order_qt_nullable_keys_jni "SELECT id,v FROM nullable_keys ORDER BY id
NULLS FIRST"
+
+ // Keep a single-file positive control: a multi-file PK merge
deliberately falls back
+ // to JNI. Generate it with Doris so this suite also works with older
Spark fixtures.
+ sql """CREATE TABLE nullable_keys_single (id INT NULL, v INT)
ENGINE=paimon
+ PROPERTIES ('primary-key'='id', 'primary-key.nullable'='true',
+ 'bucket'='1', 'write-only'='true',
'deletion-vectors.enabled'='false')"""
+ sql "INSERT INTO nullable_keys_single VALUES (NULL,10), (1,100),
(NULL,20), (1,200)"
+ order_qt_nullable_single_jni "SELECT id,v FROM nullable_keys_single
ORDER BY id NULLS FIRST"
+ // Keep logical splits: native Parquet bypasses the JNI/Rust reader
selection.
+ sql "set enable_paimon_rust_reader=true"
+ order_qt_nullable_keys_rust "SELECT id,v FROM nullable_keys_single
ORDER BY id NULLS FIRST"
+ def queryId = sql("select last_query_id()")[0][0].toString()
+ def profile = new ProfileAction(context).getProfile(queryId,
+ ["PaimonRustReader", "Profile Completion State: COMPLETE"])
+ assertTrue(profile.contains("PaimonRustReader"))
+
+ sql "set force_jni_scanner=true"
+ sql "set enable_paimon_rust_reader=false"
+ sql """CREATE TABLE indexed_values (id INT, v STRING) ENGINE=paimon
+ PROPERTIES ('bucket'='-1', 'file-index.bitmap.columns'='id')"""
+ sql "INSERT INTO indexed_values VALUES (1,'one'), (2,'two')"
+ order_qt_file_indexes """SELECT
column_name,index_type,SUM(record_count),MIN(CAST(is_empty AS INT))
+ FROM indexed_values\$file_indexes
+ GROUP BY column_name,index_type ORDER BY column_name,index_type"""
+ test {
+ sql "SELECT id FROM indexed_values
@options('scan.mode'='latest-delta')"
+ exception "latest-delta' is not supported by Doris"
+ }
+
+ sql """CREATE TABLE wrapping_sum (id INT NOT NULL, v BIGINT)
ENGINE=paimon
+ PROPERTIES ('primary-key'='id', 'bucket'='1', 'write-only'='true',
+ 'deletion-vectors.enabled'='false',
'merge-engine'='aggregation',
+ 'fields.v.aggregate-function'='sum')"""
+ sql "INSERT INTO wrapping_sum VALUES (1,9223372036854775807)"
+ sql "INSERT INTO wrapping_sum VALUES (1,1)"
+ order_qt_wrapping_sum "SELECT id,v FROM wrapping_sum ORDER BY id"
+
+ sql """CREATE TABLE checked_sum (id INT NOT NULL, v BIGINT)
ENGINE=paimon
+ PROPERTIES ('primary-key'='id', 'bucket'='1', 'write-only'='true',
+ 'deletion-vectors.enabled'='false',
'merge-engine'='aggregation',
+ 'fields.v.aggregate-function'='sum',
'fields.v.sum.fail-on-overflow'='true')"""
+ sql "INSERT INTO checked_sum VALUES (1,9223372036854775807)"
+ sql "INSERT INTO checked_sum VALUES (1,1)"
+ test {
+ sql "SELECT id,v FROM checked_sum ORDER BY id"
+ exception "overflow"
+ }
+ } finally {
+ saved.each { key, value -> sql "set ${key}=${value}" }
+ }
+}
diff --git
a/regression-test/suites/external_table_p0/paimon/test_paimon_nullable_key_merge.groovy
b/regression-test/suites/external_table_p0/paimon/test_paimon_nullable_key_merge.groovy
new file mode 100644
index 00000000000..b9de2e744c4
--- /dev/null
+++
b/regression-test/suites/external_table_p0/paimon/test_paimon_nullable_key_merge.groovy
@@ -0,0 +1,133 @@
+// 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_nullable_key_merge", "p0,external,paimon") {
+ if
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enablePaimonTest")))
{
+ return
+ }
+ def endpoint = context.config.otherConfigs.get("externalEnvIp")
+ def port = context.config.otherConfigs.get("iceberg_minio_port")
+ sql "DROP CATALOG IF EXISTS paimon_nullable_key_merge"
+ sql """CREATE CATALOG paimon_nullable_key_merge PROPERTIES (
+ 'type'='paimon', 'paimon.catalog.type'='filesystem',
'fs.s3.support'='true',
+ 'warehouse'='s3://warehouse/wh',
's3.endpoint'='http://${endpoint}:${port}',
+ 's3.access_key'='admin', 's3.secret_key'='password',
+ 's3.region'='us-east-1', 'use_path_style'='true')"""
+ sql "SWITCH paimon_nullable_key_merge"
+ sql "DROP DATABASE IF EXISTS paimon_nullable_key_merge_db FORCE"
+ sql "CREATE DATABASE paimon_nullable_key_merge_db"
+ sql "USE paimon_nullable_key_merge_db"
+ sql """CREATE TABLE nullable_target (id INT NULL, v INT) ENGINE=paimon
+ PROPERTIES ('primary-key'='id', 'primary-key.nullable'='true',
+ 'bucket'='1', 'write-only'='true',
'deletion-vectors.enabled'='false')"""
+ sql "INSERT INTO nullable_target VALUES (NULL,20), (1,200), (3,300)"
+
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 99 AS v) s ON t.id <=> s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ order_qt_null_key_update "SELECT * FROM nullable_target ORDER BY id NULLS
FIRST"
+
+ // Ordinary equality does not match NULL keys, even with only a MATCHED
branch.
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 999 AS v) s ON t.id = s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ order_qt_null_key_equal_no_match "SELECT * FROM nullable_target ORDER BY
id NULLS FIRST"
+
+ sql """MERGE INTO nullable_target t
+ USING (SELECT 2 AS id, 222 AS v) s ON t.id = s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ sql """MERGE INTO nullable_target t
+ USING (SELECT 1 AS id, 111 AS v) s ON t.id = s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ order_qt_matched_and_insert "SELECT * FROM nullable_target ORDER BY id
NULLS FIRST"
+
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id) s ON t.id <=> s.id
+ WHEN MATCHED THEN DELETE"""
+ order_qt_null_key_delete "SELECT * FROM nullable_target ORDER BY id NULLS
FIRST"
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 999 AS v) s ON t.id <=> s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ order_qt_missing_null_key_no_match "SELECT * FROM nullable_target ORDER BY
id NULLS FIRST"
+
+ // A null-extended target must choose INSERT, including a NULL source key.
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 77 AS v) s ON t.id = s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ order_qt_insert_null_key "SELECT * FROM nullable_target ORDER BY id NULLS
FIRST"
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 88 AS v) s ON t.id <=> s.id
+ WHEN MATCHED AND s.v < 0 THEN DELETE
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ order_qt_null_key_branch_priority "SELECT * FROM nullable_target ORDER BY
id NULLS FIRST"
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 999 AS v) s ON t.id <=> s.id
+ WHEN MATCHED AND s.v < 0 THEN UPDATE SET v=s.v"""
+ order_qt_null_key_false_condition "SELECT * FROM nullable_target ORDER BY
id NULLS FIRST"
+ test {
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 101 AS v
+ UNION ALL SELECT CAST(NULL AS INT), 102) s ON t.id <=> s.id
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ exception "Paimon MERGE matched one target row with multiple source
rows"
+ }
+ order_qt_null_key_duplicate_unchanged "SELECT * FROM nullable_target ORDER
BY id NULLS FIRST"
+ test {
+ sql """MERGE INTO nullable_target t
+ USING (SELECT CAST(NULL AS INT) AS id, 101 AS v
+ UNION ALL SELECT CAST(NULL AS INT), 102) s ON t.id = s.id
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ exception "Paimon MERGE attempted to insert multiple rows with the
same primary key"
+ }
+ order_qt_duplicate_null_insert_unchanged "SELECT * FROM nullable_target
ORDER BY id NULLS FIRST"
+ sql """MERGE INTO nullable_target t
+ USING (SELECT 1 AS id, 999 AS v) s ON t.id = s.id
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ sql """MERGE INTO nullable_target t
+ USING (SELECT 4 AS id, 444 AS v) s ON t.id = s.id
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES (s.id,s.v)"""
+ order_qt_insert_only "SELECT * FROM nullable_target ORDER BY id NULLS
FIRST"
+ // User expressions must not bind to the private marker if a source column
shares its name.
+ sql """MERGE INTO nullable_target t
+ USING (SELECT 5 AS id, 555 AS __DORIS_CHANGELOG_TARGET_PRESENT__) s ON
t.id = s.id
+ WHEN MATCHED THEN UPDATE SET v=__DORIS_CHANGELOG_TARGET_PRESENT__
+ WHEN NOT MATCHED THEN INSERT (id,v) VALUES
(s.id,__DORIS_CHANGELOG_TARGET_PRESENT__)"""
+ order_qt_marker_name_collision "SELECT * FROM nullable_target ORDER BY id
NULLS FIRST"
+
+ sql """CREATE TABLE composite_target (k1 INT NULL, k2 INT NULL, v INT)
ENGINE=paimon
+ PROPERTIES ('primary-key'='k1,k2', 'primary-key.nullable'='true',
+ 'bucket'='1', 'write-only'='true',
'deletion-vectors.enabled'='false')"""
+ sql "INSERT INTO composite_target VALUES (NULL,1,10), (1,NULL,20),
(NULL,NULL,30), (1,1,40)"
+ sql """MERGE INTO composite_target t
+ USING (SELECT CAST(NULL AS INT) AS k1, 1 AS k2, 110 AS v
+ UNION ALL SELECT 1, CAST(NULL AS INT), 120
+ UNION ALL SELECT CAST(NULL AS INT), CAST(NULL AS INT), 130
+ UNION ALL SELECT 1, 1, 140) s
+ ON t.k1 <=> s.k1 AND t.k2 <=> s.k2
+ WHEN MATCHED THEN UPDATE SET v=s.v"""
+ order_qt_composite_update "SELECT * FROM composite_target ORDER BY k1
NULLS FIRST,k2 NULLS FIRST"
+ // Include an unmatched source row: MATCHED-only DELETE must not
materialize it.
+ sql """MERGE INTO composite_target t
+ USING (SELECT CAST(NULL AS INT) AS k1, CAST(NULL AS INT) AS k2
+ UNION ALL SELECT 99, 99) s
+ ON t.k1 <=> s.k1 AND t.k2 <=> s.k2
+ WHEN MATCHED THEN DELETE"""
+ order_qt_composite_delete "SELECT * FROM composite_target ORDER BY k1
NULLS FIRST,k2 NULLS FIRST"
+}
diff --git
a/regression-test/suites/external_table_p0/paimon/write/test_paimon_write_transaction.groovy
b/regression-test/suites/external_table_p0/paimon/write/test_paimon_write_transaction.groovy
index bfdeffa376b..894f4c6cddd 100644
---
a/regression-test/suites/external_table_p0/paimon/write/test_paimon_write_transaction.groovy
+++
b/regression-test/suites/external_table_p0/paimon/write/test_paimon_write_transaction.groovy
@@ -447,7 +447,7 @@ suite("test_paimon_write_transaction",
"p0,external,paimon") {
sql """INSERT INTO t_failed_write VALUES
(2, 'accepted_before_error'),
(3, repeat('x', 1048576))"""
- exception "The record exceeds the maximum size of a sort buffer"
+ exception "The record exceeds the maximum size of a Paimon write
sort buffer"
}
qt_txn_failed_write_after """SELECT id, payload FROM t_failed_write
ORDER BY id"""
qt_txn_failed_snapshot_after """SELECT COUNT(*) FROM
t_failed_write\$snapshots"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]