Skip to content

fix(arrow-pg): emit NULL field for null struct values instead of skipping encoding#299

Merged
sunng87 merged 1 commit intodatafusion-contrib:masterfrom
vimeh:fix/arrow-pg-null-struct-encoding
Feb 26, 2026
Merged

fix(arrow-pg): emit NULL field for null struct values instead of skipping encoding#299
sunng87 merged 1 commit intodatafusion-contrib:masterfrom
vimeh:fix/arrow-pg-null-struct-encoding

Conversation

@vimeh
Copy link
Contributor

@vimeh vimeh commented Feb 25, 2026

encode_struct returns Ok(()) for null struct values without calling encoder.encode_field(). This skips writing a NULL indicator to the pgwire DataRow, corrupting the column count and breaking client connections.

Every other nullable type in encode_value (Lists at line 486, Dictionaries at line 494) correctly calls encoder.encode_field(&None::<T>, pg_field) for null values. Structs are the only type that silently skips the field.

@sunng87
Copy link
Member

sunng87 commented Feb 26, 2026

Good catch! Thank you @vimeh

Could you run cargo fmt for this?

…ping encoding

`encode_struct` returned `Ok(())` for null struct values without calling
`encoder.encode_field()`. This skipped writing a NULL indicator to the
pgwire DataRow, corrupting the column count and breaking client
connections.

The fix calls `encoder.encode_field(&None::<&[i8]>, ...)` for null
structs, consistent with how List and Dictionary types already handle
nulls in `encode_value`.

Adds a regression test that verifies `encode_field` is called exactly
once when encoding a null struct row.
@vimeh vimeh force-pushed the fix/arrow-pg-null-struct-encoding branch from 498970b to c794e99 Compare February 26, 2026 02:35
@vimeh
Copy link
Contributor Author

vimeh commented Feb 26, 2026

done!

@sunng87 sunng87 merged commit 86325a6 into datafusion-contrib:master Feb 26, 2026
7 checks passed
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.

2 participants