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

[Feature] List Partition For AMV(Part 2): Support list partition for asynchronous materialized view with non-nullable partition columns #46680

Merged

Conversation

LiShuMing
Copy link
Contributor

@LiShuMing LiShuMing commented Jun 5, 2024

Why I'm doing:

What I'm doing:

  • Support mv refresh for list partitioned amv;
  • Support mv rewrite for list partitioned amv;
CREATE TABLE t3 (
      id BIGINT,
      province VARCHAR(64) not null,
      age SMALLINT,
      dt VARCHAR(10) not null
)
DUPLICATE KEY(id)
PARTITION BY LIST (province, dt) (
     PARTITION p1 VALUES IN (("beijing", "2024-01-01"))  ,
     PARTITION p2 VALUES IN (("guangdong", "2024-01-01")), 
     PARTITION p3 VALUES IN (("beijing", "2024-01-02"))  ,
     PARTITION p4 VALUES IN (("guangdong", "2024-01-02")) 
)
DISTRIBUTED BY RANDOM;
INSERT INTO t3 VALUES (1, 'beijing', 20, '2024-01-01'), (2, 'guangdong', 20, '2024-01-01'), (3, 'guangdong', 20, '2024-01-02');

-- test sync refresh & partition_refresh_number= 1
create materialized view test_mv1
partition by province
REFRESH DEFERRED MANUAL
distributed by hash(dt, province) buckets 10 
PROPERTIES (
"replication_num" = "1"
) 
as select dt, province, sum(age) from t3 group by dt, province;
refresh materialized view  test_mv1 with sync mode;
select * from test_mv1 order by 1, 2;
function: check_hit_materialized_view("select dt, province, sum(age) from t3 group by dt, province order by 1, 2;", "test_mv1")
select dt, province, sum(age) from t3 group by dt, province order by 1, 2;
INSERT INTO t3 VALUES (2, 'beijing', 20, '2024-01-01');
function: check_hit_materialized_view("select dt, province, sum(age) from t3 group by dt, province order by 1, 2;", "test_mv1")
select dt, province, sum(age) from t3 group by dt, province order by 1, 2;
drop materialized view test_mv1;

Fixes #46087

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@LiShuMing LiShuMing requested review from a team as code owners June 5, 2024 10:21
@LiShuMing LiShuMing force-pushed the fix/main/support_list_partitions_mv.v3 branch 3 times, most recently from a5cd3d6 to 73e5c67 Compare June 6, 2024 16:17
@LiShuMing LiShuMing changed the title [Feature] [WIP] Support list partition for not nullable columns [Feature] Support list partition for not nullable columns Jun 27, 2024
@LiShuMing LiShuMing changed the title [Feature] Support list partition for not nullable columns [Feature] Support list partition for asynchronous materialized view with non-nullable partition columns Jun 27, 2024
@LiShuMing LiShuMing force-pushed the fix/main/support_list_partitions_mv.v3 branch from 7daffaf to 68c2189 Compare June 27, 2024 08:46
@LiShuMing LiShuMing changed the title [Feature] Support list partition for asynchronous materialized view with non-nullable partition columns [Feature] List Partition For AMV(Part 2): Support list partition for asynchronous materialized view with non-nullable partition columns Jun 27, 2024
Signed-off-by: shuming.li <[email protected]>
@LiShuMing LiShuMing force-pushed the fix/main/support_list_partitions_mv.v3 branch from cfe2a34 to a967fe5 Compare June 30, 2024 00:13
Signed-off-by: shuming.li <[email protected]>

fix bugs

Signed-off-by: shuming.li <[email protected]>
Copy link

sonarcloud bot commented Jul 1, 2024

Map<String, PListCell> mvItems) {
// This synchronization method has a one-to-one correspondence
// between the base table and the partition of the mv.
Map<String, PListCell> adds = diffList(baseItems, mvItems);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any risk to be a time-consuming step when table or mv has a large number of partitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It's possible to be time consuming.

I will add a benchmark to figure out how slow it's, and do some optimization later in the next pr.

Copy link

github-actions bot commented Jul 1, 2024

[FE Incremental Coverage Report]

pass : 363 / 445 (81.57%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/scheduler/mv/MVPCTRefreshPartitioner.java 0 1 00.00% [150]
🔵 com/starrocks/catalog/MvBaseTableUpdateInfo.java 0 2 00.00% [73, 74]
🔵 com/starrocks/catalog/mv/MVTimelinessListPartitionArbiter.java 31 57 54.39% [52, 53, 54, 61, 67, 68, 101, 103, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 118, 120, 121, 122, 123, 124, 125]
🔵 com/starrocks/scheduler/ExecuteOption.java 7 12 58.33% [128, 129, 130, 132, 134]
🔵 com/starrocks/sql/common/ListPartitionDiff.java 6 10 60.00% [39, 40, 47, 48]
🔵 com/starrocks/catalog/MvRefreshArbiter.java 2 3 66.67% [201]
🔵 com/starrocks/scheduler/TaskRunManager.java 6 9 66.67% [147, 149, 153]
🔵 com/starrocks/sql/common/PListAtom.java 15 21 71.43% [39, 42, 45, 50, 55, 69]
🔵 com/starrocks/sql/analyzer/MaterializedViewAnalyzer.java 8 10 80.00% [813, 818]
🔵 com/starrocks/sql/common/PListCellPlus.java 25 30 83.33% [40, 79, 82, 85, 93]
🔵 com/starrocks/scheduler/mv/MVPCTRefreshListPartitioner.java 117 137 85.40% [76, 83, 84, 138, 143, 150, 159, 171, 186, 188, 192, 208, 210, 251, 252, 267, 268, 305, 306, 307]
🔵 com/starrocks/sql/common/ListPartitionDiffer.java 113 120 94.17% [206, 250, 251, 252, 253, 265, 266]
🔵 com/starrocks/scheduler/PartitionBasedMvRefreshProcessor.java 2 2 100.00% []
🔵 com/starrocks/catalog/mv/MVTimelinessArbiter.java 8 8 100.00% []
🔵 com/starrocks/sql/common/ListPartitionDiffResult.java 6 6 100.00% []
🔵 com/starrocks/sql/common/RangePartitionDiffer.java 1 1 100.00% []
🔵 com/starrocks/scheduler/mv/MVPCTRefreshRangePartitioner.java 3 3 100.00% []
🔵 com/starrocks/sql/common/PListCell.java 11 11 100.00% []
🔵 com/starrocks/catalog/mv/MVTimelinessRangePartitionArbiter.java 2 2 100.00% []

Copy link

github-actions bot commented Jul 1, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@LiShuMing LiShuMing enabled auto-merge (squash) July 1, 2024 12:26
@LiShuMing LiShuMing merged commit 7ea0e0f into StarRocks:main Jul 1, 2024
62 checks passed
@LiShuMing LiShuMing deleted the fix/main/support_list_partitions_mv.v3 branch July 1, 2024 12:55
@LiShuMing
Copy link
Contributor Author

@Mergifyio backport branch-3.3

Copy link
Contributor

mergify bot commented Jul 1, 2024

backport branch-3.3

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 1, 2024
…asynchronous materialized view with non-nullable partition columns (#46680)

Signed-off-by: shuming.li <[email protected]>
(cherry picked from commit 7ea0e0f)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/scheduler/PartitionBasedMvRefreshProcessor.java
#	fe/fe-core/src/main/java/com/starrocks/sql/common/RangePartitionDiffer.java
#	test/lib/sr_sql_lib.py
wanpengfei-git pushed a commit that referenced this pull request Jul 1, 2024
…asynchronous materialized view with non-nullable partition columns (backport #46680) (#47712)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
XinzhuangL pushed a commit to fl4me-starrocks/starrocks that referenced this pull request Jul 2, 2024
…asynchronous materialized view with non-nullable partition columns (StarRocks#46680)

Signed-off-by: shuming.li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MV] Support list partition for materialized view
7 participants