Skip to content

Commit

Permalink
support alter table add roll up in shard data
Browse files Browse the repository at this point in the history
Signed-off-by: smartlxh <[email protected]>
  • Loading branch information
smartlxh committed Nov 23, 2024
1 parent 89be537 commit a925ca2
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,6 @@ private void getAlterJobV2Infos(Database db, List<List<Comparable>> rollupJobInf
@Override
public ShowResultSet process(List<AlterClause> alterClauses, Database db, OlapTable olapTable)
throws DdlException, AnalysisException, MetaNotFoundException {
if (olapTable.isCloudNativeTable()) {
throw new DdlException("Does not support add rollup on lake table");
}
if (olapTable.existTempPartitions()) {
throw new DdlException("Can not alter table when there are temp partitions in table");
}
Expand Down
32 changes: 32 additions & 0 deletions test/sql/test_lake_rollup/R/test_lake_rollup
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- name: test_lake_rollup @cloud
CREATE TABLE tbl1 (
k1 date,
k2 int,
v1 int sum
) PARTITION BY RANGE(k1) (
PARTITION p1 values [('2020-01-01'),('2020-02-01')),
PARTITION p2 values [('2020-02-01'),('2020-03-01')))
DISTRIBUTED BY HASH(k2) BUCKETS 3
PROPERTIES('replication_num' = '1');
-- result:
-- !result

INSERT INTO tbl1
VALUES
("2020-01-12",4,100),
("2020-01-11",5,100),
("2020-01-11",4,100);
-- result:
-- !result

ALTER TABLE tbl1 ADD ROLLUP rollup1 (k1, v1) FROM tbl1;
-- result:
-- !result
function: wait_alter_table_finish("ROLLUP")
-- result:
None
-- !result

INSERT INTO tbl1 VALUES("2020-01-11",6,100);
-- result:
-- !result
21 changes: 21 additions & 0 deletions test/sql/test_lake_rollup/T/test_lake_rollup
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- name: test_lake_rollup @cloud
CREATE TABLE tbl1 (
k1 date,
k2 int,
v1 int sum
) PARTITION BY RANGE(k1) (
PARTITION p1 values [('2020-01-01'),('2020-02-01')),
PARTITION p2 values [('2020-02-01'),('2020-03-01')))
DISTRIBUTED BY HASH(k2) BUCKETS 3
PROPERTIES('replication_num' = '1');

INSERT INTO tbl1
VALUES
("2020-01-12",4,100),
("2020-01-11",5,100),
("2020-01-11",4,100);

ALTER TABLE tbl1 ADD ROLLUP rollup1 (k1, v1) FROM tbl1;
function: wait_alter_table_finish("ROLLUP")

INSERT INTO tbl1 VALUES("2020-01-11",6,100);
16 changes: 14 additions & 2 deletions test/sql/test_lake_sync_mv/R/test_lake_sync_mv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- name: test_invalid_json @cloud
-- name: test_lake_sync_mv @cloud
CREATE TABLE tbl1 (
k1 date,
k2 int,
Expand All @@ -8,13 +8,25 @@ CREATE TABLE tbl1 (
PARTITION p2 values [('2020-02-01'),('2020-03-01')))
DISTRIBUTED BY HASH(k2) BUCKETS 3
PROPERTIES('replication_num' = '1');
-- result:
-- !result

INSERT INTO tbl1
VALUES
("2020-01-12",4,100),
("2020-01-11",5,100),
("2020-01-11",4,100);
-- result:
-- !result

CREATE MATERIALIZED VIEW sync_mv AS SELECT k1, SUM(v1) FROM tbl1 GROUP BY k1;
-- result:
-- !result
function: wait_materialized_view_finish()
-- result:
None
-- !result

INSERT INTO tbl1 VALUES("2020-01-11",6,100);
INSERT INTO tbl1 VALUES("2020-01-11",6,100);
-- result:
-- !result
13 changes: 3 additions & 10 deletions test/sql/test_lake_sync_mv/T/test_lake_sync_mv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- name: test_invalid_json @cloud
-- name: test_lake_sync_mv @cloud
CREATE TABLE tbl1 (
k1 date,
k2 int,
Expand All @@ -8,21 +8,14 @@ CREATE TABLE tbl1 (
PARTITION p2 values [('2020-02-01'),('2020-03-01')))
DISTRIBUTED BY HASH(k2) BUCKETS 3
PROPERTIES('replication_num' = '1');
-- result:
-- !result

INSERT INTO tbl1
VALUES
("2020-01-12",4,100),
("2020-01-11",5,100),
("2020-01-11",4,100);
-- result:
-- !result

CREATE MATERIALIZED VIEW sync_mv AS SELECT k1, SUM(v1) FROM tbl1 GROUP BY k1;
-- result:
-- !result
function: wait_materialized_view_finish()

INSERT INTO tbl1 VALUES("2020-01-11",6,100);
-- result:
-- !result
INSERT INTO tbl1 VALUES("2020-01-11",6,100);

0 comments on commit a925ca2

Please sign in to comment.