[VL][Delta] Add JVM Delta DV scan handoff#12131
Conversation
|
Run Gluten Clickhouse CI on x86 |
af4d0fb to
b0da63a
Compare
|
Run Gluten Clickhouse CI on x86 |
b0da63a to
b8f932c
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
| private lazy val deltaDeletionVectorRegistration | ||
| : DeltaScanTransformer.DeletionVectorRegistration = | ||
| DeltaScanTransformer.registerDeletionVectorsFromFileFormat(relation) |
There was a problem hiding this comment.
Can we follow the approach in the previous attempt #10740 to pass DVs to native? Would code be simpler that way?
There was a problem hiding this comment.
Thanks for pointing that out @zhztheplayer
I updated this in d06ec27 to follow the same split-time handoff shape from #10740 more closely.
The PR now removes the driver-side DeltaDeletionVectorRegistry and the relation-wide lazy DV registration from DeltaScanTransformer. DV payloads are materialized from each PartitionedFile's Delta metadata when building split info, then passed to native through the external split payload buffers added in this PR.
I kept the #12040-style external payload channel instead of embedding the serialized bitmap directly into Substrait like #10740 did, because #12040 introduced the native Delta split descriptor path that consumes payload buffers separately. This keeps the code simpler while avoiding large binary DV payloads in the Substrait plan.
|
Run Gluten Clickhouse CI on x86 |
d06ec27 to
c6f05f0
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
| import org.apache.spark.sql.delta.sources.DeltaSQLConf | ||
|
|
||
| /** Shadow Delta's PrepareDeltaScan to inject backend-specific DV preprocessing. */ | ||
| class PrepareDeltaScan(protected val spark: SparkSession) |
There was a problem hiding this comment.
Would you explain a bit what this rule is doing and why it's needed?
There was a problem hiding this comment.
Thanks @zhztheplayer. This is a Delta 3.3 compatibility shim around Delta's PrepareDeltaScan.
It keeps Delta's normal scan preparation first, including stats skipping, metadata-query optimization, and transaction read tracking. After that, Gluten runs DV preprocessing so the scan exposes Delta's internal DV metadata/row-deleted column.
Gluten needs that metadata to materialize the per-file DV payload for the native split. Later, once the native split has the payload, Gluten strips Spark's synthetic DV predicate/internal columns so Velox applies the DV filter natively and we do not filter twice.
I can expand the comment to make this flow clear.
| this(runtime, iterHandle, null); | ||
| } | ||
|
|
||
| public ColumnarBatchOutIterator(Runtime runtime, long iterHandle, Object retainedReference) { |
There was a problem hiding this comment.
What is retainedReference for?
There was a problem hiding this comment.
Yea that was unclear name so I renamed this to retainedSplitPayloadBuffers and typed it as ByteBuffer[][].
It keeps the Java-owned direct buffers reachable while Velox holds native views into them, so the payload memory cannot be GC’d during scan execution.
| /// Optional externally provided deletion vector payloads aligned with metadataColumns. | ||
| std::vector<std::optional<SplitPayloadBufferView>> deletionVectorPayloads; | ||
|
|
There was a problem hiding this comment.
Can we add DeltaSplitInfo : SplitInfo?
There was a problem hiding this comment.
Addressed. I added DeltaSplitInfo on the Velox side and moved the Delta DV split state there instead of keeping it on the generic split metadata path.
| metadataColumnMap[metadataColumn.key()] = metadataColumn.value(); | ||
| } | ||
| for (const auto& otherMetadataColumn : file.other_const_metadata_columns()) { | ||
| if (auto unpackedValue = unpackMetadataValue(otherMetadataColumn.value())) { |
There was a problem hiding this comment.
Can we extend the substrait proto, to avoid placing the essential info in otherMetadataColumn?
There was a problem hiding this comment.
Got it. I extended the Substrait read options with typed Delta DV fields and stopped carrying this essential Delta metadata through other_const_metadata_columns.
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
What changes are proposed in this pull request?
This PR is the next step in the split Delta deletion-vector (DV) stack, following #12040.
It adds the JVM-side Delta DV scan metadata handoff that consumes the native Velox Delta DV reader layer introduced by #12040, without adding DELETE/UPDATE/MERGE DV DML support yet.
Main changes:
StoredBitmap/RoaringBitmapArrayFormat.PortablepathThis PR is intentionally JVM scan handoff only:
spark.databricks.delta.deletionVectors.useMetadataRowIndex=falseyetThe no-metadata-row-index path currently falls back because it relies on Spark's row-index filtering contract, especially for DML-created DVs. Native support for that path should be added only after it can prove the same correctness contract.
Those pieces will be added in follow-up split PRs.
issue #11901.
How was this patch tested?
Added focused JVM/Velox Delta scan coverage in:
backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/DeltaDeletionVectorHandoffSuite.scalabackends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/DeltaSuite.scalabackends-velox/src-delta40/test/scala/org/apache/spark/sql/delta/DeltaDeletionVectorHandoffSuite.scalagluten-delta/src/test/scala/org/apache/gluten/execution/DeltaSuite.scalaCovered cases:
Validation run:
./dev/format-scala-code.sh check./dev/run-scala-test.sh --force -Pjava-17,spark-3.5,backends-velox,hadoop-3.3,spark-ut,delta -pl backends-velox -s org.apache.gluten.execution.VeloxDeltaSuite(19/19passed)./dev/run-scala-test.sh --force -Pjava-17,spark-4.0,scala-2.13,backends-velox,hadoop-3.3,spark-ut,delta -pl backends-velox -s org.apache.gluten.execution.VeloxDeltaSuite(19/19passed)./build/mvn -pl gluten-delta -am -Pbackends-velox -Pspark-3.4 -Pdelta -DskipTests compile./build/mvn -pl gluten-delta,backends-velox -am -Pbackends-velox -Pspark-3.5 -Pdelta -DskipTests test-compile./build/mvn -pl gluten-delta,backends-velox -am -Pbackends-velox -Pspark-4.0 -Pscala-2.13 -Pdelta -DskipTests test-compilegit diff --check upstream/main..HEADAfter addressing review feedback to follow the #10740 split-time handoff shape more closely:
./dev/format-scala-code.sh check./build/mvn -pl gluten-delta,backends-velox -am -Pbackends-velox -Pspark-3.5 -Pdelta -DskipTests test-compile./build/mvn -pl gluten-delta,backends-velox -am -Pbackends-velox -Pspark-4.0 -Pscala-2.13 -Pdelta -DskipTests test-compilegit diff --checkA focused local handoff suite run was attempted, but this machine does not have
darwin/aarch64/libgluten.dylib, so the suite aborted during SparkContext startup before executing tests. CI should cover the runtime path.Was this patch authored or co-authored using generative AI tooling?
Generated-by: IBM BOB