Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support alter table add roll up in shared data #53153

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
38 changes: 38 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,38 @@
-- 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

SELECT v1 FROM rollup1 [_SYNC_MV_] ORDER BY v1;
-- result:
100
300
-- !result
23 changes: 23 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,23 @@
-- 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);

SELECT v1 FROM rollup1 [_SYNC_MV_] ORDER BY v1;
22 changes: 20 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,31 @@ 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

SELECT mv_sum_v1 FROM sync_mv [_SYNC_MV_] ORDER BY k1;
-- result:
300
100
-- !result
13 changes: 4 additions & 9 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,16 @@ 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

SELECT mv_sum_v1 FROM sync_mv [_SYNC_MV_] ORDER BY k1;
Loading