[
https://issues.apache.org/jira/browse/PHOENIX-5434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Swaroopa Kadam updated PHOENIX-5434:
------------------------------------
Fix Version/s: (was: 4.14.3)
(was: 4.15.0)
> IndexTool rebuild doesn't work if # of rows in base table/view > index table
> ----------------------------------------------------------------------------
>
> Key: PHOENIX-5434
> URL: https://issues.apache.org/jira/browse/PHOENIX-5434
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 5.0.0, 4.14.2
> Reporter: Swaroopa Kadam
> Assignee: Swaroopa Kadam
> Priority: Blocker
>
> {code:java}
> @Test
> public void testIndexRebuildWithNoIndexRows() throws Throwable {
> String baseTable = generateUniqueName();
> String viewName = generateUniqueName();
> Connection conn = null;
> try {
> conn = DriverManager.getConnection(getUrl());
> conn.setAutoCommit(true);
> String ddlFormat =
> "CREATE TABLE IF NOT EXISTS " + baseTable + " ("
> + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR "
> + " CONSTRAINT NAME_PK PRIMARY KEY (PK2) )";
> conn.createStatement().execute(ddlFormat);
> // Create a view
> String viewDDL = "CREATE VIEW " + viewName + " AS SELECT * FROM " +
> baseTable;
> conn.createStatement().execute(viewDDL);
> // Create index
> String indexName = generateUniqueName();
> String idxSDDL = String.format("CREATE INDEX %s ON %s (V1)",
> indexName, viewName);
> conn.createStatement().execute(idxSDDL);
> // Insert rows
> int numOfValues = 1000;
> for (int i=0; i < numOfValues; i++){
> conn.createStatement().execute(
> String.format("UPSERT INTO %s VALUES('%s', '%s', '%s')",
> viewName, String.valueOf(i), "y",
> "z"));
> }
> for (int i=numOfValues; i < numOfValues*2; i++){
> conn.createStatement().execute(
> String.format("UPSERT INTO %s VALUES('%s', '%s', '%s')",
> viewName, String.valueOf(i), "x",
> "y"));
> }
> conn.createStatement().execute("DELETE FROM "+indexName+" WHERE
> \"0:V1\" = 'x'");
> String viewIndexTableName =
> MetaDataUtil.getViewIndexPhysicalName(baseTable);
> ConnectionQueryServices queryServices =
> conn.unwrap(PhoenixConnection.class).getQueryServices();
> int count =
> getUtility().countRows(queryServices.getTable(Bytes.toBytes(viewIndexTableName)));
> assertTrue(count == numOfValues);
> count =
> getUtility().countRows(queryServices.getTable(Bytes.toBytes(baseTable)));
> assertTrue(count == 2*numOfValues);
> IndexToolIT.runIndexTool(true, false, "", viewName, indexName);
> // See that index is rebuilt and confirm index has rows
> Table htable=
> queryServices.getTable(Bytes.toBytes(viewIndexTableName));
> count = getUtility().countRows(htable);
> assertEquals(numOfValues*2, count); //fails here
> } finally {
> if (conn != null) {
> conn.commit();
> conn.close();
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)