Skip to content

Commit

Permalink
Fix for appending lists with null
Browse files Browse the repository at this point in the history
* Add failing test

* Make test pass

* Alternative test implementation. Reduce data size from 2000 rows to 10 rows.
  • Loading branch information
brendonparker authored Jun 18, 2024
1 parent e2e2e71 commit 53734da
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions DuckDB.NET.Data/Internal/Writer/ListVectorDataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,54 @@ internal override bool AppendCollection(ICollection value, int rowIndex)
_ = value switch
{
IEnumerable<bool> items => WriteItems(items),
IEnumerable<bool?> items => WriteItems(items),

IEnumerable<sbyte> items => WriteItems(items),
IEnumerable<sbyte?> items => WriteItems(items),
IEnumerable<short> items => WriteItems(items),
IEnumerable<short?> items => WriteItems(items),
IEnumerable<int> items => WriteItems(items),
IEnumerable<int?> items => WriteItems(items),
IEnumerable<long> items => WriteItems(items),
IEnumerable<long?> items => WriteItems(items),
IEnumerable<byte> items => WriteItems(items),
IEnumerable<byte?> items => WriteItems(items),
IEnumerable<ushort> items => WriteItems(items),
IEnumerable<ushort?> items => WriteItems(items),
IEnumerable<uint> items => WriteItems(items),
IEnumerable<uint?> items => WriteItems(items),
IEnumerable<ulong> items => WriteItems(items),
IEnumerable<ulong?> items => WriteItems(items),

IEnumerable<float> items => WriteItems(items),
IEnumerable<float?> items => WriteItems(items),
IEnumerable<double> items => WriteItems(items),
IEnumerable<double?> items => WriteItems(items),

IEnumerable<decimal> items => WriteItems(items),
IEnumerable<decimal?> items => WriteItems(items),
IEnumerable<BigInteger> items => WriteItems(items),
IEnumerable<BigInteger?> items => WriteItems(items),

IEnumerable<string> items => WriteItems(items),
IEnumerable<Guid> items => WriteItems(items),
IEnumerable<Guid?> items => WriteItems(items),
IEnumerable<DateTime> items => WriteItems(items),
IEnumerable<DateTime?> items => WriteItems(items),
IEnumerable<TimeSpan> items => WriteItems(items),
IEnumerable<TimeSpan?> items => WriteItems(items),
IEnumerable<DuckDBDateOnly> items => WriteItems(items),
IEnumerable<DuckDBDateOnly?> items => WriteItems(items),
IEnumerable<DuckDBTimeOnly> items => WriteItems(items),
IEnumerable<DuckDBTimeOnly?> items => WriteItems(items),
#if NET6_0_OR_GREATER
IEnumerable<DateOnly> items => WriteItems(items),
IEnumerable<DateOnly?> items => WriteItems(items),
IEnumerable<TimeOnly> items => WriteItems(items),
IEnumerable<TimeOnly?> items => WriteItems(items),
#endif
IEnumerable<DateTimeOffset> items => WriteItems(items),
IEnumerable<DateTimeOffset?> items => WriteItems(items),

_ => WriteItems<object>((IEnumerable<object>)value)
};
Expand Down
8 changes: 7 additions & 1 deletion DuckDB.NET.Test/DuckDBManagedAppenderListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ public void ArrayValuesInt()
ListValuesInternal("Integer", faker => faker.Random.Int(), 5);
}

[Fact]
public void ListValuesNullableDouble()
{
ListValuesInternal("Double", faker => faker.Random.Double().OrNull(faker));
}

private void ListValuesInternal<T>(string typeName, Func<Faker, T> generator, int? length = null)
{
var rows = 2000;
var rows = 10;
var table = $"managedAppenderLists";

var columnLength = length.HasValue ? length.Value.ToString() : "";
Expand Down

0 comments on commit 53734da

Please sign in to comment.