phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Taylor (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-4634) Looking up a parent index table of a tenant child view fails in BaseColumnResolver createTableRef()
Date Fri, 09 Mar 2018 16:56:00 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-4634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16393164#comment-16393164
] 

James Taylor commented on PHOENIX-4634:
---------------------------------------

Thanks for the revised patch, [~tdsilva]. Couple of questions/comments:
- I was thinking we could just reset tableName and schemaName at the start of the method (and
not repeat this code which is done a few lines up). Would that work? I supposed we need to
remember the original full table name (unless we can recreate it easily). See v4 of the patch
I attached.
{code}
+        boolean resolveInheritedIndex = tableName.contains(QueryConstants.CHILD_VIEW_INDEX_NAME_SEPARATOR);
+        if (resolveInheritedIndex) {
+            String viewName =
+                    SchemaUtil.getTableNameFromFullName(tableName,
+                        QueryConstants.CHILD_VIEW_INDEX_NAME_SEPARATOR);
+            schemaName = SchemaUtil.getSchemaNameFromFullName(viewName);
+            tableName = SchemaUtil.getTableNameFromFullName(viewName);
+            try {
+                tableRef = connection.getTableRef(new PTableKey(tenantId, viewName));
+                table = tableRef.getTable();
+                tableTimestamp = table.getTimeStamp();
+                tableResolvedTimestamp = tableRef.getResolvedTimeStamp();
+            } catch (TableNotFoundException e) {
+            }
+        }
{code}
- The end if block doesn't look right as you'd be resetting the result to have a null table
so the if would always be false. I think you just need to reset result in the catch block.
See v4 of the patch I attached.
{code}
+        if (resolveInheritedIndex) {
+            // reset the result as we looked up the parent view 
+            result = new MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND,
+                QueryConstants.UNSET_TIMESTAMP, null);
+            if (result.getTable() != null) {
+                try {
+                    // look up the inherited index
+                    tableRef = connection.getTableRef(new PTableKey(tenantId, fullTableName));
+                    table = tableRef.getTable();
+                    result =
+                            new MetaDataMutationResult(MutationCode.TABLE_ALREADY_EXISTS,
+                                    QueryConstants.UNSET_TIMESTAMP, table);
+                } catch (TableNotFoundException e) {
+                }
+            }
+        }
{code}
- Higher level question: why/when is this issue occurring? Is it only from the PhoenixRuntime.getTable()
call? Or more broadly? If the former, then is it better to fix this more locally in PhoenixRuntime
(as it seems you originally tried to do)? Is there a better, cleaner fix as I can't help but
feel like this is a hack (which is fine for now).

> Looking up a parent index table of a tenant child view fails in BaseColumnResolver createTableRef()
> ---------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-4634
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4634
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Thomas D'Silva
>            Assignee: Thomas D'Silva
>            Priority: Major
>             Fix For: 4.14.0
>
>         Attachments: PHOENIX-4634-4.x-HBase-0.98.patch, PHOENIX-4634-v2.patch, PHOENIX-4634-v3.patch
>
>
> If we are looking up a parent table index of a child view , we need to resolve the view
which will load the parent table indexes (instead of trying to resolve the parent table index
directly). 
>  
> {code:java}
> org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03): Table undefined.
tableName=Schema.Schema.Index#Schma.View
> org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.createTableRef(FromCompiler.java:577)
> at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.<init>(FromCompiler.java:391)
> at org.apache.phoenix.compile.FromCompiler.getResolverForQuery(FromCompiler.java:228)
> at org.apache.phoenix.compile.FromCompiler.getResolverForQuery(FromCompiler.java:206)
> at org.apache.phoenix.optimize.QueryOptimizer.addPlan(QueryOptimizer.java:226)
> at org.apache.phoenix.optimize.QueryOptimizer.getApplicablePlans(QueryOptimizer.java:146)
> at org.apache.phoenix.optimize.QueryOptimizer.getApplicablePlans(QueryOptimizer.java:103)
> at org.apache.phoenix.compile.DeleteCompiler.compile(DeleteCompiler.java:501)
> at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableDeleteStatement.compilePlan(PhoenixStatement.java:770)
> at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableDeleteStatement.compilePlan(PhoenixStatement.java:758)
> at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:386)
> at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:376)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message