github-actions[bot] commented on code in PR #65991:
URL: https://github.com/apache/doris/pull/65991#discussion_r3671018232


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java:
##########
@@ -715,15 +749,71 @@ private Plan 
bindHiveTableSink(MatchingContext<UnboundHiveTableSink<Plan>> ctx)
                 Optional.empty(),
                 child);
         // we need to insert all the columns of the target table
+        // (except the static partition columns which are supplied by the 
PARTITION clause)
         if (boundSink.getCols().size() != child.getOutput().size()) {
             throw new AnalysisException("insert into cols should be 
corresponding to the query output");
         }
         Map<String, NamedExpression> columnToOutput = getColumnToOutput(ctx, 
table, false, false,
                 boundSink, child);
+
+        // For static partition columns, add constant expressions from the 
PARTITION clause.
+        // This ensures every written row carries the static partition value, 
so all rows
+        // land in the specified partition (and INSERT OVERWRITE only 
overwrites that partition).
+        if (!staticPartitionColNames.isEmpty()) {
+            for (Map.Entry<String, Expression> entry : 
staticPartitions.entrySet()) {
+                Expression valueExpr = entry.getValue();
+                Column column = table.getColumn(entry.getKey());
+                if (column != null) {
+                    Expression castExpr = TypeCoercionUtils.castIfNotSameType(

Review Comment:
   [P2] Bound partition lookup for static targets
   
   These constants are only added to the row projection; the canonical static 
spec is not retained by the logical/physical sink or 
`HiveInsertCommandContext`. As a result, `HiveTableSink.setPartitionValues()` 
still enumerates `getNameToPartitionValues().values()` and 
`getAllPartitionsWithCache()` loads one `HivePartition` for every partition in 
the table. Even `PARTITION(dt='2026-07-24')` is therefore O(total partitions) 
in FE metadata work, which can make this targeted syntax unusable on large Hive 
tables. Please carry the canonical spec downstream and fetch only the exact 
fully-static target (or the matching prefix for hybrid writes), keeping the 
all-partition path only for fully dynamic writes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to