sanjeet006py commented on code in PR #1751:
URL: https://github.com/apache/phoenix/pull/1751#discussion_r1420286340
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java:
##########
@@ -1795,4 +1795,45 @@ public void
testChangePropertiesUpdatesLASTDDLTimestamp() throws Exception {
newLastDDLTimestamp > oldLastDDLTimestamp);
}
}
-}
\ No newline at end of file
+
+ @Test
+ public void testChangeTableLevelMaxLookbackAge() throws Exception {
+ String schemaName = generateUniqueName();
+ String dataTableName = generateUniqueName();
+ String fullTableName = SchemaUtil.getTableName(schemaName,
dataTableName);
+ long baseMaxLookbackAge = 86400000; // 1 day
+ long maxLookbackAge = baseMaxLookbackAge;
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ String ddl = "CREATE TABLE " + fullTableName +
+ " (a_string varchar not null, a_binary VARCHAR not null,
col1 integer" +
+ " CONSTRAINT pk PRIMARY KEY (a_string, a_binary)) " +
"MAX_LOOKBACK_AGE=" + maxLookbackAge;
+ conn.createStatement().execute(ddl);
+ assertMaxLookbackAge(schemaName, dataTableName, maxLookbackAge);
+ maxLookbackAge = 3L * baseMaxLookbackAge;
+ ddl = "ALTER TABLE " + fullTableName + " SET MAX_LOOKBACK_AGE = "
+ maxLookbackAge;
+ conn.createStatement().execute(ddl);
+ assertMaxLookbackAge(schemaName, dataTableName, maxLookbackAge);
+ maxLookbackAge = 2L * baseMaxLookbackAge;
+ ddl = "ALTER TABLE " + fullTableName + " SET MAX_LOOKBACK_AGE = "
+ maxLookbackAge;
+ conn.createStatement().execute(ddl);
+ assertMaxLookbackAge(schemaName, dataTableName, maxLookbackAge);
+ maxLookbackAge = 0;
+ ddl = "ALTER TABLE " + fullTableName + " SET MAX_LOOKBACK_AGE = "
+ maxLookbackAge;
+ conn.createStatement().execute(ddl);
+ assertMaxLookbackAge(schemaName, dataTableName, maxLookbackAge);
+ }
+ }
+
+ private void assertMaxLookbackAge(String schemaName, String dataTableName,
long expectedMaxLookbackAge) throws Exception {
+ String query = "SELECT MAX_LOOKBACK_AGE FROM \"SYSTEM\".\"CATALOG\"\n"
+ + "WHERE TENANT_ID IS NULL AND\n"
+ + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+
dataTableName + "') AND\n"
+ + "COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL";
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ ResultSet rs = conn.createStatement().executeQuery(query);
+ assertTrue(rs.next());
+ assertEquals(expectedMaxLookbackAge, rs.getLong(1));
Review Comment:
I have updated an existing testcase to check if max lookback age is set to 0
when not specified as table property in here:
https://github.com/sanjeet006py/phoenix/blob/PHOENIX-7006/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java#L1284.
> Also add assertions in some old tests or new one where value is null in
SYSCAT.
As the mini-cluster is spin up using the same code base with my changes so
not completely sure how to test a scenario of tables already existing with null
in SYSCAT. Can you please give some pointers. Thanks
--
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]