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


##########
regression-test/suites/external_table_p0/hive/write/test_hive_write_static_partition.groovy:
##########
@@ -123,6 +123,28 @@ suite("test_hive_write_static_partition", 
"p0,external,hive,external_docker,exte
         assertEquals("tagG", p28ow[0][0]); assertEquals(700, p28ow[0][1])
         assertEquals("2026-07-28", p28ow[0][2])
 
+        // 9. A numeric literal can render as "1E+3" in FE planning and "1000" 
on the BE row. The
+        //    provider must keep the full listing so an existing p=1000 
partition is overwritten,
+        //    not classified NEW and appended.
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='1000')
+            SELECT 'tagH', 'u8', 800;
+        """
+        sql """ set debug_skip_fold_constant = true; """
+        try {
+            sql """
+                INSERT OVERWRITE TABLE ${tableName} PARTITION(ts_date=1e3)
+                SELECT 'tagI', 'u9', 900;
+            """
+        } finally {
+            sql """ set debug_skip_fold_constant = false; """
+        }
+        sql """ refresh catalog ${catalog_name}; """
+        def p1000 = sql """ select tag_value, ts, ts_date from ${tableName} 
where ts_date='1000'; """

Review Comment:
   [P3] Generate the numeric overwrite’s expected rows
   
   The added query has a deterministic result, and the repository’s 
regression-test standards require a generated expected result for this case. 
Use an ordered `qt` query and generate the `.out` entry with the regression 
runner. The expected single row will still catch an overwrite that retains 
`tagH`.



##########
fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveWritePlanProviderTest.java:
##########
@@ -626,6 +629,288 @@ public void planWriteRejectsLzoInputFormat() {
 
     // ───────────────────────────── existing partitions 
─────────────────────────────
 
+    @Test
+    public void fullyStaticWritesLoadOnlyTargetWithoutListingPartitions() {
+        for (boolean overwrite : Arrays.asList(false, true)) {
+            for (String key : Arrays.asList("dt", "DT", "Dt")) {
+                RecordingHmsClient client = new RecordingHmsClient();
+                client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+                client.rejectPartitionListing = true;
+                client.partitions = Arrays.asList(
+                        partition(Collections.singletonList("2026-10-19")),
+                        partition(Collections.singletonList("2026-10-20")));
+
+                THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(),
+                        
handle().overwrite(overwrite).staticSpec(Collections.singletonMap(key, 
"2026-10-19")));
+
+                
Assertions.assertEquals(Collections.singletonList("dt=2026-10-19"), 
client.requestedPartitions);
+                Assertions.assertEquals(1, sink.getPartitionsSize());
+                
Assertions.assertEquals(Collections.singletonList("2026-10-19"),
+                        sink.getPartitions().get(0).getValues());
+                Assertions.assertEquals(overwrite, sink.isOverwrite());
+            }
+        }
+    }
+
+    @Test
+    public void staticPartitionNamesFollowSchemaOrderAndEscapeValues() {
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = tableBuilder().partitionKeys(Arrays.asList(col("dt", 
"string"), col("region", "string")))
+                .build();
+        client.rejectPartitionListing = true;
+        Map<String, String> spec = new java.util.LinkedHashMap<>();
+        spec.put("REGION", "a/b=c%z");
+        spec.put("DT", "2026-10-19");
+        client.partitions = 
Collections.singletonList(partition(Arrays.asList("2026-10-19", "a/b=c%z")));
+
+        THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(), handle().staticSpec(spec));
+
+        
Assertions.assertEquals(Collections.singletonList("dt=2026-10-19/region=a%2Fb%3Dc%25z"),
+                client.requestedPartitions);
+        Assertions.assertEquals(Arrays.asList("2026-10-19", "a/b=c%z"), 
sink.getPartitions().get(0).getValues());
+    }
+
+    @Test
+    public void missingStaticTargetDoesNotLoadUnrelatedPartitions() {
+        for (boolean overwrite : Arrays.asList(false, true)) {
+            RecordingHmsClient client = new RecordingHmsClient();
+            client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+            client.rejectPartitionListing = true;
+            client.partitions = 
Collections.singletonList(partition(Collections.singletonList("old")));
+
+            THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(),
+                    
handle().overwrite(overwrite).staticSpec(Collections.singletonMap("DT", 
"new")));
+
+            Assertions.assertEquals(Collections.singletonList("dt=new"), 
client.requestedPartitions);
+            Assertions.assertTrue(sink.getPartitions().isEmpty(), "BE must 
classify the absent target as NEW");
+        }
+    }
+
+    @Test
+    public void emptyStringStaticValueUsesHiveDefaultPartition() {
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+        client.rejectPartitionListing = true;
+        client.partitions = Collections.singletonList(
+                
partition(Collections.singletonList("__HIVE_DEFAULT_PARTITION__")));
+
+        THiveTableSink sink = planSink(client, new RecordingConnectorContext(),
+                handle().staticSpec(Collections.singletonMap("DT", "")));
+
+        
Assertions.assertEquals(Collections.singletonList("dt=__HIVE_DEFAULT_PARTITION__"),
+                client.requestedPartitions);
+        Assertions.assertEquals(1, sink.getPartitionsSize());
+    }
+
+    @Test
+    public void sqlNullStaticValueRetainsFullListing() {
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+        client.partitionNames = 
Collections.singletonList("dt=__HIVE_DEFAULT_PARTITION__");
+        client.partitions = Collections.singletonList(
+                
partition(Collections.singletonList("__HIVE_DEFAULT_PARTITION__")));
+        WriteHandle writeHandle = 
handle().staticSpec(Collections.singletonMap("DT", "NULL"))
+                .staticNullKeys(Collections.singleton("DT"));
+
+        THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(), writeHandle);
+
+        Assertions.assertTrue(client.calls.contains("listPartitionNames"));
+        Assertions.assertEquals(1, sink.getPartitionsSize());
+    }
+
+    @Test
+    public void staticPartitionLookupUsesCastValues() {
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+        client.rejectPartitionListing = true;
+        WriteHandle writeHandle = 
handle().staticSpec(Collections.singletonMap("DT", "too-long"));
+        writeHandle.castStaticSpec = Collections.singletonMap("DT", "too");
+
+        planSink(client, new RecordingConnectorContext(), writeHandle);
+
+        Assertions.assertEquals(Collections.singletonList("dt=too"), 
client.requestedPartitions,
+                "metadata must locate the partition from the value actually 
materialized into the row");
+    }
+
+    @Test
+    public void partialAndNullStaticSpecsRetainFullPartitionListing() {
+        for (Map<String, String> spec : Arrays.asList(Collections.<String, 
String>emptyMap(),
+                Collections.singletonMap("DT", "x"), Collections.<String, 
String>singletonMap("DT", null))) {
+            RecordingHmsClient client = new RecordingHmsClient();
+            client.table = 
tableBuilder().partitionKeys(Arrays.asList(col("dt", "string"), col("region", 
"string")))
+                    .build();
+            client.partitionNames = 
Collections.singletonList("dt=x/region=bj");
+            client.partitions = 
Collections.singletonList(partition(Arrays.asList("x", "bj")));
+
+            THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(), handle().staticSpec(spec));
+
+            Assertions.assertTrue(client.calls.contains("listPartitionNames"));
+            Assertions.assertEquals(client.partitionNames, 
client.requestedPartitions);
+            Assertions.assertEquals(1, sink.getPartitionsSize());
+        }
+    }
+
+    @Test
+    public void typedPartitionSpecsRetainFullPartitionListing() {
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("flag", 
"boolean"))).build();
+        client.partitionNames = Collections.singletonList("flag=1");
+        client.partitions = 
Collections.singletonList(partition(Collections.singletonList("1")));
+
+        THiveTableSink sink = planSink(client, new RecordingConnectorContext(),
+                handle().staticSpec(Collections.singletonMap("FLAG", "true")));
+
+        Assertions.assertTrue(client.calls.contains("listPartitionNames"));
+        Assertions.assertEquals(Collections.singletonList("1"), 
sink.getPartitions().get(0).getValues());
+    }
+
+    @Test
+    public void charAndVarcharPartitionsUseTargetLookup() {
+        // A CHAR/VARCHAR column carries its length in precision, not in 
typeName; the string-type gate must
+        // still recognize the type and narrow the listing.
+        for (String type : Arrays.asList("CHAR", "VARCHAR")) {
+            RecordingHmsClient client = new RecordingHmsClient();
+            client.table = 
tableBuilder().partitionKeys(Collections.singletonList(
+                    new ConnectorColumn("dt", ConnectorType.of(type, 8, -1), 
"", true, null))).build();
+            client.rejectPartitionListing = true;
+            client.partitions = 
Collections.singletonList(partition(Collections.singletonList("2026-10-19")));
+
+            THiveTableSink sink = planSink(client, new 
RecordingConnectorContext(),
+                    handle().staticSpec(Collections.singletonMap("DT", 
"2026-10-19")));
+
+            
Assertions.assertEquals(Collections.singletonList("dt=2026-10-19"), 
client.requestedPartitions);
+            Assertions.assertEquals(1, sink.getPartitionsSize());
+        }
+    }
+
+    @Test
+    public void staleCachedStaticTargetUsesFreshHmsLookup() {
+        // The object cache can still hold a partition that HMS has already 
dropped. The static target must be
+        // re-read from HMS, otherwise BE sends APPEND and the commit 
statistics update fails.
+        RecordingHmsClient client = new RecordingHmsClient();
+        client.table = 
tableBuilder().partitionKeys(Collections.singletonList(col("dt", 
"string"))).build();
+        client.rejectPartitionListing = true;
+        client.partitions = 
Collections.singletonList(partition(Collections.singletonList("2026-10-19")));
+        client.freshPartitions = Collections.emptyList();
+
+        THiveTableSink sink = planSink(client, new RecordingConnectorContext(),
+                handle().staticSpec(Collections.singletonMap("DT", 
"2026-10-19")));
+
+        Assertions.assertEquals(Collections.singletonList("dt=2026-10-19"), 
client.requestedPartitions);
+        Assertions.assertTrue(sink.getPartitions().isEmpty(),
+                "a dropped target must be absent from the sink so BE 
classifies it as NEW");
+        Assertions.assertTrue(client.calls.stream().anyMatch(c -> 
c.startsWith("getExistingPartitionsFresh")),
+                "the static target must bypass the partition-object cache; 
calls=" + client.calls);
+        Assertions.assertFalse(client.calls.stream().anyMatch(c -> 
c.startsWith("getExistingPartitions:")),

Review Comment:
   [P3] Check the cached lookup event the fake records
   
   `RecordingHmsClient.getExistingPartitions` delegates to `getPartitions`, 
which records `getPartitions:`. The check for `getExistingPartitions:` always 
passes, so the test would miss a redundant cached read followed by the expected 
fresh read. Assert against `getPartitions:` or have the fake record the cached 
lookup explicitly.



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