• 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

84.62
/DuckDB.NET.Data/DataChunk/Reader/DecimalVectorDataReader.cs
1
namespace DuckDB.NET.Data.DataChunk.Reader;
2

3
internal sealed class DecimalVectorDataReader : VectorDataReaderBase
4
{
5
    private readonly DuckDBType decimalType;
6
    private readonly NumericVectorDataReader numericVectorDataReader;
7

8
    internal unsafe DecimalVectorDataReader(IntPtr vector, void* dataPointer, ulong* validityMaskPointer, DuckDBType columnType, string columnName) : base(dataPointer, validityMaskPointer, columnType, columnName)
945✔
9
    {
10
        using var logicalType = NativeMethods.Vectors.DuckDBVectorGetColumnType(vector);
945✔
11
        Scale = NativeMethods.LogicalType.DuckDBDecimalScale(logicalType);
945✔
12
        Precision = NativeMethods.LogicalType.DuckDBDecimalWidth(logicalType);
945✔
13
        decimalType = NativeMethods.LogicalType.DuckDBDecimalInternalType(logicalType);
945✔
14

15
        numericVectorDataReader = new NumericVectorDataReader(dataPointer, validityMaskPointer, columnType, columnName);
945✔
16
    }
1,890✔
17

18
    internal byte Scale { get; }
1,181,443✔
19

20
    internal byte Precision { get; }
6✔
21

22
    protected override T GetValidValue<T>(ulong offset, Type targetType)
23
    {
24
        if (DuckDBType != DuckDBType.Decimal)
808,466!
25
        {
UNCOV
26
            return base.GetValidValue<T>(offset, targetType);
×
27
        }
28

29
        var value = GetDecimal(offset);
808,466✔
30
        return (T)(object)value; //JIT will optimize the casts at least for not nullable T
808,466✔
31
    }
32

33
    internal override object GetValue(ulong offset, Type targetType)
34
    {
35
        if (DuckDBType != DuckDBType.Decimal)
372,971!
36
        {
UNCOV
37
            return base.GetValue(offset, targetType);
×
38
        }
39

40
        return GetDecimal(offset);
372,971✔
41
    }
42

43
    private decimal GetDecimal(ulong offset)
44
    {
45
        var pow = (decimal)Math.Pow(10, Scale);
1,181,437✔
46
        switch (decimalType)
1,181,437!
47
        {
48
            case DuckDBType.SmallInt:
49
                return decimal.Divide(GetFieldData<short>(offset), pow);
114✔
50
            case DuckDBType.Integer:
51
                return decimal.Divide(GetFieldData<int>(offset), pow);
114✔
52
            case DuckDBType.BigInt:
53
                return decimal.Divide(GetFieldData<long>(offset), pow);
60,114✔
54
            case DuckDBType.HugeInt:
55
                {
56
                    var hugeInt = numericVectorDataReader.GetBigInteger(offset, false);
1,121,095✔
57

58
                    var result = (decimal)BigInteger.DivRem(hugeInt, (BigInteger)pow, out var remainder);
1,121,095✔
59

60
                    result += decimal.Divide((decimal)remainder, pow);
1,121,095✔
61
                    return result;
1,121,095✔
62
                }
UNCOV
63
            default: throw new DuckDBException($"Invalid type {DuckDBType} ({(int)DuckDBType}) for column {ColumnName}");
×
64
        }
65
    }
66

67
    public override void Dispose()
68
    {
69
        numericVectorDataReader.Dispose();
204✔
70
        base.Dispose();
204✔
71
    }
204✔
72
}
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