virajjasani commented on code in PR #2308:
URL: https://github.com/apache/phoenix/pull/2308#discussion_r2471295512
##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -6909,6 +6911,29 @@ public void
invalidateServerMetadataCache(List<InvalidateServerMetadataCacheRequ
}
}
+ /*
+ Delete any metadata related to this table in the System tables for Streams.
+ */
+ @Override
+ public void deleteAllStreamMetadataForTable(java.sql.Connection conn, String
tableName)
Review Comment:
Let's remove `deleteAllStreamMetadataForTable()` from MetaDataClient?
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStreamIT.java:
##########
@@ -433,6 +434,34 @@ public void testStreamMetadataWhenTableIsDropped() throws
SQLException {
Assert.assertTrue(rs.next());
}
+ @Test
+ public void testStreamMetadataWhenCDCIsDropped() throws SQLException {
+ Connection conn = newConnection();
+ MetaDataClient mdc = new
MetaDataClient(conn.unwrap(PhoenixConnection.class));
+ String schemaName = "\"" + generateUniqueName().toLowerCase() + "\"";
+ String tableName =
+ SchemaUtil.getTableName(schemaName, "\"" +
generateUniqueName().toLowerCase() + "\"");
+ String unescapedFullTableName =
SchemaUtil.getUnEscapedFullName(tableName);
+ String create_table_sql =
+ "CREATE TABLE " + tableName + " ( k INTEGER PRIMARY KEY," + "
v1 INTEGER, v2 DATE)";
+ conn.createStatement().execute(create_table_sql);
+ String cdcName = "\"" + generateUniqueName().toLowerCase() + "\"";
+ String cdc_sql = "CREATE CDC " + cdcName + " ON " + tableName;
+ conn.createStatement().execute(cdc_sql);
+ TaskRegionObserver.SelfHealingTask task = new
TaskRegionObserver.SelfHealingTask(
+ taskRegionEnvironment,
QueryServicesOptions.DEFAULT_TASK_HANDLING_MAX_INTERVAL_MS);
+ task.run();
+ String drop_cdc_sql = "DROP CDC " + cdcName + " ON " + tableName;
Review Comment:
nit: from Java variable convention, we can use `dropCdcSql` but it's fine
for now, we can do this cleanup later also
##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java:
##########
@@ -4063,10 +4063,11 @@ public MutationState dropCDC(DropCDCStatement
statement) throws SQLException {
String parentTableName = statement.getTableName().getTableName();
String indexName =
CDCUtil.getCDCIndexName(statement.getCdcObjName().getName());
// Mark CDC Stream as Disabled
- long cdcIndexTimestamp = connection.getTable(indexName).getTimeStamp();
- String streamName = String.format(CDC_STREAM_NAME_FORMAT, parentTableName,
cdcTableName,
+ long cdcIndexTimestamp =
connection.getTable(SchemaUtil.getTableName(schemaName,
indexName)).getTimeStamp();
Review Comment:
looks like we need `mvn spotless:apply` overall
--
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]