This is an automated email from the ASF dual-hosted git repository.

suxiaogang223 pushed a commit to branch feature/paimon-jni-write-v1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit d2b14a51462115af293ea91f59ab93d08b9cb370
Author: Socrates <[email protected]>
AuthorDate: Wed Jul 8 18:32:32 2026 +0800

    fix: update FE Paimon write code after rebase to latest master
    
    - PaimonInsertCommandContext: add txnId, commitUser, staticPartition fields
    - PaimonTableSink: use PaimonInsertCommandContext instead of 
BaseExternalTableInsertCommandContext
    - PhysicalPaimonTableSink: replace ConnectContext with Statistics, add 
getRequirePhysicalProperties()
    - UnboundPaimonTableSink: add missing ImmutableList import
    
    Co-Authored-By: Claude <[email protected]>
---
 .../nereids/analyzer/UnboundPaimonTableSink.java   |  1 +
 .../insert/PaimonInsertCommandContext.java         | 31 +++++++++++
 .../plans/physical/PhysicalPaimonTableSink.java    | 60 ++++++++++------------
 .../org/apache/doris/planner/PaimonTableSink.java  | 14 ++---
 4 files changed, 65 insertions(+), 41 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundPaimonTableSink.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundPaimonTableSink.java
index 92275a24552..9a3a812ef10 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundPaimonTableSink.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundPaimonTableSink.java
@@ -25,6 +25,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.info.DMLCommandType;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 import java.util.Optional;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/PaimonInsertCommandContext.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/PaimonInsertCommandContext.java
index f0bf011b793..51abd7d19d6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/PaimonInsertCommandContext.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/PaimonInsertCommandContext.java
@@ -17,8 +17,39 @@
 
 package org.apache.doris.nereids.trees.plans.commands.insert;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Insert command context for Paimon tables.
  */
 public class PaimonInsertCommandContext extends 
BaseExternalTableInsertCommandContext {
+    private long txnId = 0;
+    private String commitUser;
+    private Map<String, String> staticPartition = new HashMap<>();
+
+    public long getTxnId() {
+        return txnId;
+    }
+
+    public void setTxnId(long txnId) {
+        this.txnId = txnId;
+    }
+
+    public String getCommitUser() {
+        return commitUser;
+    }
+
+    public void setCommitUser(String commitUser) {
+        this.commitUser = commitUser;
+    }
+
+    public Map<String, String> getStaticPartition() {
+        return staticPartition;
+    }
+
+    public void setStaticPartition(Map<String, String> staticPartition) {
+        this.staticPartition = staticPartition != null
+                ? new HashMap<>(staticPartition) : new HashMap<>();
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalPaimonTableSink.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalPaimonTableSink.java
index 3493ad585a5..61cdb0c18ee 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalPaimonTableSink.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalPaimonTableSink.java
@@ -28,7 +28,7 @@ import org.apache.doris.nereids.trees.plans.AbstractPlan;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.PlanType;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
-import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.statistics.Statistics;
 
 import java.util.List;
 import java.util.Optional;
@@ -39,9 +39,6 @@ import java.util.Optional;
 public class PhysicalPaimonTableSink<CHILD_TYPE extends Plan>
         extends PhysicalBaseExternalTableSink<CHILD_TYPE> {
 
-    private final PaimonExternalDatabase database;
-    private final PaimonExternalTable targetTable;
-
     public PhysicalPaimonTableSink(PaimonExternalDatabase database,
                                     PaimonExternalTable targetTable,
                                     List<Column> cols,
@@ -60,54 +57,49 @@ public class PhysicalPaimonTableSink<CHILD_TYPE extends 
Plan>
                                     Optional<GroupExpression> groupExpression,
                                     LogicalProperties logicalProperties,
                                     PhysicalProperties physicalProperties,
-                                    ConnectContext connectContext,
+                                    Statistics statistics,
                                     CHILD_TYPE child) {
-        super(PlanType.PHYSICAL_PAIMON_TABLE_SINK, outputExprs, 
groupExpression,
-                logicalProperties, physicalProperties, connectContext, cols, 
child);
-        this.database = database;
-        this.targetTable = targetTable;
-    }
-
-    public PaimonExternalDatabase getDatabase() {
-        return database;
-    }
-
-    public PaimonExternalTable getTargetTable() {
-        return targetTable;
+        super(PlanType.PHYSICAL_PAIMON_TABLE_SINK, database, targetTable, 
cols, outputExprs,
+                groupExpression, logicalProperties, physicalProperties, 
statistics, child);
     }
 
     @Override
     public Plan withChildren(List<Plan> children) {
-        return AbstractPlan.copyWithSameId(this, () ->
-                new PhysicalPaimonTableSink<>(database, targetTable, cols, 
outputExprs,
-                        Optional.empty(), getLogicalProperties(),
-                        physicalProperties, connectContext, children.get(0)));
+        return AbstractPlan.copyWithSameId(this, () -> new 
PhysicalPaimonTableSink<>(
+                (PaimonExternalDatabase) database, (PaimonExternalTable) 
targetTable,
+                cols, outputExprs, groupExpression,
+                getLogicalProperties(), physicalProperties, statistics, 
children.get(0)));
     }
 
     @Override
     public Plan withGroupExpression(Optional<GroupExpression> groupExpression) 
{
-        return AbstractPlan.copyWithSameId(this, () ->
-                new PhysicalPaimonTableSink<>(database, targetTable, cols, 
outputExprs,
-                        groupExpression, getLogicalProperties(),
-                        physicalProperties, connectContext, child()));
+        return AbstractPlan.copyWithSameId(this, () -> new 
PhysicalPaimonTableSink<>(
+                (PaimonExternalDatabase) database, (PaimonExternalTable) 
targetTable,
+                cols, outputExprs, groupExpression,
+                getLogicalProperties(), physicalProperties, statistics, 
child()));
     }
 
     @Override
     public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> 
groupExpression,
             Optional<LogicalProperties> logicalProperties, List<Plan> 
children) {
-        return AbstractPlan.copyWithSameId(this, () ->
-                new PhysicalPaimonTableSink<>(database, targetTable, cols, 
outputExprs,
-                        groupExpression, logicalProperties.get(),
-                        physicalProperties, connectContext, children.get(0)));
+        return AbstractPlan.copyWithSameId(this, () -> new 
PhysicalPaimonTableSink<>(
+                (PaimonExternalDatabase) database, (PaimonExternalTable) 
targetTable,
+                cols, outputExprs, groupExpression,
+                logicalProperties.get(), physicalProperties, statistics, 
children.get(0)));
     }
 
     @Override
     public PhysicalPaimonTableSink<Plan> withPhysicalPropertiesAndStats(
-            PhysicalProperties physicalProperties, 
org.apache.doris.statistics.Statistics stats) {
-        return AbstractPlan.copyWithSameId(this, () ->
-                new PhysicalPaimonTableSink<>(database, targetTable, cols, 
outputExprs,
-                        groupExpression, getLogicalProperties(),
-                        physicalProperties, connectContext, child()));
+            PhysicalProperties physicalProperties, Statistics stats) {
+        return AbstractPlan.copyWithSameId(this, () -> new 
PhysicalPaimonTableSink<>(
+                (PaimonExternalDatabase) database, (PaimonExternalTable) 
targetTable,
+                cols, outputExprs, groupExpression,
+                getLogicalProperties(), physicalProperties, stats, child()));
+    }
+
+    @Override
+    public PhysicalProperties getRequirePhysicalProperties() {
+        return physicalProperties != null ? physicalProperties : 
PhysicalProperties.ANY;
     }
 
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/PaimonTableSink.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/PaimonTableSink.java
index bf24cb21f3c..0c83f41e366 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PaimonTableSink.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PaimonTableSink.java
@@ -23,8 +23,8 @@ import org.apache.doris.common.AnalysisException;
 import org.apache.doris.datasource.mvcc.MvccUtil;
 import org.apache.doris.datasource.paimon.PaimonExternalCatalog;
 import org.apache.doris.datasource.paimon.PaimonExternalTable;
-import 
org.apache.doris.nereids.trees.plans.commands.insert.BaseExternalTableInsertCommandContext;
 import 
org.apache.doris.nereids.trees.plans.commands.insert.InsertCommandContext;
+import 
org.apache.doris.nereids.trees.plans.commands.insert.PaimonInsertCommandContext;
 import org.apache.doris.thrift.TDataSink;
 import org.apache.doris.thrift.TDataSinkType;
 import org.apache.doris.thrift.TExplainLevel;
@@ -122,9 +122,9 @@ public class PaimonTableSink extends 
BaseExternalTableDataSink {
         }
 
         // Transaction context: commit identifier and user
-        if (insertCtx.isPresent() && insertCtx.get() instanceof 
BaseExternalTableInsertCommandContext) {
-            BaseExternalTableInsertCommandContext ctx =
-                    (BaseExternalTableInsertCommandContext) insertCtx.get();
+        if (insertCtx.isPresent() && insertCtx.get() instanceof 
PaimonInsertCommandContext) {
+            PaimonInsertCommandContext ctx =
+                    (PaimonInsertCommandContext) insertCtx.get();
             if (ctx.getTxnId() > 0) {
                 paimonOptions.put("doris.commit_identifier", 
String.valueOf(ctx.getTxnId()));
             }
@@ -187,9 +187,9 @@ public class PaimonTableSink extends 
BaseExternalTableDataSink {
 
         // Write mode: APPEND or OVERWRITE
         tSink.setBackendType(TPaimonWriteBackendType.JNI);
-        if (insertCtx.isPresent() && insertCtx.get() instanceof 
BaseExternalTableInsertCommandContext) {
-            BaseExternalTableInsertCommandContext ctx =
-                    (BaseExternalTableInsertCommandContext) insertCtx.get();
+        if (insertCtx.isPresent() && insertCtx.get() instanceof 
PaimonInsertCommandContext) {
+            PaimonInsertCommandContext ctx =
+                    (PaimonInsertCommandContext) insertCtx.get();
             if (ctx.isOverwrite()) {
                 tSink.setWriteMode(TPaimonWriteMode.OVERWRITE);
                 paimonOptions.put("doris.write_mode", "OVERWRITE");


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to