gokceni commented on a change in pull request #1170:
URL: https://github.com/apache/phoenix/pull/1170#discussion_r605086281



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1209,7 +1231,30 @@ private PTable getTable(RegionScanner scanner, long 
clientTimeStamp, long tableT
                 if (linkType == LinkType.INDEX_TABLE) {
                     addIndexToTable(tenantId, schemaName, famName, tableName, 
clientTimeStamp, indexes, clientVersion);
                 } else if (linkType == LinkType.PHYSICAL_TABLE) {
-                    physicalTables.add(famName);
+                    // famName contains the logical name of the parent table. 
We need to get the actual physical name of the table
+                    PTable parentTable = null;
+                    if (indexType != IndexType.LOCAL) {
+                        parentTable = getTable(null, 
SchemaUtil.getSchemaNameFromFullName(famName.getBytes()).getBytes(),
+                                
SchemaUtil.getTableNameFromFullName(famName.getBytes()).getBytes(), 
clientTimeStamp, clientVersion);
+                        if (parentTable == null) {
+                            // parentTable is not in the cache. Since famName 
is only logical name, we need to find the physical table.
+                            try (PhoenixConnection connection = 
QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class))
 {
+                                parentTable = 
PhoenixRuntime.getTableNoCache(connection, famName.getString());
+                            } catch (TableNotFoundException e) {
+                                // It is ok to swallow this exception since 
this could be a view index and _IDX_ table is not there.
+                            }
+                        }
+                    }
+
+                    if (parentTable == null) {
+                        physicalTables.add(famName);
+                        // If this is a view index, then one of the link is 
IDX_VW -> _IDX_ PhysicalTable link. Since famName is _IDX_ and we can't get 
this table hence it is null, we need to use actual view name
+                        parentLogicalName = (tableType == INDEX ? 
SchemaUtil.getTableName(parentSchemaName, parentTableName) : famName);

Review comment:
       INDEX is PTableType not string




-- 
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]


Reply via email to