hudi-cli: metadata delete-record-index NPEs unless another metadata command ran first
- Dominant language
- Java
- Stars
- 6.2k
- Forks
- 2.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 111
Description
### 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 `
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.(HoodieSparkEngineContext.java)
at org.apache.hudi.cli.commands.MetadataCommand.deleteRecordIndex(MetadataCommand.java:156)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open MetadataCommand.java and compare deleteRecordIndex with the sibling metadata create, init, and list-partitions commands. Run the reproduction with delete-record-index as the first metadata command, then use the tests being written in issue #19877 to verify the command initializes its Spark context and deletes the record index without an ordering dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spark
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100