[WIP] PHOENIX-7278 Add support to dump BAD_ROWS in a directory for CsvBulkL…
…oadTool
What changes were proposed in this pull request?
Added a --bad-records-path (-B) CLI option to CsvBulkLoadTool / JsonBulkLoadTool that writes rejected/malformed records to an HDFS directory during bulk import. When a record fails parsing (e.g., unterminated CSV quote) or fails upsert (e.g., type mismatch), the offending record and its error message are written to a per-task-attempt file (
Why are the changes needed?
Previously, when --ignore-errors was used, bad records were silently skipped with only a counter increment. Operators had no way to identify which records failed or why, making it difficult to fix source data and re-import. This change provides an audit trail of rejected records for post-job analysis and data remediation.
Does this PR introduce any user-facing change?
Yes. A new CLI option --bad-records-path / -B is available for CsvBulkLoadTool and JsonBulkLoadTool. When specified, rejected records are written to the given HDFS path. Using this option implicitly enables --ignore-errors.
How was this patch tested?
Unit tests in BadRecordsWriterTest covering MapperUpsertListener error handling, BadRecordWriter interface, null writer safety, counter increments, error propagation behavior, and multi-error scenarios (10 tests, all passing). Existing BulkLoadToolTest.testParseOptions_BadRecordsPath verifies option parsing.
Was this patch authored or co-authored using generative AI tooling?
Yes using claude code