haridsv commented on code in PR #2196: URL: https://github.com/apache/phoenix/pull/2196#discussion_r2156081633
########## phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java: ########## @@ -3333,6 +3333,11 @@ private MetaDataMutationResult doDropTable(byte[] key, byte[] tenantId, byte[] s // Recursively delete indexes for (byte[] indexName : indexNames) { + if (CDCUtil.isCDCIndex(indexName)) { + byte[] cdcKey = SchemaUtil.getTableKey(tenantId, schemaName, CDCUtil.getCdcObjectName(indexName)); + Delete deleteCdc = new Delete(cdcKey, clientTimeStamp); + catalogMutations.add(deleteCdc); + } Review Comment: I think in the order of delete, it should be CDC index first and then the CDC object, basically following the same philosophy of deleting the indexes before the table. ########## phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCDefinitionIT.java: ########## @@ -145,10 +145,21 @@ public void testCreateCaseSensitiveTable() throws Exception { String cdc_sql = "CREATE CDC " + cdcName + " ON " + tableName; conn.createStatement().execute(cdc_sql); conn.createStatement().executeQuery("SELECT * FROM " + cdcName); + + String drop_sql = forView ? "DROP VIEW " + tableName : "DROP TABLE " + tableName; Review Comment: So, CASCADE option is not required? ########## phoenix-core-client/src/main/java/org/apache/phoenix/util/CDCUtil.java: ########## @@ -99,6 +99,19 @@ public static boolean isCDCIndex(String indexName) { return indexName.startsWith(CDC_INDEX_PREFIX); } + public static boolean isCDCIndex(byte[] indexNameBytes) { + String indexName = Bytes.toString(indexNameBytes); + return indexName.startsWith(CDC_INDEX_PREFIX); Review Comment: You can call the `isCDCIndex(String)` variant here. ########## phoenix-core-client/src/main/java/org/apache/phoenix/util/CDCUtil.java: ########## @@ -99,6 +99,19 @@ public static boolean isCDCIndex(String indexName) { return indexName.startsWith(CDC_INDEX_PREFIX); } + public static boolean isCDCIndex(byte[] indexNameBytes) { + String indexName = Bytes.toString(indexNameBytes); + return indexName.startsWith(CDC_INDEX_PREFIX); + } + + public static byte[] getCdcObjectName(byte[] cdcIndexName) { + byte[] result = new byte[cdcIndexName.length - CDC_INDEX_PREFIX.length()]; + for (int i = 0; i < cdcIndexName.length - CDC_INDEX_PREFIX.length(); i++) { + result[i] = cdcIndexName[i + CDC_INDEX_PREFIX.length()]; + } Review Comment: You can use one of the existing byte copy methods such as `Arrays.copyOfRange`. -- 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: issues-unsubscr...@phoenix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org