• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / DuckDB.NET / 21786556530

07 Feb 2026 08:39PM UTC coverage: 89.155% (-0.07%) from 89.223%
21786556530

push

github

Giorgi
Added support for clearing in-progress adapter

Requires DuckDB 1.5

1199 of 1393 branches covered (86.07%)

Branch coverage included in aggregate %.

6 of 8 new or added lines in 1 file covered. (75.0%)

193 existing lines in 43 files now uncovered.

2336 of 2572 relevant lines covered (90.82%)

557295.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.63
/DuckDB.NET.Data/DataChunk/Reader/ListVectorDataReader.cs
1
namespace DuckDB.NET.Data.DataChunk.Reader;
2

3
internal sealed class ListVectorDataReader : VectorDataReaderBase
4
{
5
    private readonly ulong arraySize;
6
    private readonly VectorDataReaderBase listDataReader;
7

8
    public bool IsList => DuckDBType == DuckDBType.List;
14,544✔
9

10
    internal unsafe ListVectorDataReader(IntPtr vector, void* dataPointer, ulong* validityMaskPointer, DuckDBType columnType, DuckDBLogicalType logicalColumnType, string columnName) 
11
                    : base(dataPointer, validityMaskPointer, columnType, columnName)
4,848✔
12
    {
13
        using var childType = IsList ? NativeMethods.LogicalType.DuckDBListTypeChildType(logicalColumnType) : NativeMethods.LogicalType.DuckDBArrayTypeChildType(logicalColumnType);
4,848✔
14

15
        var childVector = IsList ? NativeMethods.Vectors.DuckDBListVectorGetChild(vector) : NativeMethods.Vectors.DuckDBArrayVectorGetChild(vector);
4,848✔
16

17
        arraySize = IsList ? 0 : (ulong)NativeMethods.LogicalType.DuckDBArrayVectorGetSize(logicalColumnType);
4,848✔
18
        listDataReader = VectorDataReaderFactory.CreateReader(childVector, childType, columnName);
4,848✔
19
    }
9,696✔
20

21
    protected override Type GetColumnType()
22
    {
23
        return typeof(List<>).MakeGenericType(listDataReader.ClrType);
30✔
24
    }
25

26
    protected override Type GetColumnProviderSpecificType()
27
    {
28
        return typeof(List<>).MakeGenericType(listDataReader.ProviderSpecificClrType);
18✔
29
    }
30

31
    internal override unsafe object GetValue(ulong offset, Type targetType)
32
    {
33
        switch (DuckDBType)
1,040,915!
34
        {
35
            case DuckDBType.List:
36
                {
37
                    var listData = (DuckDBListEntry*)DataPointer + offset;
1,034,753✔
38

39
                    return GetList(targetType, listData->Offset, listData->Length);
1,034,753✔
40
                }
41
            case DuckDBType.Array:
42
                return GetList(targetType, offset * arraySize, arraySize);
6,162✔
43
            default:
UNCOV
44
                return base.GetValue(offset, targetType);
×
45
        }
46
    }
47

48
    private object GetList(Type returnType, ulong listOffset, ulong length)
49
    {
50
        var listType = returnType.GetGenericArguments()[0];
1,040,915✔
51

52
        var allowNulls = listType.AllowsNullValue(out var _, out var nullableType);
1,040,915✔
53

54
        var list = Activator.CreateInstance(returnType) as IList
1,040,915!
55
                   ?? throw new ArgumentException($"The type '{returnType.Name}' specified in parameter {nameof(returnType)} cannot be instantiated as an IList.");
1,040,915✔
56

57
        //Special case for specific types to avoid boxing
58
        return list switch
1,040,915✔
59
        {
1,040,915✔
60
            List<int> theList => BuildList(theList),
44,112✔
61
            List<int?> theList => BuildList(theList),
21,919✔
62
            List<float> theList => BuildList(theList),
21,987✔
63
            List<float?> theList => BuildList(theList),
22,141✔
64
            List<double> theList => BuildList(theList),
21,978✔
65
            List<double?> theList => BuildList(theList),
21,941✔
66
            List<decimal> theList => BuildList(theList),
51,847✔
67
            List<decimal?> theList => BuildList(theList),
21,886✔
68
            _ => BuildListCommon(list, nullableType ?? listType)
813,104✔
69
        };
1,040,915✔
70

71
        List<T> BuildList<T>(List<T> result)
72
        {
73
            for (ulong i = 0; i < length; i++)
12,920,720✔
74
            {
75
                var childOffset = listOffset + i;
6,232,555✔
76
                if (listDataReader.IsValid(childOffset))
6,232,555✔
77
                {
78
                    var item = listDataReader.GetValue<T>(childOffset);
4,734,849✔
79
                    result.Add(item);
4,734,846✔
80
                }
81
                else
82
                {
83
                    result.Add(allowNulls ? default! : throw new InvalidCastException("The list contains null value"));
1,497,706✔
84
                }
85
            }
86
            return result;
227,805✔
87
        }
88

89
        IList BuildListCommon(IList result, Type targetType)
90
        {
91
            for (ulong i = 0; i < length; i++)
40,373,246✔
92
            {
93
                var childOffset = listOffset + i;
19,373,537✔
94
                if (listDataReader.IsValid(childOffset))
19,373,537✔
95
                {
96
                    var item = listDataReader.GetValue(childOffset, targetType);
15,638,955✔
97
                    result.Add(item);
15,638,940✔
98
                }
99
                else
100
                {
101
                    result.Add(allowNulls ? null : throw new InvalidCastException("The list contains null value"));
3,734,582✔
102
                }
103
            }
104
            return result;
813,086✔
105
        }
106
    }
107

108
    public override void Dispose()
109
    {
110
        listDataReader.Dispose();
714✔
111
        base.Dispose();
714✔
112
    }
714✔
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc