palashc commented on code in PR #1702:
URL: https://github.com/apache/phoenix/pull/1702#discussion_r1355860010
##########
phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java:
##########
@@ -420,6 +423,126 @@ public void
testInvalidateCacheForBaseTableWithUpdateIndexStatement() throws Exc
}
+ /**
+ * Test that we invalidate the cache for parent table and update the last
ddl timestamp
+ * of the parent table while we add an index.
+ * Test that we invalidate the cache for parent table and index when we
drop an index.
+ * Also we update the last ddl timestamp for parent table when we drop an
index.
+ * @throws Exception
+ */
+ @Test
+ public void testUpdateLastDDLTimestampTableAfterIndexCreation() throws
Exception {
+ String tableName = generateUniqueName();
+ byte[] tableNameBytes = Bytes.toBytes(tableName);
+ String indexName = generateUniqueName();
+ byte[] indexNameBytes = Bytes.toBytes(indexName);
+ ServerMetadataCache cache = ServerMetadataCache.getInstance(config);
+ String ddl =
+ "create table " + tableName + " ( k integer PRIMARY KEY," + "
v1 integer,"
+ + " v2 integer)";
+ String createIndexDDL = "create index " + indexName + " on " +
tableName + " (v1)";
+ String dropIndexDDL = "DROP INDEX " + indexName + " ON " + tableName;
+ try (Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = conn.createStatement()) {
+ conn.setAutoCommit(true);
+ stmt.execute(ddl);
+ long tableLastDDLTimestampBeforeIndexCreation =
getLastDDLTimestamp(tableName);
+ // Populate the cache
+ assertNotNull(cache.getLastDDLTimestampForTable(null, null,
tableNameBytes));
+ Thread.sleep(1);
Review Comment:
Got it. Will be nice to add a comment mentioning this.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]