Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-5650: IndexUpgradeTool does not rebuild view indexes#665
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
35 changes: 34 additions & 1 deletion
35 phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 26 additions & 15 deletions
41 phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -648,17 +648,12 @@ private HashMap<String, IndexInfo> prepareToRebuildIndexes(Connection conn, | ||
| } | ||
| if (hasViewIndex) { | ||
| String viewSql = "SELECT DISTINCT TABLE_NAME, TENANT_ID FROM " | ||
| + "SYSTEM.CATALOG " | ||
| + "WHERE COLUMN_FAMILY = \'" + dataTableFullName + "\' " | ||
| + (!StringUtil.EMPTY_STRING.equals(schemaName) ? "AND TABLE_SCHEM = \'" | ||
| + schemaName + "\' " : "") | ||
| + "AND LINK_TYPE = " | ||
| + PTable.LinkType.PHYSICAL_TABLE.getSerializedValue(); | ||
| String viewSql = getViewSql(tableName, schemaName); | ||
| ResultSet rs = conn.createStatement().executeQuery(viewSql); | ||
| while (rs.next()) { | ||
| String viewName = rs.getString(1); | ||
| String viewFullName = rs.getString(1); | ||
swaroopak marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| String viewName = SchemaUtil.getTableNameFromFullName(viewFullName); | ||
| String tenantId = rs.getString(2); | ||
| ArrayList<String> viewIndexes = findViewIndexes(conn, schemaName, viewName, | ||
| tenantId); | ||
| @@ -673,16 +668,21 @@ private HashMap<String, IndexInfo> prepareToRebuildIndexes(Connection conn, | ||
| return indexInfos; | ||
| } | ||
| @VisibleForTesting | ||
| public String getViewSql(String tableName, String schemaName) { | ||
| return "SELECT DISTINCT COLUMN_FAMILY, TENANT_ID FROM " | ||
| + "SYSTEM.CHILD_LINK " | ||
| + "WHERE TABLE_NAME = \'" + tableName + "\'" | ||
| + (!Strings.isNullOrEmpty(schemaName) ? " AND TABLE_SCHEM = \'" | ||
| + schemaName + "\'" : "") | ||
| + " AND LINK_TYPE = " | ||
| + PTable.LinkType.CHILD_TABLE.getSerializedValue(); | ||
| } | ||
| private ArrayList<String> findViewIndexes(Connection conn, String schemaName, String viewName, | ||
| String tenantId) throws SQLException { | ||
| String viewIndexesSql = "SELECT DISTINCT COLUMN_FAMILY FROM " | ||
| + "SYSTEM.CATALOG " | ||
| + "WHERE TABLE_NAME = \'" + viewName + "\'" | ||
| + (!StringUtil.EMPTY_STRING.equals(schemaName) ? "AND TABLE_SCHEM = \'" | ||
| + schemaName + "\' " : "") | ||
| + "AND LINK_TYPE = " + PTable.LinkType.INDEX_TABLE.getSerializedValue() | ||
| + (tenantId != null ? " AND TENANT_ID = \'" + tenantId + "\'" : ""); | ||
| String viewIndexesSql = getViewIndexesSql(viewName, schemaName, tenantId); | ||
| ArrayList<String> viewIndexes = new ArrayList<>(); | ||
| ResultSet rs = conn.createStatement().executeQuery(viewIndexesSql); | ||
| while (rs.next()) { | ||
| @@ -692,6 +692,17 @@ private ArrayList<String> findViewIndexes(Connection conn, String schemaName, St | ||
| return viewIndexes; | ||
| } | ||
| @VisibleForTesting | ||
| public String getViewIndexesSql(String viewName, String schemaName, String tenantId) { | ||
| return "SELECT DISTINCT COLUMN_FAMILY FROM " | ||
| + "SYSTEM.CATALOG " | ||
| + "WHERE TABLE_NAME = \'" + viewName + "\'" | ||
| + (!Strings.isNullOrEmpty(schemaName) ? " AND TABLE_SCHEM = \'" | ||
| + schemaName + "\'" : "") | ||
| + " AND LINK_TYPE = " + PTable.LinkType.INDEX_TABLE.getSerializedValue() | ||
| + (tenantId != null ? " AND TENANT_ID = \'" + tenantId + "\'" : ""); | ||
| } | ||
| private class IndexInfo { | ||
| final private String schemaName; | ||
| final private String baseTable; | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.