Repository navigation
feat: Add support for the null type - #226
Open
singhpratech wants to merge 1 commit into
Open
singhpratech wants to merge 1 commit into
singhpratech wants to merge 1 commit into
Conversation
Add ArrowType.ArrowNull with NullArray and NullArrayBuilder. A null array has no buffers, so only its length is tracked and every value is null. Null columns can be read and written in the IPC file and streaming formats, and imported and exported through the C data interface with the format string "n". Closes apache#225.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's Changed
Adds the null type, which until now was only a case in
ArrowTypeId.ArrowType.ArrowNull, with C data interface format stringnin both directions.NullArray(ArrowArray<Never>) andNullArrayBuilder/NullBufferBuilder, available throughArrowArrayBuilders.loadNullArrayBuilder()andloadBuilder(arrowType:). A null array has no buffers, so the builder only tracks its length;ArrowData.isNullreturnstruefor the null type without touching a buffer.Nulltype and loads a null column from its field node alone, consuming no buffers. The writer emits theNulltype and no buffers.ChunkedArrayHolderreports zero buffers for a null column instead of assuming two or three.n_buffers == 0and imports back with its length.Not included:
ArrowEncoder/ArrowDecoder, since there is no Swift value type that maps to a null column.Testing
testNullArray: builder and array behaviour, including throughArrowArrayHolderBuilder.testNullTypeInMemoryToFromStream: round trip through the streaming and file formats, with the null column placed between an int32 and a string column so that a wrong buffer count would corrupt the column after it.testImportExportNullArrayand a null field added totestImportExportSchema.swift testpasses locally on macOS with Swift 6.3 and the-warnings-as-errorsflags enabled.[int32, null, string]with the expected values, and Swift reads a file with the same columns written by pyarrow.AI disclosure: written with Claude Code.
Closes #225.