Skip to content

GH-1477: Fill the offsets of NULL rows in ClobConsumer - #1479

Merged
jbonofre merged 2 commits into
apache:mainfrom
jbonofre:clob-consumer-null-offsets
Nov 16, 2026
Merged

jbonofre merged 2 commits into
apache:mainfrom
jbonofre:clob-consumer-null-offsets

Conversation

@jbonofre

Copy link
Copy Markdown
Member

What's Changed

Follow-up to #1231. A NULL row in ClobConsumer doesn't write its end offset, so the next value read its start offset from that unwritten slot (0) and was written over the earlier values: rows "AAAA", NULL, "BB" read back as "BBAA", NULL, "BB", with decreasing offsets.

Both consumers now call vector.fillEmpties(currentIndex) before writing a value, as setSafe() does. It gives the NULL rows since the last value empty offsets, and also grows the validity and offset buffers when currentIndex is past the value capacity, as BinaryConsumer does. Before, consuming more rows than the value capacity (3970 by default) failed with an IndexOutOfBoundsException.

ClobConsumerTest covers NULL rows before, between and after values for both consumers, and twice the default value capacity of rows. The three new tests fail without the fix.

Closes #1477.

A NULL row doesn't write its end offset, so the next value started at
offset 0 and overwrote the earlier values. Fill the offsets of the NULL
rows with fillEmpties() before writing a value, which also grows the
validity and offset buffers past the value capacity.
jbonofre added a commit that referenced this pull request Nov 16, 2026
## What's Changed

Follow-up to #1231. `ClobConsumer` reads a CLOB in chunks of 256
characters and encodes each chunk to UTF-8 on its own, so a character
outside the BMP split between two chunks was encoded as `??`.

- A chunk that ends with a high surrogate, while characters remain, now
leaves it for the next chunk, so the pair is encoded together.
- The read position advances by the length of the chunk instead of the
requested size. The shorter chunk needs this, and it also stops skipping
characters when a driver returns fewer than requested.
- An empty chunk before the end of the CLOB throws an `SQLException`
instead of looping forever.

`ClobConsumerTest` covers emojis across chunk boundaries for both
consumers. The test fails without the fix: 255 `a` followed by 😀 read
back as 257 bytes instead of 259.

This changes other lines of `ClobConsumer` than #1479, and the two
branches merge cleanly.

Closes #1478.
@jbonofre
jbonofre merged commit 7f7689b into apache:main Nov 16, 2026
21 checks passed
@jbonofre
jbonofre deleted the clob-consumer-null-offsets branch November 16, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClobConsumer overwrites earlier values after a NULL row

2 participants