Skip to content

Commit

Permalink
[BugFix] Fix dynamic_overwrite on non automatic partition table
Browse files Browse the repository at this point in the history
Signed-off-by: meegoo <[email protected]>
  • Loading branch information
meegoo committed Dec 9, 2024
1 parent c8f6c6b commit 479b908
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public static void analyzeWithDeferredLock(InsertStmt insertStmt, ConnectContext
} else if (insertStmt.isStaticKeyPartitionInsert()) {
checkStaticKeyPartitionInsert(insertStmt, table, targetPartitionNames);
} else {
if ((insertStmt.isOverwrite() && session.getSessionVariable().isDynamicOverwrite())) {
if ((insertStmt.isOverwrite() && session.getSessionVariable().isDynamicOverwrite())
&& olapTable.supportedAutomaticPartition()) {
insertStmt.setIsDynamicOverwrite(true);
} else {
for (Partition partition : olapTable.getPartitions()) {
Expand Down
78 changes: 78 additions & 0 deletions test/sql/test_dynamic_overwrite/R/test_overwrite
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ show variables like '%dynamic_overwrite%';
-- result:
dynamic_overwrite true
-- !result




-- name: test_dynamic_overwrite
create table t(k int, v int) partition by (k);
-- result:
Expand Down Expand Up @@ -44,4 +48,78 @@ select * from t;
4 1
2 2
3 2
-- !result



-- name: test_dynamic_overwrite_on_other_table
create table t(k int) partition by range(k)
(
PARTITION p1 VALUES LESS THAN ("1"),
PARTITION p2 VALUES LESS THAN ("2")
);
-- result:
-- !result
insert into t values(0);
-- result:
-- !result
insert into t values(1);
-- result:
-- !result
select * from t;
-- result:
0
1
-- !result
insert overwrite t values(1);
-- result:
-- !result
select * from t;
-- result:
1
-- !result
set dynamic_overwrite=true;
-- result:
-- !result
insert overwrite t values(0);
-- result:
-- !result
select * from t;
-- result:
0
-- !result
create table t1(k int)
PARTITION BY LIST (k) (
PARTITION p1 VALUES IN ("1"),
PARTITION p2 VALUES IN ("0")
);
-- result:
-- !result
insert into t1 values(0);
-- result:
-- !result
insert into t1 values(1);
-- result:
-- !result
select * from t1;
-- result:
1
0
-- !result
insert overwrite t1 values(1);
-- result:
-- !result
select * from t1;
-- result:
1
-- !result
set dynamic_overwrite=true;
-- result:
-- !result
insert overwrite t1 values(0);
-- result:
-- !result
select * from t1;
-- result:
0
-- !result
36 changes: 36 additions & 0 deletions test/sql/test_dynamic_overwrite/T/test_overwrite
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,39 @@ select * from t;
set dynamic_overwrite=true;
insert overwrite t values(4,1),(3,2);
select * from t;

-- name: test_dynamic_overwrite_on_other_table
create table t(k int) partition by range(k)
(
PARTITION p1 VALUES LESS THAN ("1"),
PARTITION p2 VALUES LESS THAN ("2")
);

insert into t values(0);
insert into t values(1);
select * from t;

insert overwrite t values(1);
select * from t;

set dynamic_overwrite=true;
insert overwrite t values(0);
select * from t;


create table t1(k int)
PARTITION BY LIST (k) (
PARTITION p1 VALUES IN ("1"),
PARTITION p2 VALUES IN ("0")
);

insert into t1 values(0);
insert into t1 values(1);
select * from t1;

insert overwrite t1 values(1);
select * from t1;

set dynamic_overwrite=true;
insert overwrite t1 values(0);
select * from t1;

0 comments on commit 479b908

Please sign in to comment.