phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Swaroopa Kadam (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (PHOENIX-5429) IndexTool doesn't rebuild indexes from data table after truncating the index table
Date Wed, 07 Aug 2019 20:13:00 GMT

     [ https://issues.apache.org/jira/browse/PHOENIX-5429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Swaroopa Kadam resolved PHOENIX-5429.
-------------------------------------
    Resolution: Not A Bug

> IndexTool doesn't rebuild indexes from data table after truncating the index table 
> -----------------------------------------------------------------------------------
>
>                 Key: PHOENIX-5429
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5429
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.14.2
>            Reporter: Swaroopa Kadam
>            Assignee: Gokcen Iskender
>            Priority: Blocker
>             Fix For: 4.15.0, 5.1.0, 4.14.3
>
>
> Following test fails. with AssertionError at the last assertion. 
> {code:java}
> @Test
> public void testIndexRebuildTask() throws Throwable {
>     String TENANT1 = "tenant1";
>     String baseTable = generateUniqueName();
>     String viewName = generateUniqueName();
>     Connection conn = null;
>     Connection viewConn = null;
>     try {
>         conn = DriverManager.getConnection(getUrl());
>         conn.setAutoCommit(false);
>         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
>         props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, TENANT1);
>         viewConn =DriverManager.getConnection(getUrl(), props);
>         String ddlFormat =
>                 "CREATE TABLE IF NOT EXISTS " + baseTable + "  ("
>                         + " %s PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR "
>                         + " CONSTRAINT NAME_PK PRIMARY KEY (%s PK2)" + " ) %s";
>         conn.createStatement().execute(generateDDL(ddlFormat));
>         conn.commit();
>         // Create a view
>         String viewDDL = "CREATE VIEW " + viewName + " AS SELECT * FROM " + baseTable;
>         viewConn.createStatement().execute(viewDDL);
>         // Create index
>         String indexName = generateUniqueName();
>         String idxSDDL = String.format("CREATE INDEX %s ON %s (V1)", indexName, viewName);
>         viewConn.createStatement().execute(idxSDDL);
>         // Insert rows
>         int numOfValues = 1000;
>         for (int i=0; i < numOfValues; i++){
>             viewConn.createStatement().execute(
>                     String.format("UPSERT INTO %s VALUES('%s', '%s', '%s')", viewName,
String.valueOf(i), "y",
>                             "z"));
>         }
>         viewConn.commit();
>         String viewIndexTableName = MetaDataUtil.getViewIndexPhysicalName(baseTable);
>         ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices();
>         int count = getUtility().countRows(queryServices.getTable(Bytes.toBytes(viewIndexTableName)));
>         assertTrue(count == numOfValues);
>         // Remove index contents and try again
>         Admin admin = queryServices.getAdmin();
>         TableName tableName = TableName.valueOf(viewIndexTableName);
>         admin.disableTable(tableName);
>         admin.truncateTable(tableName, true);
>         IndexToolIT.runIndexTool(true, false, "", viewName, indexName, TENANT1);
>         // See that index is rebuilt and confirm index has rows
>         Table htable= queryServices.getTable(Bytes.toBytes(viewIndexTableName));
>         count = getUtility().countRows(htable);
>         assertEquals(numOfValues, count);
>     } finally {
>         if (conn != null) {
>              conn.commit();
>             conn.close();
>         }
>         if (viewConn != null) {
>             viewConn.close();
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message