priyankporwal commented on a change in pull request #551: PHOENIX-5415: NPE in
getting conf from addHbaseResources in IndexUpgr…
URL: https://github.com/apache/phoenix/pull/551#discussion_r307841474
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
##########
@@ -572,34 +577,40 @@ private void prepareToRebuildIndexes(Connection conn,
String dataTableFullName)
}
if (hasViewIndex) {
- ResultSet
- rs =
+ ResultSet rs =
conn.createStatement().executeQuery(
"SELECT DISTINCT TABLE_NAME, TENANT_ID FROM "
- + "SYSTEM.CATALOG WHERE COLUMN_FAMILY
= \'"
- + viewIndexPhysicalName
- + "\' AND TABLE_TYPE = \'i\' AND " +
"LINK_TYPE = "
+ + "SYSTEM.CATALOG "
+ + "WHERE COLUMN_FAMILY =
\'"+dataTableFullName+"\' "
+ + "AND LINK_TYPE = "
+
PTable.LinkType.PHYSICAL_TABLE.getSerializedValue());
while (rs.next()) {
- String viewIndexName = rs.getString(1);
+ String viewName = rs.getString(1);
String tenantId = rs.getString(2);
ResultSet
innerRS =
conn.createStatement().executeQuery(
- "SELECT DISTINCT TABLE_NAME FROM "
- + "SYSTEM.CATALOG WHERE
COLUMN_FAMILY = \'"
- + viewIndexName
- + "\' AND TABLE_TYPE = \'i\' AND "
+ "LINK_TYPE = "
- +
PTable.LinkType.INDEX_TABLE.getSerializedValue());
- innerRS.next();
- String viewName = innerRS.getString(1);
- IndexInfo indexInfo = new IndexInfo(schemaName, viewName,
tenantId == null ? GLOBAL_INDEX_ID: tenantId,
- viewIndexName);
- rebuildIndexes.put(viewIndexName, indexInfo);
+ "SELECT DISTINCT COLUMN_FAMILY FROM "
+ + "SYSTEM.CATALOG "
+ + "WHERE TABLE_NAME =
\'"+viewName+"\'"
+ + "AND LINK_TYPE = "
+ +
PTable.LinkType.INDEX_TABLE.getSerializedValue()
+ + (tenantId != null? " AND
TENANT_ID = \'"+tenantId+"\'":""));
+ while(innerRS.next()) {
+ String viewIndexName = innerRS.getString(1);
+ IndexInfo
+ indexInfo =
+ new IndexInfo(schemaName, viewName,
+ tenantId == null ? GLOBAL_INDEX_ID :
tenantId, viewIndexName);
+ rebuildIndexes.put(viewIndexName, indexInfo);
+ }
}
}
//for rebuilding indexes in case of upgrade.
rebuildMap.put(dataTableFullName, rebuildIndexes);
+
+ String json = gson.toJson(rebuildMap);
+ LOGGER.info("Index rebuild map " +json);
Review comment:
Nit: space after +
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services