[
https://issues.apache.org/jira/browse/PHOENIX-4195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16505416#comment-16505416
]
Thomas D'Silva commented on PHOENIX-4195:
-----------------------------------------
If the table/view has a child view that added their own PK columns the
optimization won't work. I don't think its makes sense to traverse the view
hierarchy just to determine whether or not to use this optimization.
I suggested not using the optimization for multi-tenant tables because as you
said PTable currently doesn't indicate if it has any child views and
multi-tenant tables are most likely have child views.
You could run a query on SYSTEM.CATALOG to see if the table/view has any child
views (by querying for the CHILD_TABLE link type). I needed to something
similar PHOENIX-3534. You could adapt the following code.
Also after PHOENIX-3534, the child links will be moved to their a separate
SYSTEM.CHILD_LINK table.
{code}
/**
* @return true if the given table has at least one child view
* @throws IOException
*/
public static boolean hasChildViews(Table systemCatalog, byte[] tenantId,
byte[] schemaName, byte[] tableName, long timestamp) throws IOException {
byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
Scan scan = MetaDataUtil.newTableRowsScan(key,
MetaDataProtocol.MIN_TABLE_TIMESTAMP, timestamp);
SingleColumnValueFilter linkFilter =
new SingleColumnValueFilter(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES,
CompareFilter.CompareOp.EQUAL,
LinkType.CHILD_TABLE.getSerializedValueAsByteArray()) {
// if we found a row with the CHILD_TABLE link type we are done and can
// terminate the scan
@Override
public boolean filterAllRemaining() throws IOException {
return matchedColumn;
}
};
linkFilter.setFilterIfMissing(true);
scan.setFilter(linkFilter);
scan.addColumn(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES);
try (ResultScanner scanner = systemCatalog.getScanner(scan)) {
Result result = scanner.next();
return result!=null;
}
}
{code}
> PHOENIX-4195 Deleting tenant rows using a tenant or global connection on the
> base table fails
> ---------------------------------------------------------------------------------------------
>
> Key: PHOENIX-4195
> URL: https://issues.apache.org/jira/browse/PHOENIX-4195
> Project: Phoenix
> Issue Type: Bug
> Reporter: Thomas D'Silva
> Assignee: Geoffrey Jacoby
> Priority: Major
> Attachments: test.diff
>
>
> The attached test fails.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)