-
Notifications
You must be signed in to change notification settings - Fork 627
Fix client-v2: serialize Nested columns in RowBinary writer #2936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
polyglotAI-bot
wants to merge
2
commits into
main
Choose a base branch
from
polyglot/rowbinary-nested-writer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Nested rejected unlike Array
Medium Severity
RowBinaryFormatWriterstill rejects a Javanullfor a non-nullableNestedcolumn inwriteValuePreamble, while non-nullableArraycolumns are allowed through and serialize as an empty array. The newserializeNestedTypeDatawrites a zero element count fornull, but that path is never reached on insert.Reviewed by Cursor Bugbot for commit e0f4674. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks — I checked this empirically against a live server (ClickHouse 26.5) and I don't think we should let a Java
nullthrough for a non-nullableNestedcolumn, because theArraypath it would mirror is itself byte-incorrect.Here is exactly what
writeValuePreamble+ the serializer emit for a non-nullable column given a Javanull:Array(Int32)+null00 00Nested(a Int32, b String)+nullIllegalArgumentException: An attempt to write null into not nullable columnNested(a Int32, b String)+Arrays.asList()(empty)00The
Arraycase emits two bytes:writeValuePreamblewriteswriteNonNull(0x00) and thenserializeArrayData(null)writes the var-uint length0(0x00). Sending those bytes to the server for a singleArray(Int32)column does not insert one empty array — it inserts a phantom second row:So
Arraydoesn't correctly "serializenullas an empty array" — it silently corrupts the stream (and in a multi-column row that extra byte shifts every following column). MakingNestedmatchArraywould copy that bug.The current
Nestedbehavior — throwing fornullinto a non-nullable column — is the safe and consistent choice (it's what every non-Array/Dynamictype does) and it fails loudly instead of corrupting data. The correct way to write an emptyNestedis an empty list, which round-trips correctly (00, a single empty row) and is covered by the unit test. Theif (value == null) writeVarInt(0)guard inserializeNestedTypeDatais a deliberate mirror of the identical guard inserializeArrayDataand emits correct bytes if reached via direct/recursive serialization, so I've kept it.I'm leaving this thread open. The pre-existing
Array+nullphantom-row issue is a separate behavior change unrelated to theNestedsupport in this PR, so I'm flagging it to be fixed on its own rather than folding it in here. If you'd prefer top-levelnullto mean "empty Nested", the correct fix would be a do-nothing preamble branch (emitting a single00), not theArraybranch — happy to add that, but it's a separate decision from the crash fix here.