-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 materialized view to active #23304
Conversation
Signed-off-by: Astralidea <[email protected]>
Signed-off-by: Astralidea <[email protected]>
Map<TableName, Table> tableNameTableMap = AnalyzerUtils.collectAllConnectorTableAndView(queryStatement); | ||
List<BaseTableInfo> baseTableInfos = MaterializedViewAnalyzer.getBaseTableInfos(tableNameTableMap); | ||
materializedView.setBaseTableInfos(baseTableInfos); | ||
materializedView.getRefreshScheme().getAsyncRefreshContext().clearVisibleVersionMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the MV's history data? Can it be queried again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The historical data of the MV can be queried, and theoretically it can be forced to trigger another refresh. This issue can be discussed together with the next PR issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After set active, we need to refresh this mv to enable the query rewrite?
continue; | ||
} | ||
MvId mvId = new MvId(dbId, mv.getId()); | ||
table.addRelatedMaterializedView(mvId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
table may already contain the mvId?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addRelatedMaterializedView use Set structure。
So even if you have it before, you won't add more. Normally, the MvID will be removed normally during Drop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other DDLs (like altering table column names) also can cause Mv's to be inactive, so need to be more careful.
if (table == null) { | ||
LOG.warn("Setting the materialized view {}({}) to invalid because " + | ||
"the table {} was not exist.", mv.getName(), mv.getId(), baseTableInfo.getTableName()); | ||
mv.setActive(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the inactive reason at the same time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to set maybe after your PR #21591 merge?
Signed-off-by: Astralidea <[email protected]>
Signed-off-by: Astralidea <[email protected]>
SonarCloud Quality Gate failed. |
[FE PR Coverage Check]😞 fail : 45 / 161 (27.95%) file detail
|
Pull request was closed
@Mergifyio backport branch-3.0 |
@Mergifyio backport branch-2.5 |
🟠 Waiting for conditions to match
|
🟠 Waiting for conditions to match
|
Fixes #23304 --------- Signed-off-by: Astralidea <[email protected]>
Fixes #23304 --------- Signed-off-by: Astralidea <[email protected]> (cherry picked from commit f74e15e) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/alter/Alter.java # fe/fe-core/src/main/java/com/starrocks/server/GlobalStateMgr.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/MaterializedViewAnalyzer.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/SemanticException.java # fe/fe-core/src/main/java/com/starrocks/sql/ast/AlterMaterializedViewStmt.java # fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java # fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 # fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocksLex.g4 # test/sql/test_materialized_column/R/test_materialized_column # test/sql/test_mv/R/basic
Fixes #23304 --------- Signed-off-by: Astralidea <[email protected]> (cherry picked from commit f74e15e) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/alter/Alter.java # fe/fe-core/src/main/java/com/starrocks/server/GlobalStateMgr.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/MaterializedViewAnalyzer.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/SemanticException.java # fe/fe-core/src/main/java/com/starrocks/sql/ast/AlterMaterializedViewStmt.java # fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java # fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 # fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocksLex.g4 # test/sql/test_materialized_column/R/test_materialized_column # test/sql/test_mv/R/basic
) Fixes StarRocks#23304 --------- Signed-off-by: Astralidea <[email protected]>
) Fixes StarRocks#23304 --------- Signed-off-by: Astralidea <[email protected]>
What type of PR is this:
Which issues of this PR fixes:
Fixes #
Problem Summary(Required):
There are still some issues with this solution, which will be resolved in the next PR.
Checklist:
Bugfix cherry-pick branch check: