Repository navigation
Conversation
|
@ErikBPF thanks for opening this. Could you add me as a collaborator on ErikBPF/datafusion-comet so I can push to |
|
Here's how I'd split the work so each piece stays reviewable:
I'll open the first two from my fork, link them here, and add you as a collaborator on it so you can push to those branches. Once you've added me on yours, I'll move the serde and suite into this PR and hand it back to you. |
Adds delta_interleave_bits, a scalar function that builds Delta Lake's Z-order key for one or two Int32 inputs: bits are taken from the most significant down, alternating between inputs with the first input in the higher position, a null input counts as zero, and the result is four bytes per input and never null. The tests check the output against values produced by Delta's own InterleaveBits on both its default and fast code paths, including signed extrema and nulls. Nothing calls the function from Spark yet; the Delta serde that uses it comes separately.
|
@dwsmith1983 Thanks. I sent a collaborator invitation for The proposed split works for us:
I will keep the manual probe in this PR as the reference baseline until the suite supersedes it. The only open dependency is the expression-admission design in #7573; we will not add core Delta class matching on our side unless that is the maintainers' preference. |
Adds CometExpressionContrib, a ServiceLoader hook beside CometScanContrib, so a contrib can register a serde for an expression class core never names. Delta's InterleaveBits is the first user: the class lives in delta-spark, which core does not depend on. QueryPlanSerde.serdeFor now looks in core's map first and the contrib registry second, and both lookup sites use it. A contrib entry for a class core already handles is ignored, a class claimed by two contribs is dropped from both since ServiceLoader order is unspecified, and a contrib that throws is skipped. Default builds ship no service file, so nothing changes for them. The scan suite's service-file test helper moves into a shared test utility that both suites use.
Registers a serde for Delta's InterleaveBits through the contrib expression hook, so the Z-order key for one or two integer inputs runs in Comet's native kernel instead of falling back. Other forms keep falling back with a reason, and spark.comet.expression.InterleaveBits.enabled turns it off. The new suite checks exact bytes for column and literal inputs, nulls, signed extrema and generated pairs against Spark under both of Delta's interleave code paths, across several batches and on an empty table. It replaces the standalone reference checks under dev/repros/delta. The Delta user guide gains a section on Z-order keys, and the scan flag's description now says only scans are left to Spark by default.
Arrow builders leave zero under a null slot, so the existing null tests passed even without the kernel's null check. The new test puts -1 under a null and expects the bytes of a zero input.
|
@ErikBPF pushed the Delta serde and the expression suite (dcbbdec). Until the two pieces underneath merge, this diff also carries them:
After those merge and this branch merges It's yours from here for cleanup and extending. Open items I left:
|
Which issue does this PR close?
Refs #7573. This draft does not close the issue.
Rationale for this change
Delta's
InterleaveBitsis the Z-order keyOPTIMIZE ... ZORDER BYsorts on. It falls back to Spark today, and the issue records the observed fallback on Parquet input. This branch takes the expression through the Comet pipeline for the one- and two-inputINTshapes that the issue scopes.The core hook is a
CometExpressionContribServiceLoader interface next toCometScanContrib: the Delta contrib registers a serde forInterleaveBits, so core names no Delta class. This is a draft until maintainers agree on that seam in #7573; the other option discussed there is matching the Delta class name in core.Hilbert ordering, range-partition expressions and broader clustering operations remain out of scope.
OPTIMIZE ... ZORDER BYstill falls back because its inputs are Delta's range-partition expressions, which Comet does not convert.What changes are included in this PR?
CometExpressionContribhook: ServiceLoader discovery, core-wins and duplicate-claim handling, aserdeForlookup used byQueryPlanSerdeand the ScalaUDF guard check, and focused tests.InterleaveBits, with fallback for other arities and non-INTchildren.delta_interleave_bitskernel: one or twoInt32inputs,4 * nbig-endian bytes, null-as-zero, never null.OPTIMIZEstill matching Spark.How are these changes tested?
cargo test -p datafusion-comet-spark-expr --lib delta_funcs: 9 passed. The goldens include 130 pairs generated from both of Delta's interleave implementations.CometExpressionContribSuite: 7 passed (Spark 4.1.3).CometDeltaInterleaveBitsSuite: 9 passed (Spark 4.1.3 / Delta 4.3.1), including both Delta interleave paths and theOPTIMIZEregression.spark-4.2profile; the OPTIMIZE case fails withNoSuchMethodErrorinQueryExecutionbecause Delta 4.3.1 targets Spark 4.1. The Spark 4.2 / Delta 4.4 pairing is separate work in feat(delta): pair Spark 4.2 with Delta 4.4.1 #7593.These are local/Apollo runs, not a published CI run. The PR stays a draft until the expression-admission design in #7573 is settled.