Repository navigation
[VL] Preserve Java exceptions through native iterators - #13561
zhztheplayer merged 11 commits into
Conversation
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
d2d3b37 to
9b3f41e
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
9b3f41e to
895992a
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
…Exec Plan GlutenDeltaInvariantCheckerExec where Delta plans its row-based DeltaInvariantCheckerExec, instead of wrapping the Velox writer's task iterator. The writer no longer takes a checker. When native code pulls the node's batches (the writer's sort on partitioned writes, the optimized-write shuffle), it keeps only the violation's text. The transaction then finds that text in the failure and rethrows Delta's DeltaInvariantViolationException, until apache#13561 keeps Java exceptions across native code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
) * [GLUTEN-10215][VL] Delta write: Offload top-level NOT NULL checks * [GLUTEN-10215][VL] Address review of native NOT NULL checks - Find nulls by decoding each constrained column and counting its nulls a word at a time, instead of trusting the cached null count: it can be stale, and on a dictionary or constant wrapping it misses the nulls of the wrapped values. The scan moves into VeloxColumnarBatch::firstNullColumnIndex, with unit tests. - Fail the write if a native invariant checker reaches the WriteFilesExec branch of GlutenDeltaFileFormatWriter, which cannot apply it. - Keep the checker's column ordinals and constraints in parallel arrays. - Move GlutenDeltaInvariantChecker into the shared src-delta tree, so that every Delta version enforces the constraints the same way. - Undo the reindentation of the spotless:off src-delta4 writer. - Test the checker without a native library, and NOT NULL violations in data read from Parquet and with optimized writes. * [GLUTEN-10215][VL] Test partitioned NOT NULL violations and update the Delta docs A partitioned native write sorts the rows natively before writing them. The native NOT NULL check runs after that sort, on the JVM, so violations keep Delta's DeltaInvariantViolationException instead of being wrapped in a GlutenException. Test it on Spark 3.5 and 4.x, including an empty string partition value that Delta turns into a null, and update VeloxDelta.md, which still described the row-based check for every NOT NULL write. * [GLUTEN-10215][VL] Choose the native NOT NULL checker in one shared place Both Delta transactions picked the checker with the same lines. Move them into GlutenDeltaInvariantChecker.forWrite, which also keeps Delta's row checker when spark.databricks.delta.constraints.convertEmptyToNullForStringPartitionCol is off and the table has a string partition column. Delta then checks the empty strings themselves, while the native checker would see the nulls the writer turns them into, and would fail writes that Delta accepts. * [GLUTEN-10215][VL] Trim the native NOT NULL tests Move the NOT NULL tests into the existing DeltaNativeWriteSuite of each Delta tree, which drops DeltaNativeWriteInvariantSuite and the helpers it copied. Each tree keeps three tests: - a native write with neither Delta's row checker nor C2R, and its violation, with and without optimized writes; - CHECK constraints keep DeltaInvariantCheckerExec; - violations on a partitioned table. Drop the Parquet-source test. VeloxColumnarBatchTest covers dictionary encodings directly, and the end-to-end test could not ensure them. Shorten the checker's doc comment, which repeated the PR description. * [GLUTEN-10215][VL] Check NOT NULL in a columnar DeltaInvariantCheckerExec Plan GlutenDeltaInvariantCheckerExec where Delta plans its row-based DeltaInvariantCheckerExec, instead of wrapping the Velox writer's task iterator. The writer no longer takes a checker. When native code pulls the node's batches (the writer's sort on partitioned writes, the optimized-write shuffle), it keeps only the violation's text. The transaction then finds that text in the failure and rethrows Delta's DeltaInvariantViolationException, until #13561 keeps Java exceptions across native code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [GLUTEN-10215][VL] Create the native NOT NULL checker in glutenPhysicalPlan glutenPhysicalPlan already gets the constraints, so it now creates the checker itself and its arguments are back to what they are on main. The unwrap moves into a catch around the native write. It takes the checker from the plan's GlutenDeltaInvariantCheckerExec and leaves failures that Delta's InnerInvariantViolationException already handles to Delta's catch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [GLUTEN-10215][VL] Make findViolation static findViolation no longer needs the checker's constraints. It finds the text of a NOT NULL violation in the failure, takes the column name from it and rebuilds Delta's exception with the constructor Delta uses. Both transactions call it directly, so the transaction no longer looks up the checker in the plan. NOT NULL violations from Delta's row checker whose text reaches the driver only inside a GlutenException now keep Delta's exception type too. CHECK violations still do not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Mohammad Linjawi <Mohammad.Linjawi@ibm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
895992a to
d17fa5f
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-library lifetime handling, thread propagation, and GPU callbacks at the shared JNI boundary require human native/JVM integration validation beyond the supplied runtime evidence, which does not cover GPU execution.
No open issues 🎉
4 resolved since last review
Onlynext()is wrapped withwrapJavaException, but iterator reads also commonly call… Asserting fullgetMessageequality in addition toerrorClass,messageParameters, and… Constructingfacebook::velox::VeloxExceptiondirectly with a long parameter list (including a…entries.erase(std::find(...))is undefined behavior ifunwrap_isn’t found (e.g., if destructor…
Review effort: Balanced
Split layer 2 of apache#13133, depending on apache#13560. Preserve the Java carrier through Velox input streams and lazy output loading, with focused native, real-JVM, and Delta constraint regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the bare Java throwable case and verify the exact direct cause. Also exercise an already-translated GlutenException and require the same wrapper object through nested iterators, matching the upstream no-rewrap policy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use the backend input factory for both initial and later splits, so CPU and cuDF streams can read generic iterators without interpreting Java failures. Exercise both split paths with the original Spark throwable. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use the standard Velox test source directory and backend guard. The shared test module no longer needs a separate source root or Scalastyle configuration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep native iterator reads native. Only the JNI hasNext and next entry points ask the backend to recover a Java callback from a failed read; other errors follow the existing JNI fallback. Cover lazy loading from a native caller and from both Java-facing reads. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Let the shared JNI return boundary restore a captured throwable or apply the native fallback. Velox returns the carrier from a failed output read instead of rethrowing it into a second catch; unrelated JNI calls keep their existing handling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore AGENTS.md to the iterator PR base. The test-placement guidance is tracked separately in apache#13727. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Let the ordinary JNI return handler follow backend-specific and standard nested causes without a runtime. Scope each registered callback to its lifetime, preserve the native fallback, and verify that a Delta NOT NULL violation reconstructed from text cannot pass the regression. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Log a missing registration instead of passing the end iterator to erase. Normal scoped unregistration is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1f3230b to
df3e57e
Compare
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-DSO throwable ownership and backend callback lifetimes require human review and native/JVM runtime validation, especially for the explicitly unverified GPU path and library teardown safety.
No open issues 🎉
Review effort: Balanced
zhztheplayer
left a comment
There was a problem hiding this comment.
Thanks for iterating, only a nit left.
Put the library-lifetime registration in a backend-local helper, so the init sequence uses a register call without changing when the callback is installed or removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Run Gluten Clickhouse CI on x86 |
|
@zhztheplayer the failing CI is a transient issue I opened this PR to address it: #13797 |


What changes are proposed in this pull request?
Preserve the original Java throwable when Velox reads a Java-backed iterator. The JNI input adapter wraps the failure before the driver can reduce it to text. Velox registers how to extract its native cause; ordinary
JNI_METHOD_ENDfollows it without a runtime or special iterator catch. Native callers keep their native exception.Uses the JNI carrier from #13560. Combined reference: #13133.
How was this patch tested?
On the rebased revision, all 8 JNI iterator and 6 native Delta constraint cases passed on Spark 4.1 with JDK 17 and
-Xcheck:jni. Native sources, dependency pins, and binary hashes were unchanged by the rebase.Before the rebase, all 21 native tests passed after the cleanup guard was added. A separate check forced a missing registration and verified that the remaining callback was unaffected. Earlier checks included 14 core JNI JUnit tests, 20 Spark tests on each of 3.5 and 4.1, and throwable restoration across
libgluten.soandlibvelox.so. Disabling input wrapping made the partitioned NOT NULL regression fail specifically on Delta’s text-based reconstruction. GPU execution was not tested locally.Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot 1.0.106-8.unstable.r43566476370.g869eef3 (GPT-6.2 Astra, gpt-6.2-astra)