[ https://issues.apache.org/jira/browse/PHOENIX-3475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15655659#comment-15655659 ]
James Taylor commented on PHOENIX-3475: --------------------------------------- What metadata do you mean, [~akshita.malhotra]? If you want the The Phoenix metadata for each index of a view is potentially different. That can be retrieved via the DatabaseMetaData#getTables and DatabaseMetaData#getIndexInfo calls based on the index or view name. Here's an example, augmenting an existing unit test in ViewIndexIT: {code} @Test public void testCreatingIndexOnGlobalView() throws Exception { String baseTable = generateUniqueName(); String globalView = generateUniqueName(); String globalViewIdx = generateUniqueName(); try (Connection conn = DriverManager.getConnection(getUrl())) { conn.createStatement().execute("CREATE TABLE " + baseTable + " (TENANT_ID CHAR(15) NOT NULL, PK2 DATE NOT NULL, PK3 INTEGER NOT NULL, KV1 VARCHAR, KV2 VARCHAR, KV3 CHAR(15) CONSTRAINT PK PRIMARY KEY(TENANT_ID, PK2 ROW_TIMESTAMP, PK3)) MULTI_TENANT=true"); conn.createStatement().execute("CREATE VIEW " + globalView + " AS SELECT * FROM " + baseTable); conn.createStatement().execute("CREATE INDEX " + globalViewIdx + " ON " + globalView + " (PK3 DESC, KV3) INCLUDE (KV1)"); ResultSet rs = conn.getMetaData().getTables("", "", globalViewIdx, new String[] {"INDEX"}); assertTrue(rs.next()); rs = conn.getMetaData().getIndexInfo("", "", globalView, false, false); assertTrue(rs.next()); {code} If you mean HBase metadata, then Phoenix doesn't store that, HBase does. For that you could use the physical table name (retrieved as mentioned above), and do an HBaseAdmin call to retrieve the HTableDescriptor. Hopefully the migration tool isn't trying to create HTables on its own, but uses Phoenix DDL. If that's the case, then the underlying HBase physical table for the indexes on views will be created when the multi-tenant table or index on view is created. > MetaData #getTables() API doesn't return view indexes > ----------------------------------------------------- > > Key: PHOENIX-3475 > URL: https://issues.apache.org/jira/browse/PHOENIX-3475 > Project: Phoenix > Issue Type: Bug > Reporter: Akshita Malhotra > Fix For: 4.9.0 > > > HBase migration tool uses DatabaseMetadata#getTables() API to retrieve the > tables for copying data. We have found that API doesn't return base index > tables ( _IDX_<base table name>) > For testing purposes, we issue following DDL to generate the view and the > corresponding view index: > -CREATE VIEW IF NOT EXISTS MIGRATIONTEST_VIEW (OLD_VALUE_VIEW varchar) AS > SELECT * FROM MIGRATIONTEST WHERE OLD_VALUE like 'E%' > -CREATE INDEX IF NOT EXISTS MIGRATIONTEST_VIEW_IDX ON MIGRATIONTEST_VIEW > (OLD_VALUE_VIEW) > By using HBase API, we were able to confirm that base index table > (_IDX_MIGRATIONTEST) is created. > Both jdbc DatabaseMetadata API and P* getMetaDataCache API doesn't seem to > be returning view indexes. Also P*MetaData #getTableRef API return > "TableNotFoundException" when attempted to fetch PTable corresponding to the > base index table name. -- This message was sent by Atlassian JIRA (v6.3.4#6332)