CurtHagenlocher opened a new issue, #513:
URL: https://github.com/apache/arrow-dotnet/issues/513
### Describe the bug, including details regarding any error messages,
version, and platform.
The Arrow format allows a struct with no fields, and other implementations
create and exchange them. pyarrow, for example, has `pa.struct([])`.
Apache.Arrow refuses one in three places:
1. **Type construction:** `new StructType(new List<Field>())` throws
`ArgumentNullException("fields")`. `NestedType`'s list constructor treats an
empty list like null. `UnionType` goes through the same constructor.
2. **IPC read:** a schema that contains a `struct<>` (for example, written
by pyarrow) fails in `MessageSerializer.GetFieldArrowType`. A field with no
children gets `childFields == null`, and the `Struct_` case asserts it is
non-null.
3. **C data interface export:** `CArrowSchemaExporter` throws
`NotSupportedException("Exporting nested data types with zero children.")`.
Expected: a zero-field `StructType` can be built, a `StructArray` with no
children (length and validity only) works, and both round-trip through the IPC
stream and file formats and the C data interface. This should hold for a
top-level column and for a struct nested in, for example, a list.
Repro, with pyarrow writing and Apache.Arrow reading:
```python
import pyarrow as pa, pyarrow.ipc as ipc
t = pa.table({"empty": pa.array([{}, None, {}], type=pa.struct([]))})
with ipc.new_file("empty.arrow", t.schema) as w:
w.write_table(t)
```
```csharp
using var reader = new ArrowFileReader(File.OpenRead("empty.arrow"));
reader.ReadNextRecordBatch(); // fails reading the schema
```
Where this came up: an Avro record with no fields, such as the `partition`
record in an unpartitioned Iceberg table's manifest, has no Arrow
representation in .NET today. In other implementations it maps naturally to
`struct<>`.
Seen on current main (bbca2f6), on all target frameworks.
### Component(s)
C#
--
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]