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


##########
regression-test/suites/external_table_p0/hive/write/test_hive_write_static_partition.groovy:
##########
@@ -0,0 +1,304 @@
+// 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_hive_write_static_partition", 
"p0,external,hive,external_docker,external_docker_hive") {
+
+    // Static partition insert:
+    //   INSERT [OVERWRITE] TABLE t PARTITION(col='val', ...) SELECT ...
+    // The partition column value comes from the PARTITION clause instead of 
the query output.
+    def testStaticPartitionWrite = { String catalog_name ->
+        String tableName = "hive_static_par_tbl"
+
+        hive_docker """ DROP TABLE IF EXISTS ${tableName}; """
+        hive_docker """
+            CREATE TABLE ${tableName} (
+                tag_value string,
+                user_id   string,
+                ts        int
+            )
+            PARTITIONED BY (ts_date string)
+            STORED AS parquet;
+        """
+        sql """ refresh catalog ${catalog_name}; """
+
+        // 1. INSERT INTO ... PARTITION(ts_date='2026-07-24') without listing 
the partition column in SELECT.
+        //    This used to fail with "insert into cols should be corresponding 
to the query output".
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='2026-07-24')
+            SELECT 'tagA', 'u1', 100;
+        """
+        // 2. Append another row into the SAME partition.
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='2026-07-24')
+            SELECT 'tagB', 'u2', 200;
+        """
+        // 3. Insert into a DIFFERENT partition.
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='2026-07-25')
+            SELECT 'tagC', 'u3', 300;
+        """
+        sql """ refresh catalog ${catalog_name}; """
+
+        // Verify: 2 rows in partition 2026-07-24 and 1 row in 2026-07-25, 
partition column filled correctly.
+        def all = sql """ select tag_value, user_id, ts, ts_date from 
${tableName} order by ts_date, ts; """
+        assertEquals(3, all.size())
+        assertEquals("tagA", all[0][0]); assertEquals("2026-07-24", all[0][3])
+        assertEquals("tagB", all[1][0]); assertEquals("2026-07-24", all[1][3])
+        assertEquals("tagC", all[2][0]); assertEquals("2026-07-25", all[2][3])
+
+        // Partition pruning should work on the statically written partition 
value.
+        def p24 = sql """ select tag_value from ${tableName} where 
ts_date='2026-07-24' order by ts; """
+        assertEquals(2, p24.size())
+
+        // 4. INSERT OVERWRITE a single partition: it should only replace 
2026-07-24, leaving 2026-07-25 intact.
+        sql """
+            INSERT OVERWRITE TABLE ${tableName} PARTITION(ts_date='2026-07-24')
+            SELECT 'tagX', 'u9', 999;
+        """
+        sql """ refresh catalog ${catalog_name}; """
+
+        def afterOverwrite = sql """ select tag_value, user_id, ts, ts_date 
from ${tableName} order by ts_date, ts; """
+        assertEquals(2, afterOverwrite.size())
+        // partition 2026-07-24 replaced by a single row
+        assertEquals("tagX", afterOverwrite[0][0]); assertEquals(999, 
afterOverwrite[0][2])
+        assertEquals("2026-07-24", afterOverwrite[0][3])
+        // partition 2026-07-25 untouched
+        assertEquals("tagC", afterOverwrite[1][0]); assertEquals("2026-07-25", 
afterOverwrite[1][3])
+
+        // 5. Static partition combined with an explicit (non-partition) 
column list.
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='2026-07-26') 
(tag_value, user_id, ts)
+            SELECT 'tagD', 'u4', 400;
+        """
+        sql """ refresh catalog ${catalog_name}; """
+        def p26 = sql """ select tag_value, ts_date from ${tableName} where 
ts_date='2026-07-26'; """
+        assertEquals(1, p26.size())
+        assertEquals("tagD", p26[0][0])
+
+        // 6. Partition column name matching should be case-insensitive.
+        sql """
+            INSERT INTO ${tableName} PARTITION(TS_DATE='2026-07-27')
+            SELECT 'tagE', 'u5', 500;
+        """
+        sql """ refresh catalog ${catalog_name}; """
+        def p27 = sql """ select tag_value, ts_date from ${tableName} where 
ts_date='2026-07-27'; """
+        assertEquals(1, p27.size())
+        assertEquals("tagE", p27[0][0])
+        assertEquals("2026-07-27", p27[0][1])
+
+        // 7. Inline VALUES form (no explicit column list): partition column 
value comes from the
+        //    PARTITION clause, so VALUES only supplies the non-partition 
columns.
+        sql """
+            INSERT INTO ${tableName} PARTITION(ts_date='2026-07-28')
+            VALUES ('tagF', 'u6', 600);
+        """
+        sql """ refresh catalog ${catalog_name}; """
+        def p28 = sql """ select tag_value, user_id, ts, ts_date from 
${tableName} where ts_date='2026-07-28'; """
+        assertEquals(1, p28.size())
+        assertEquals("tagF", p28[0][0]); assertEquals("u6", p28[0][1])
+        assertEquals(600, p28[0][2]); assertEquals("2026-07-28", p28[0][3])
+
+        // 8. INSERT OVERWRITE with inline VALUES should only replace the 
targeted partition.
+        sql """
+            INSERT OVERWRITE TABLE ${tableName} PARTITION(ts_date='2026-07-28')
+            VALUES ('tagG', 'u7', 700);
+        """
+        sql """ refresh catalog ${catalog_name}; """
+        def p28ow = sql """ select tag_value, ts, ts_date from ${tableName} 
where ts_date='2026-07-28'; """
+        assertEquals(1, p28ow.size())
+        assertEquals("tagG", p28ow[0][0]); assertEquals(700, p28ow[0][1])
+        assertEquals("2026-07-28", p28ow[0][2])
+
+        hive_docker """ DROP TABLE IF EXISTS ${tableName}; """
+    }
+
+    def testStaticPartitionMultiColumnWrite = { String catalog_name ->

Review Comment:
   [P2] Cover hybrid static/dynamic Hive partitions
   
   This suite only exercises fully static multi-column targets, but the 
implementation also accepts a subset such as `PARTITION(dt='2026-07-24') SELECT 
..., region`. `BindSink` then removes only `dt`, and the physical sink must 
route on both the synthesized `dt` slot and the child-sourced `region` slot. 
That is a distinct write/overwrite path when one statement emits several 
regions, and none of the current cases proves its routing or sibling 
preservation. Please add end-to-end Hive INSERT and OVERWRITE coverage that 
emits multiple dynamic partition values under one static prefix and verifies 
the affected partitions plus an untouched sibling prefix.



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