voonhous opened a new issue, #19878:
URL: https://github.com/apache/hudi/issues/19878

   ### Bug Description
   
   **What happened:**
   `metadata delete-record-index` throws a bare `NullPointerException` when it 
is the first metadata command run in a hudi-cli session. 
`MetadataCommand.deleteRecordIndex` (master 6ac27904, 
`MetadataCommand.java:154-156`) builds `new HoodieSparkEngineContext(jsc)` 
without calling `initJavaSparkContext(...)` first, unlike `metadata create` 
(line 136), `metadata init` (line 181) and `metadata list-partitions` (line 
219). The command only works if another metadata command initialised the shared 
`jsc` field earlier in the same session.
   
   **What you expected:**
   The command initialises its own Spark context like the sibling commands and 
deletes the record index.
   
   **Steps to reproduce:**
   1. `connect --path <table with record index>`
   2. `metadata delete-record-index`
   3. NPE from `HoodieSparkEngineContext` construction. Run `metadata 
list-partitions` first and step 2 succeeds.
   
   Found while writing the tests in #19877; the command is left untested there 
rather than pinning the ordering dependency. Fix is a one-liner: call 
`initJavaSparkContext(Option.of(master))` (adding the `--sparkMaster` option 
the other commands take) before constructing the engine context.
   
   ### Environment
   
   **Hudi version:** master (6ac27904), also present in 1.0.x
   **Query engine:** hudi-cli (Spark)
   **Relevant configs:** none
   
   ### Logs and Stack Trace
   
   ```
   java.lang.NullPointerException
     at 
org.apache.hudi.client.common.HoodieSparkEngineContext.<init>(HoodieSparkEngineContext.java)
     at 
org.apache.hudi.cli.commands.MetadataCommand.deleteRecordIndex(MetadataCommand.java:156)
   ```
   


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