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

Giorgi / DuckDB.NET / 28102732334

24 Jun 2026 01:39PM UTC coverage: 89.358% (-0.1%) from 89.474%
28102732334

Pull #334

github

web-flow
Merge 0037674ea into 38ddceb66
Pull Request #334: Add Apache Arrow result streaming to DuckDBCommand

1359 of 1583 branches covered (85.85%)

Branch coverage included in aggregate %.

84 of 94 new or added lines in 4 files covered. (89.36%)

6 existing lines in 2 files now uncovered.

2856 of 3134 relevant lines covered (91.13%)

421088.62 hits per line

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

57.89
/DuckDB.NET.Data/Mapping/DuckDBAppenderMap.cs
1
namespace DuckDB.NET.Data.Mapping;
2

3
/// <summary>
4
/// Base class for defining mappings between .NET classes and DuckDB table columns for appender operations.
5
/// </summary>
6
/// <typeparam name="T">The type to map</typeparam>
7
public abstract class DuckDBAppenderMap<T>
8
{
9
    /// <summary>
10
    /// Gets the property mappings defined for this class map.
11
    /// </summary>
12
    internal List<IPropertyMapping<T>> PropertyMappings { get; } = new(8);
66✔
13

14
    /// <summary>
15
    /// Maps a property to the next column in sequence.
16
    /// </summary>
17
    /// <typeparam name="TProperty">The property type</typeparam>
18
    /// <param name="getter">Function to get the property value</param>
19
    protected void Map<TProperty>(Func<T, TProperty> getter)
20
    {
21
        var mapping = new PropertyMapping<T, TProperty>
36✔
22
        {
36✔
23
            PropertyType = typeof(TProperty),
36✔
24
            Getter = getter,
36✔
25
            MappingType = PropertyMappingType.Property
36✔
26
        };
36✔
27

28
        PropertyMappings.Add(mapping);
36✔
29
    }
36✔
30

31
    /// <summary>
32
    /// Adds a default value for the next column.
33
    /// </summary>
34
    protected void DefaultValue()
35
    {
36
        var mapping = new DefaultValueMapping<T>
3✔
37
        {
3✔
38
            PropertyType = typeof(object),
3✔
39
            MappingType = PropertyMappingType.Default
3✔
40
        };
3✔
41

42
        PropertyMappings.Add(mapping);
3✔
43
    }
3✔
44

45
    /// <summary>
46
    /// Adds a null value for the next column.
47
    /// </summary>
48
    protected void NullValue()
49
    {
50
        var mapping = new NullValueMapping<T>
3✔
51
        {
3✔
52
            PropertyType = typeof(object),
3✔
53
            MappingType = PropertyMappingType.Null
3✔
54
        };
3✔
55

56
        PropertyMappings.Add(mapping);
3✔
57
    }
3✔
58
}
59

60
internal enum PropertyMappingType
61
{
62
    Property,
63
    Default,
64
    Null
65
}
66

67
internal interface IPropertyMapping<T>
68
{
69
    Type PropertyType { get; }
70
    PropertyMappingType MappingType { get; }
71
    IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record);
72
}
73

74
internal sealed class PropertyMapping<T, TProperty> : IPropertyMapping<T>
75
{
76
    public Type PropertyType { get; set; } = typeof(object);
108✔
77
    public Func<T, TProperty> Getter { get; set; } = _ => default!;
120✔
78
    public PropertyMappingType MappingType { get; set; }
69✔
79

80
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
81
    {
82
        var value = Getter(record);
48✔
83

84
        if (value is null)
48!
85
        {
86
            return row.AppendNullValue();
×
87
        }
88

89
        return value switch
48!
90
        {
48✔
91
            // Reference types
48✔
92
            string v => row.AppendValue(v),
12✔
93
            byte[] v => row.AppendValue(v),
6✔
94

48✔
95
            // Value types
48✔
96
            bool v => row.AppendValue(v),
×
97
            sbyte v => row.AppendValue(v),
×
UNCOV
98
            short v => row.AppendValue(v),
×
99
            int v => row.AppendValue(v),
18✔
100
            long v => row.AppendValue(v),
×
101
            byte v => row.AppendValue(v),
×
102
            ushort v => row.AppendValue(v),
×
103
            uint v => row.AppendValue(v),
×
UNCOV
104
            ulong v => row.AppendValue(v),
×
105
            float v => row.AppendValue(v),
6✔
106
            double v => row.AppendValue(v),
×
UNCOV
107
            decimal v => row.AppendValue(v),
×
108
            DateTime v => row.AppendValue(v),
6✔
109
            DateTimeOffset v => row.AppendValue(v),
×
110
            TimeSpan v => row.AppendValue(v),
×
111
            Guid v => row.AppendValue(v),
×
112
            BigInteger v => row.AppendValue(v),
×
113
            DuckDBDateOnly v => row.AppendValue(v),
×
114
            DuckDBTimeOnly v => row.AppendValue(v),
×
115
            DateOnly v => row.AppendValue(v),
×
UNCOV
116
            TimeOnly v => row.AppendValue(v),
×
117

48✔
UNCOV
118
            _ => throw new NotSupportedException($"Type {typeof(TProperty).Name} is not supported for appending")
×
119
        };
48✔
120
    }
121
}
122

123
internal sealed class DefaultValueMapping<T> : IPropertyMapping<T>
124
{
125
    public Type PropertyType { get; set; } = typeof(object);
6✔
126
    public PropertyMappingType MappingType { get; set; }
6✔
127

128
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
129
    {
130
        return row.AppendDefault();
6✔
131
    }
132
}
133

134
internal sealed class NullValueMapping<T> : IPropertyMapping<T>
135
{
136
    public Type PropertyType { get; set; } = typeof(object);
6✔
137
    public PropertyMappingType MappingType { get; set; }
6✔
138

139
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
140
    {
141
        return row.AppendNullValue();
6✔
142
    }
143
}
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