Source:
public static void dropChildViews(RegionCoprocessorEnvironment env, byte[] tenantIdBytes, byte[] schemaName, byte[] tableName) throws IOException, SQLException, ClassNotFoundException { Table hTable = ServerUtil.getHTableForCoprocessorScan(env, SchemaUtil.getPhysicalTableName( PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME_BYTES, env.getConfiguration())); TableViewFinderResult childViewsResult = ViewFinder.findRelatedViews(hTable, tenantIdBytes, schemaName, tableName, PTable.LinkType.CHILD_TABLE, HConstants.LATEST_TIMESTAMP); if (childViewsResult.hasLinks()) { for (TableInfo viewInfo : childViewsResult.getLinks()) { byte[] viewTenantId = viewInfo.getTenantId(); byte[] viewSchemaName = viewInfo.getSchemaName(); byte[] viewName = viewInfo.getTableName(); logger.debug("dropChildViews :" + Bytes.toString(schemaName) + "." + Bytes.toString(tableName) + " -> " + Bytes.toString(viewSchemaName) + "." + Bytes.toString(viewName) + "with tenant id :" + Bytes.toString(viewTenantId)); Properties props = new Properties(); if (viewTenantId != null && viewTenantId.length != 0) props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, Bytes.toString(viewTenantId)); try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(props, env.getConfiguration()) .unwrap(PhoenixConnection.class)) { MetaDataClient client = new MetaDataClient(connection); org.apache.phoenix.parse.TableName viewTableName = org.apache.phoenix.parse.TableName .create(Bytes.toString(viewSchemaName), Bytes.toString(viewName)); client.dropTable( new DropTableStatement(viewTableName, PTableType.VIEW, false, true, true)); } } } }

Target:
public static void dropChildViews(RegionCoprocessorEnvironment env, byte[] tenantIdBytes, byte[] schemaName, byte[] tableName) throws IOException, SQLException, ClassNotFoundException { Table hTable = ServerUtil.getHTableForCoprocessorScan(env, SchemaUtil.getPhysicalTableName( PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME_BYTES, env.getConfiguration())); TableViewFinderResult childViewsResult = ViewFinder.findRelatedViews(hTable, tenantIdBytes, schemaName, tableName, PTable.LinkType.CHILD_TABLE, HConstants.LATEST_TIMESTAMP); if (childViewsResult.hasLinks()) { for (TableInfo viewInfo : childViewsResult.getLinks()) { byte[] viewTenantId = viewInfo.getTenantId(); byte[] viewSchemaName = viewInfo.getSchemaName(); byte[] viewName = viewInfo.getTableName(); if (logger.isDebugEnabled()) { logger.debug("dropChildViews :" + Bytes.toString(schemaName) + "." + Bytes.toString(tableName) + " -> " + Bytes.toString(viewSchemaName) + "." + Bytes.toString(viewName) + "with tenant id :" + Bytes.toString(viewTenantId)); } Properties props = new Properties(); if (viewTenantId != null && viewTenantId.length != 0) props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, Bytes.toString(viewTenantId)); try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(props, env.getConfiguration()) .unwrap(PhoenixConnection.class)) { MetaDataClient client = new MetaDataClient(connection); org.apache.phoenix.parse.TableName viewTableName = org.apache.phoenix.parse.TableName .create(Bytes.toString(viewSchemaName), Bytes.toString(viewName)); client.dropTable( new DropTableStatement(viewTableName, PTableType.VIEW, false, true, true)); } } } }