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] [Updated] (PHOENIX-4612) Index immutability doesn't change when data table immutable changes
Date Thu, 15 Feb 2018 20:44:00 GMT

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

James Taylor updated PHOENIX-4612:
----------------------------------
    Description: 
The immutability of an index should change when the data table immutable changes. Probably
best to not allow table immutability to change as part of PHOENIX-1160.

Here's a test that currently fails:
{code}
    private static void assertImmutability(Connection conn, String tableName, boolean expectedImmutableRows)
throws Exception {
        ResultSet rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ v FROM
" + tableName);
        rs.next();
        PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTableRef(new
PTableKey(null, tableName)).getTable();
        assertEquals(expectedImmutableRows, table.isImmutableRows());
        PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
        rs = stmt.executeQuery("SELECT v FROM " + tableName);
        rs.next();
        assertTrue(stmt.getQueryPlan().getTableRef().getTable().getType() == PTableType.INDEX);
        table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTableRef(new PTableKey(null,
tableName)).getTable();
        assertEquals(expectedImmutableRows, table.isImmutableRows());
        for (PTable index : table.getIndexes()) {
            assertEquals(expectedImmutableRows, index.isImmutableRows());
        }
    }
    
    @Test
    public void testIndexImmutabilityChangesWithTable() throws Exception {
        Connection conn = DriverManager.getConnection(getUrl());
        String tableName = generateUniqueName();
        String indexName = generateUniqueName();
        conn.createStatement().execute("CREATE IMMUTABLE TABLE " + tableName + "(k VARCHAR
PRIMARY KEY, v VARCHAR) COLUMN_ENCODED_BYTES=NONE, IMMUTABLE_STORAGE_SCHEME = ONE_CELL_PER_COLUMN");
        conn.createStatement().execute("CREATE INDEX " + indexName + " ON " + tableName +
"(v)");
        assertImmutability(conn, tableName, true);
        conn.createStatement().execute("ALTER TABLE " + tableName + " SET IMMUTABLE_ROWS=false");
        assertImmutability(conn, tableName, false);
    }
{code}

  was:See QueryDatabaseMetaDataIT.testIndexImmutabilityChangesWithTable() which currently
fails. Probably best to not allow table immutability to change as part of PHOENIX-1160.


> Index immutability doesn't change when data table immutable changes
> -------------------------------------------------------------------
>
>                 Key: PHOENIX-4612
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4612
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Priority: Major
>
> The immutability of an index should change when the data table immutable changes. Probably
best to not allow table immutability to change as part of PHOENIX-1160.
> Here's a test that currently fails:
> {code}
>     private static void assertImmutability(Connection conn, String tableName, boolean
expectedImmutableRows) throws Exception {
>         ResultSet rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ v
FROM " + tableName);
>         rs.next();
>         PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTableRef(new
PTableKey(null, tableName)).getTable();
>         assertEquals(expectedImmutableRows, table.isImmutableRows());
>         PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
>         rs = stmt.executeQuery("SELECT v FROM " + tableName);
>         rs.next();
>         assertTrue(stmt.getQueryPlan().getTableRef().getTable().getType() == PTableType.INDEX);
>         table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTableRef(new
PTableKey(null, tableName)).getTable();
>         assertEquals(expectedImmutableRows, table.isImmutableRows());
>         for (PTable index : table.getIndexes()) {
>             assertEquals(expectedImmutableRows, index.isImmutableRows());
>         }
>     }
>     
>     @Test
>     public void testIndexImmutabilityChangesWithTable() throws Exception {
>         Connection conn = DriverManager.getConnection(getUrl());
>         String tableName = generateUniqueName();
>         String indexName = generateUniqueName();
>         conn.createStatement().execute("CREATE IMMUTABLE TABLE " + tableName + "(k VARCHAR
PRIMARY KEY, v VARCHAR) COLUMN_ENCODED_BYTES=NONE, IMMUTABLE_STORAGE_SCHEME = ONE_CELL_PER_COLUMN");
>         conn.createStatement().execute("CREATE INDEX " + indexName + " ON " + tableName
+ "(v)");
>         assertImmutability(conn, tableName, true);
>         conn.createStatement().execute("ALTER TABLE " + tableName + " SET IMMUTABLE_ROWS=false");
>         assertImmutability(conn, tableName, false);
>     }
> {code}



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

Mime
View raw message