sunchao opened a new pull request, #7788:
URL: https://github.com/apache/datafusion-comet/pull/7788
## Which issue does this PR close?
Closes #7213.
Closes #4316.
## Rationale for this change
When the native Parquet scan fails on a file, Spark's error should name that
file. Today it often doesn't:
- **Read failures (#7213).** A corrupt footer or page reaches the JNI
boundary as a plain `ParquetError`. It is classified as `CannotReadFile` there,
after the file's identity is gone, so the path is empty. The JVM then fills it
with every file of the task, joined by commas. For a task reading
`healthy.parquet` and `corrupt.parquet`, the error names both.
- **Schema conversion (#4316).** `ParquetSchemaConvert` is raised by the
schema adapter, which has no file identity, so the message reads `Encountered
error while reading file .` with an empty path.
`ParquetErrorContext` already keeps each file's original Spark path beside
that file's planners and streams. It only used the path for
`ParquetTimestampOverflow`, and it was only installed when checked timestamp
conversion was on.
## What changes are included in this PR?
- `with_scan_file_path` in `jni-bridge/src/errors.rs` names a file in an
error raised while scanning it:
- A bare `ParquetSchemaConvert`, `ParquetMissingFieldIds` or
`CannotReadFile` without a path gets the file's path. A path the error already
carries is kept.
- `ParquetTimestampOverflow` always takes the scan's original Spark path,
as before.
- An unclassified read failure is classified with the same
`try_classify_file_read_error` used at the JNI boundary, so only its path
changes. Missing files, predicate failures inside the reader
(`ParquetError::External(ArrowError)`), other Spark errors, and errors with
query context surface unchanged.
- `ParquetErrorContext` applies it to a file's planning errors (where footer
reads fail), its pending planners, and its stream.
- Every native Parquet scan installs `ParquetErrorContext`, not only those
with checked timestamp conversion. The dynamic-filter code that rebuilds
sources already looks through the wrapper and re-wraps.
- The JVM's per-task file list fallback in `SparkErrorConverter` stays as a
safety net for read failures raised outside a per-file scan. Its comment is
updated.
## How are these changes tested?
- `ParquetReadSuite`:
- "native scan read failure names only the corrupt file of a multi-file
task": a healthy, larger file and a corrupt one in the same task. The
`FAILED_READ_FILE` error's `path` must be the corrupt file. On main it is
`healthy.parquet,corrupt.parquet`.
- "native scan schema conversion error names the file that cannot be
converted": an INT file and a STRING file read as `a int` in one task. The
error must name the STRING file and not the other. On main it reads
`Encountered error while reading file .`.
- Both fail against main's native library and pass with this change (Spark
4.1).
- Rust unit tests:
- `file_error_context.rs`: a corrupt footer during planning and a corrupt
page during streaming both become `CannotReadFile` naming the file; a schema
conversion names its file.
- `errors.rs`: paths fill only where missing, timestamp overflow takes the
scan's path, and non-file errors are untouched.
- Two dynamic-filter join tests downcast the scan straight to
`ParquetSource`. They now use `concrete_parquet_source`, which looks through
the wrapper.
- Ran locally on Linux (WSL), Spark 4.1 and 3.5 profiles:
- `cargo fmt` and `cargo clippy --all-targets -D warnings` on the touched
crates.
- The `datafusion-comet` tests matching `parquet` and `dynamic_filter`
(460 passed).
- The `jni-bridge` lib tests. Four JVM-backed panic tests fail the same
way on unmodified main without the JVM test classes on the classpath.
- `ParquetReadV1Suite` ("native scan" and "TIMESTAMP_MILLIS" tests),
`CometExecSuite` "native parquet read" tests, and `SparkErrorConverterSuite`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]