apache / apache/arrow-swift

BaseBufferBuilder.isNull returns the inverse of the null state

Open Beginner friendly
#180 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
32
Forks
18
Avg merge
19h 14m
Merged PRs (30d)
2

Description

### Describe the bug, including details regarding any error messages, version, and platform.

### Description

`BaseBufferBuilder.isNull(_:)` reports a value as null when it is valid, and as valid when it is null.

### Root Cause

The builders write a standard Arrow validity bitmap: `append` calls `setBit` for non-null values and `clearBit` for null values, so a set bit means valid. The function returns `isSet`, which means it reports the opposite of the intended result.

```swift
public func isNull(_ index: UInt) -> Bool {
return self.nulls.length == 0 || BitUtility.isSet(index + self.offset, buffer: self.nulls)
}
```

This is confirmed by two other places in the codebase that treat the same bitmap correctly:

- `ArrowData.isNull(_:)` returns `nullBuffer.length > 0 && !BitUtility.isSet(...)`
- `ListBufferBuilder.isNull(_:)` returned `!BitUtility.isSet(...)` (redundant override)

### Affected Builders

- `FixedBufferBuilder`
- `BoolBufferBuilder`
- `VariableBufferBuilder`
- `StructBufferBuilder`
- `Date32BufferBuilder` and `Date64BufferBuilder` (via `AbstractWrapperBufferBuilder`)

### Impact

No code inside the library calls the builders' `isNull` — all internal readers go through `ArrowData.isNull` — so this affects external users of the public builder API only.

Contributor guide

Open the contributing guide

Research direction

Start at BaseBufferBuilder.isNull(_:) and compare its validity-bitmap handling with ArrowData.isNull(_:) and ListBufferBuilder.isNull(_:) as described. Verify the behavior across FixedBufferBuilder, BoolBufferBuilder, VariableBufferBuilder, StructBufferBuilder, and the date builders; done means set bits report non-null and cleared bits report null.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.