Skip to content

duckdb: i16 Decimal on duckdb side may fit in Vortex's i8 decimal buffer - #10155

Merged
myrrc merged 4 commits into
developfrom
myrrc/duckdb-decimal-null-exporter
Oct 6, 2026
Merged

myrrc merged 4 commits into
developfrom
myrrc/duckdb-decimal-null-exporter

Conversation

@myrrc

@myrrc myrrc commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Decimal builders have an extend() method which adds values to the builder's decimal buffer from another decimal buffer. We allow extend()ing from a decimal buffer which is greater than our builder's buffer. This may happen with a Chunked array where for a given precision we've estimated values to fit in T but one of chunks has type Y >= T.

As a particular example, it happens in Duckdb with a Decimal(2, 1). For 2 our type is i8 but Duckdb's minimal type for Decimals is i16, so we do a narrowing i16->i8 conversion.

Inside extend(), we lazily convert the values from the extending buffer to the target type and fail on conversion. We also don't consider NULL values. So, a NULL value on an extending buffer which contents don't fit into a builder's decimal buffer will fail a conversion. This in particular happens with copy_to_stats SLT under nextext.

The correct fix for this is to ensure boundaries between a query engine and Vortex are handled correctly, so we need to to an extra pass in the input buffer and zero out values under NULL. However, this is a big change to build and invariant.

The simpler fix, though, is to handle specific i16->i8 conversion which I do here.

@myrrc
myrrc requested a review from robert3005 September 30, 2026 10:55
@myrrc myrrc added changelog/fix A bug fix ext/duckdb Relates to the DuckDB integration labels Sep 30, 2026
@myrrc
myrrc enabled auto-merge (squash) September 30, 2026 10:55
@codspeed

codspeed Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 1 benchmark measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. This result is not comparable, so it counts as unchanged.

Preventing compiler optimizations

✅ 2107 untouched benchmarks
⏩ 518 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚠️ Simulation bench_compare_sliced_dict_primitive[(3333, 10000)] 76.6 µs < 1 ns N/A

Comparing myrrc/duckdb-decimal-null-exporter (4beb1d4) with develop (dd1ce26)

Open in CodSpeed

Footnotes

  1. 518 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@joseph-isaacs

Copy link
Copy Markdown
Contributor

I really don't understand here. What is failing the byte-widths are the same.

Can we add a test showing it or is that too hard?

@myrrc

myrrc commented Sep 30, 2026 via email

Copy link
Copy Markdown
Contributor Author

@robert3005

Copy link
Copy Markdown
Contributor

I am also lost - we clearly copy same values. Where do we produce the i8 array from i16? Seems like that conversion logic is wrong and panics if null value is out of the narrowed range?

@robert3005

Copy link
Copy Markdown
Contributor

If this is the case the fix should be in narrowing function not in duckdb

@myrrc myrrc changed the title duckdb: zero NULL values in decimal exporter decimal builders ignore NULL values when appending to builder Oct 2, 2026
@myrrc myrrc removed the ext/duckdb Relates to the DuckDB integration label Oct 2, 2026
@myrrc

myrrc commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

These are two separate bugs, both in decimal code. I've updated the patch.

@myrrc
myrrc requested a review from joseph-isaacs October 2, 2026 14:36
Comment thread vortex-array/src/builders/decimal.rs Resolved
Comment thread vortex-array/src/builders/decimal.rs Resolved
@myrrc
myrrc requested a review from joseph-isaacs October 5, 2026 09:34
@myrrc myrrc changed the title decimal builders ignore NULL values when appending to builder duckdb: i6 Decimal on duckdb side may fit in Vortex's i8 decimal buffer Oct 5, 2026
@myrrc myrrc changed the title duckdb: i6 Decimal on duckdb side may fit in Vortex's i8 decimal buffer duckdb: i16 Decimal on duckdb side may fit in Vortex's i8 decimal buffer Oct 5, 2026
@myrrc myrrc mentioned this pull request Oct 5, 2026
Signed-off-by: Mikhail Kot <[email protected]>
@myrrc
myrrc force-pushed the myrrc/duckdb-decimal-null-exporter branch from 8d0325e to 526a691 Compare October 5, 2026 13:51
Comment thread vortex-duckdb/src/convert/vector.rs Resolved
Signed-off-by: Mikhail Kot <[email protected]>
@myrrc
myrrc requested a review from joseph-isaacs October 5, 2026 14:06
Comment thread vortex-duckdb/src/convert/vector.rs Resolved
@joseph-isaacs
joseph-isaacs disabled auto-merge October 6, 2026 14:05
Signed-off-by: Mikhail Kot <[email protected]>
@myrrc
myrrc enabled auto-merge (squash) October 6, 2026 14:39
Signed-off-by: Mikhail Kot <[email protected]>
@myrrc
myrrc merged commit 659c7f7 into develop Oct 6, 2026
118 of 119 checks passed
@myrrc
myrrc deleted the myrrc/duckdb-decimal-null-exporter branch October 6, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants