yihua commented on code in PR #11951:
URL: https://github.com/apache/hudi/pull/11951#discussion_r1772377686


##########
hudi-spark-datasource/hudi-spark-common/src/main/java/org/apache/hudi/HoodieSparkIndexClient.java:
##########
@@ -112,6 +112,24 @@ public void create(HoodieTableMetaClient metaClient, 
String indexName, String in
     }
   }
 
+  @Override
+  public void drop(HoodieTableMetaClient metaClient, String indexName, boolean 
ignoreIfNotExists) {
+    if (!indexExists(metaClient, indexName)) {
+      if (ignoreIfNotExists) {
+        return;
+      } else {
+        throw new HoodieFunctionalIndexException("Index does not exist: " + 
indexName);
+      }
+    }
+
+    LOG.info("Dropping index {}", indexName);
+    HoodieIndexDefinition indexDefinition = 
metaClient.getIndexMetadata().get().getIndexDefinitions().get(indexName);
+    try (SparkRDDWriteClient writeClient = 
HoodieCLIUtils.createHoodieWriteClient(
+        sparkSession, metaClient.getBasePath().toString(), 
mapAsScalaImmutableMap(buildWriteConfig(metaClient, indexDefinition)), 
toScalaOption(Option.empty()))) {
+      writeClient.dropIndex(Collections.singletonList(indexName));

Review Comment:
   There is `BaseHoodieWriteClient` to abstract the write logic.  
Engine-specific implementation only needs to instantiate the engine-specific 
write client. The index client should only care about calling APIs in 
`BaseHoodieWriteClient`, which is the case here (need to generalize 
`HoodieCLIUtils.createHoodieWriteClient` too).



-- 
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]

Reply via email to