slachiewicz opened a new issue, #2826:
URL: https://github.com/apache/iceberg-go/issues/2826
A scan reads an optional struct as null for a row where the struct is
present, when every projected field of that struct is missing from the data
file and the scan also projects another column. Projecting the struct alone
returns the correct value, so the result depends on the projection.
### Reproduce
The table schema is `1: id long (required)`, `2: s struct<3: b long>`. The
data file was written before `s.b` was added, so it holds `s` (field ID 2) with
one other field, and `id` (field ID 1):
```json
[{"s":{"a":5},"id":1},{"s":null,"id":2}]
```
| Projection | Result |
|---|---|
| `s` | `[{"s":{"b":null}},{"s":null}]` |
| `*` | `[{"id":1,"s":null},{"id":2,"s":null}]` |
Row 1 should be `{"id":1,"s":{"b":null}}` in both.
### Cause
`prepareToRead` in
[table/arrow_scanner.go](https://github.com/apache/iceberg-go/blob/main/table/arrow_scanner.go)
reads the full file schema "to retain row counts and nested validity" only
when the projection selects no physical column at all. Once another column such
as `id` is selected, nothing under `s` is read, so the struct's validity is
lost and the missing-field path fills it with null.
### Related
#2747 keeps parent validity for the filter path when a nested field has an
`initial-default`. This report is about the projected result and needs no
default. #2687 makes the same shape reachable for a struct that has a field ID
while none of its fields do.
Seen on `main` at `af737831`, macOS arm64, Go 1.27.4. I can send a fix that
keeps one physical leaf of such a struct in the read, if that direction is fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]