ChinmaySKulkarni commented on a change in pull request #944: URL: https://github.com/apache/phoenix/pull/944#discussion_r528024432
########## File path: phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java ########## @@ -337,6 +337,49 @@ public boolean filterAllRemaining() { /** * Attempt to drop an orphan child view i.e. a child view for which we see a parent->child entry * in SYSTEM.CHILD_LINK/SYSTEM.CATALOG (as a child) but for whom the parent no longer exists. + * Its better to use this version, and trying to get the hTable Lazily instead of checking it + * first via HBase admin call + * @param env Region Coprocessor environment + * @param tenantIdBytes tenantId of the parent + * @param schemaName schema of the parent + * @param tableOrViewName parent table/view name + * @throws IOException thrown if there is an error scanning SYSTEM.CHILD_LINK or SYSTEM.CATALOG + * @throws SQLException thrown if there is an error getting a connection to the server or + * an error retrieving the PTable for a child view + */ + public static void dropChildViews(RegionCoprocessorEnvironment env, byte[] tenantIdBytes, + byte[] schemaName, byte[] tableOrViewName) + throws IOException, SQLException { + Configuration conf = env.getConfiguration(); + Table hTable = null; + try { + byte[] sysCatOrSysChildLink = SchemaUtil.getPhysicalTableName(SYSTEM_CATALOG_NAME_BYTES, Review comment: The order needs to be reversed here. We should first try to get `SYSTEM.CHILD_LINK` and if that fails, fallback to using `SYSTEM.CATALOG`. We also need to maintain the client version logic that [ViewUtil.getSystemTableForChildLinks()](https://github.com/apache/phoenix/blob/bf8bb519b0c3d0fe96e7e1e33a7672fc0e15b1ad/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java#L497) has. Btw, with your changes, do we need the `getSystemTableForChildLinks()` API anymore? ---------------------------------------------------------------- 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: us...@infra.apache.org