Skip to content

feat: Add support for the null type - #226

Open
singhpratech wants to merge 1 commit into
apache:mainfrom
singhpratech:feat-null-type
Open

singhpratech wants to merge 1 commit into
apache:mainfrom
singhpratech:feat-null-type

Conversation

@singhpratech

@singhpratech singhpratech commented Nov 22, 2026 •

Copy link
Copy Markdown

What's Changed

Adds the null type, which until now was only a case in ArrowTypeId.

  • ArrowType.ArrowNull, with C data interface format string n in both directions.
  • NullArray (ArrowArray<Never>) and NullArrayBuilder / NullBufferBuilder, available through ArrowArrayBuilders.loadNullArrayBuilder() and loadBuilder(arrowType:). A null array has no buffers, so the builder only tracks its length; ArrowData.isNull returns true for the null type without touching a buffer.
  • IPC: the reader maps the flatbuffers Null type and loads a null column from its field node alone, consuming no buffers. The writer emits the Null type and no buffers. ChunkedArrayHolder reports zero buffers for a null column instead of assuming two or three.
  • C data interface: a null array exports with n_buffers == 0 and 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 through ArrowArrayHolderBuilder.
  • 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.
  • testImportExportNullArray and a null field added to testImportExportSchema.
  • swift test passes locally on macOS with Swift 6.3 and the -warnings-as-errors flags enabled.
  • Checked by hand against pyarrow 21.0.0 in both directions: pyarrow reads the stream and file written by Swift as [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.

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.
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.

Add support for the null type

1 participant