hello-stephen commented on code in PR #69404:
URL: https://github.com/apache/doris/pull/69404#discussion_r4797221937


##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java:
##########
@@ -322,16 +324,16 @@ private static List<THiveColumn> 
buildColumns(HmsTableInfo table) {
         return columns;
     }
 
-    // Port of legacy HiveTableSink.setPartitionValues: for a partitioned 
table, list live partitions and
-    // convert each to a THivePartition (values + per-partition file format + 
in-place location). Live/uncached
-    // (matches the scan path; registered deviation DV-INC4-livepart). 
HmsClient calls self-authenticate.
-    private List<THivePartition> buildExistingPartitions(HmsTableInfo table) {
+    // Load only the target of a fully static string-partition write. Other 
writes retain the full listing.
+    // Missing partitions are omitted by getExistingPartitions and classified 
as NEW by BE.
+    private List<THivePartition> buildExistingPartitions(HmsTableInfo table, 
ConnectorWriteHandle handle) {
         List<THivePartition> partitions = new ArrayList<>();
         if (table.getPartitionKeys().isEmpty()) {
             return partitions;
         }
-        List<String> partitionNames = hmsClient.listPartitionNames(
-                table.getDbName(), table.getTableName(), -1);
+        Optional<String> staticPartitionName = fullyStaticPartitionName(table, 
handle);
+        List<String> partitionNames = 
staticPartitionName.map(Collections::singletonList)

Review Comment:
   [P2] Preserve a live existence check for the static target
   
   With `partition.cache.ttl-second=0`, the partition-name lookup goes to HMS 
while the partition object cache stays enabled. If a query warms the object 
cache for `p=x` and Hive drops `p=x` before the next static insert, this 
singleton lookup can still return the cached object. BE sends `APPEND`, and 
commit fails when the statistics update fetches the missing partition from HMS. 
The previous fresh list omitted `p=x`, so the insert took the `NEW` path and 
recreated it. Fetch the singleton from HMS without using the cached object as 
proof of existence, and cover the dropped-target case.



##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java:
##########
@@ -351,6 +353,32 @@ private List<THivePartition> 
buildExistingPartitions(HmsTableInfo table) {
         return partitions;
     }
 
+    private static Optional<String> fullyStaticPartitionName(HmsTableInfo 
table, ConnectorWriteHandle handle) {
+        // Typed partition text can differ between FE literals and BE 
directory formatting (e.g. BOOLEAN
+        // true versus 1). Narrow only string partitions, whose cast values 
are the bytes BE will write.
+        for (ConnectorColumn column : table.getPartitionKeys()) {
+            String type = column.getType().getTypeName();
+            if (!"STRING".equalsIgnoreCase(type) && 
!"VARCHAR".equalsIgnoreCase(type)
+                    && !"CHAR".equalsIgnoreCase(type)) {
+                return Optional.empty();
+            }
+        }
+        Map<String, String> spec = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        spec.putAll(handle.getCastStaticPartitionSpec());

Review Comment:
   [P2] Preserve writes whose partition cast runs on BE
   
   On a Hive table with partition keys `p CHAR(2), q STRING`, 
`PARTITION(p=123)` leaves `q` dynamic. This call still evaluates the cast to 
`CHAR(2)` before checking for `q`, and the FE literal cast throws on `123`. The 
existing row path leaves that cast for BE, whose string serializer emits the 
numeric text without a target-width check. A fully static write can hit the 
same failure. Check completeness first and keep the full listing whenever 
computing the target name would require a cast the FE cannot evaluate.



-- 
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