Skip to content

feat: add a native kernel for Delta's InterleaveBits - #7600

Draft
dwsmith1983 wants to merge 1 commit into
apache:mainfrom
dwsmith1983:feat/delta-interleave-bits-kernel
Draft

dwsmith1983 wants to merge 1 commit into
apache:mainfrom
dwsmith1983:feat/delta-interleave-bits-kernel

Conversation

@dwsmith1983

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Refs #7573. This is the first of three PRs:

  1. This PR: the native kernel.
  2. A core hook that lets a contrib register an expression serde. Not opened yet; it waits on the design question in Support Delta InterleaveBits for one or two INT inputs #7573.
  3. feat(delta): prepare InterleaveBits integration #7597: the Delta serde and expression suite. It uses both and closes Support Delta InterleaveBits for one or two INT inputs #7573.

1 and 2 can merge in either order; #7597 goes last.

Rationale for this change

Delta's InterleaveBits builds the Z-order key for liquid clustering and OPTIMIZE ZORDER BY. Comet has no native version, so the projection falls back to Spark. This adds the kernel on its own, so it can be reviewed without the Delta wiring.

What changes are included in this PR?

  • delta_interleave_bits, a scalar function 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, as in Delta.
  • Registered by name in all_scalar_functions(). Nothing calls it from Spark yet.

How are these changes tested?

Unit tests compare the output with values produced by Delta's own InterleaveBits on both its default and fast code paths: signed extrema, nulls, alternating bit patterns and generated pairs. Other tests cover scalar and array arguments in each position, all-scalar calls, and rejection of wrong argument counts or types.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Delta InterleaveBits for one or two INT inputs

1 participant