suryaprasanna commented on code in PR #17940:
URL: https://github.com/apache/hudi/pull/17940#discussion_r2784742517


##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/MetadataCommand.java:
##########
@@ -387,6 +392,58 @@ public String validateFiles(
     return HoodiePrintHelper.print(header, new HashMap<>(), "", false, 
Integer.MAX_VALUE, false, rows);
   }
 
+  @ShellMethod(key = "metadata lookup-record-index", value = "Print Record 
index information for a record_key. "
+      + "For global RLI, only record key is required. For partitioned RLI, 
both record key and partition path are required.")
+  public String getRecordIndexInfo(
+      @ShellOption(value = "--record_key", help = "Record key entry whose info 
will be fetched")
+      final String recordKey,
+      @ShellOption(value = "--partition_path", help = "Partition path. 
Required for partitioned (non-global) Record Level Index.",
+          defaultValue = "") final String partitionPath) {
+    HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient();
+    HoodieStorage storage = metaClient.getStorage();
+    HoodieMetadataConfig config = 
HoodieMetadataConfig.newBuilder().enable(true).build();
+    HoodieBackedTableMetadata metaReader = new HoodieBackedTableMetadata(
+        new HoodieLocalEngineContext(HoodieCLI.conf), storage, config, 
HoodieCLI.basePath);
+
+    ValidationUtils.checkState(metaReader.enabled(), "[ERROR] Metadata Table 
not enabled/initialized\n\n");
+    
ValidationUtils.checkState(metaClient.getTableConfig().isMetadataPartitionAvailable(MetadataPartitionType.RECORD_INDEX),
+        "[ERROR] Record index partition is not enabled/initialized\n\n");
+
+    // Check if RLI is partitioned and validate partition_path is provided
+    if (config.isRecordLevelIndexEnabled() && 
!config.isGlobalRecordLevelIndexEnabled()) {
+      ValidationUtils.checkState(!StringUtils.isNullOrEmpty(partitionPath),
+          "[ERROR] Partitioned Record Level Index requires --partition_path to 
be provided\n\n");
+    }
+
+    Option<String> dataTablePartition = 
StringUtils.isNullOrEmpty(partitionPath) ? Option.empty() : 
Option.of(partitionPath);

Review Comment:
   Here partitionPath can be empty string. So, making it nullable wont handle 
the condition.



##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/MetadataCommand.java:
##########
@@ -387,6 +392,58 @@ public String validateFiles(
     return HoodiePrintHelper.print(header, new HashMap<>(), "", false, 
Integer.MAX_VALUE, false, rows);
   }
 
+  @ShellMethod(key = "metadata lookup-record-index", value = "Print Record 
index information for a record_key. "
+      + "For global RLI, only record key is required. For partitioned RLI, 
both record key and partition path are required.")
+  public String getRecordIndexInfo(
+      @ShellOption(value = "--record_key", help = "Record key entry whose info 
will be fetched")
+      final String recordKey,
+      @ShellOption(value = "--partition_path", help = "Partition path. 
Required for partitioned (non-global) Record Level Index.",
+          defaultValue = "") final String partitionPath) {
+    HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient();
+    HoodieStorage storage = metaClient.getStorage();
+    HoodieMetadataConfig config = 
HoodieMetadataConfig.newBuilder().enable(true).build();
+    HoodieBackedTableMetadata metaReader = new HoodieBackedTableMetadata(
+        new HoodieLocalEngineContext(HoodieCLI.conf), storage, config, 
HoodieCLI.basePath);
+
+    ValidationUtils.checkState(metaReader.enabled(), "[ERROR] Metadata Table 
not enabled/initialized\n\n");
+    
ValidationUtils.checkState(metaClient.getTableConfig().isMetadataPartitionAvailable(MetadataPartitionType.RECORD_INDEX),
+        "[ERROR] Record index partition is not enabled/initialized\n\n");
+
+    // Check if RLI is partitioned and validate partition_path is provided
+    if (config.isRecordLevelIndexEnabled() && 
!config.isGlobalRecordLevelIndexEnabled()) {

Review Comment:
   Yes, I am thinking of using indexMetadata to find out if the RLI is 
partitioned. I think if we can write that information we should be able to test 
it.



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