Skip to content

[BUG]: Row group reader failed on string list #766

Description

@zhouchanghai

Library Version

6.0.0

.NET Runtime

.net 8

OS and Architecture

Windows (64-bit)

How to reproduce?

When a column is List, the row group reader will fail with error like " System.ArgumentException : Definition levels buffer is too small for field 'Tags/list/element' (length 2 < numValues 2)"

Failing test

using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    using Parquet;
    using Parquet.Schema;
    using Parquet.Serialization;
    using Xunit;

public class ParquetNetListColumnReadReproTests
{
    [Fact]
    public async Task ReadStringListColumn_WithLowLevelRowGroupReader_ShouldRoundTrip()
    {
        // Arrange - write a parquet with a single List<string> column using the high-level serializer.
        var records = new List<Record>
        {
            new Record { Tags = new List<string> { "a", "b", "c" } },
            new Record { Tags = new List<string> { "d" } },
        };

        using var stream = new MemoryStream();
        await ParquetSerializer.SerializeAsync(records, stream);
        stream.Position = 0;

        // Act - read the leaf column (Tags/list/element) back with the low-level row group reader.
        await using var reader = await ParquetReader.CreateAsync(stream);
        DataField field = reader.Schema.GetDataFields()[0];

        using var rowGroupReader = reader.OpenRowGroupReader(0);
        var numValues = (int)rowGroupReader.GetMetadata(field)!.MetaData!.NumValues;

        var values = new string[numValues];
        var repetitionLevels = new int[numValues];

        // BUG: this throws "Definition levels buffer is too small for field 'Tags/list/element'".
        await rowGroupReader.ReadAsync(field, values, repetitionLevels);

        // Assert - the four physical string values should have round-tripped.
        Assert.Equal(new[] { "a", "b", "c", "d" }, values);
    }

    private sealed class Record
    {
        public List<string>? Tags { get; set; }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions