Skip to content

Commit 1fa8ed5

Browse files
committed
Add float and double list support
1 parent 38d1ac6 commit 1fa8ed5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

DuckDB.NET.Data/Internal/Writer/ListVectorDataWriter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal sealed unsafe class ListVectorDataWriter : VectorDataWriterBase
1818
public ListVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType, DuckDBLogicalType logicalType) : base(vector, vectorData, columnType)
1919
{
2020
using var childType = IsList ? NativeMethods.LogicalType.DuckDBListTypeChildType(logicalType) : NativeMethods.LogicalType.DuckDBArrayTypeChildType(logicalType);
21-
var childVector = IsList ? NativeMethods.Vectors.DuckDBListVectorGetChild(vector) : NativeMethods.Vectors.DuckDBArrayVectorGetChild(vector); ;
21+
var childVector = IsList ? NativeMethods.Vectors.DuckDBListVectorGetChild(vector) : NativeMethods.Vectors.DuckDBArrayVectorGetChild(vector);
2222

2323
arraySize = IsList ? 0 : (ulong)NativeMethods.LogicalType.DuckDBArrayVectorGetSize(logicalType);
2424
listItemWriter = VectorDataWriterFactory.CreateWriter(childVector, childType);
@@ -43,6 +43,9 @@ internal override bool AppendCollection(ICollection value, int rowIndex)
4343
IEnumerable<uint> items => WriteItems(items),
4444
IEnumerable<ulong> items => WriteItems(items),
4545

46+
IEnumerable<float> items => WriteItems(items),
47+
IEnumerable<double> items => WriteItems(items),
48+
4649
IEnumerable<decimal> items => WriteItems(items),
4750
IEnumerable<BigInteger> items => WriteItems(items),
4851

@@ -73,7 +76,7 @@ int WriteItems<T>(IEnumerable<T> items)
7376
if (IsList == false && count != arraySize)
7477
{
7578
throw new InvalidOperationException($"Column has Array size of {arraySize} but the specified value has size of {count}");
76-
};
79+
}
7780

7881
var index = 0;
7982

DuckDB.NET.Test/DuckDBManagedAppenderListTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,20 @@ public void ListValuesLong()
4444
ListValuesInternal("BigInt", faker => faker.Random.Long());
4545
}
4646

47+
[Fact]
48+
public void ListValuesFloat()
49+
{
50+
ListValuesInternal("Float", faker => faker.Random.Float());
51+
}
52+
53+
[Fact]
54+
public void ListValuesDouble()
55+
{
56+
ListValuesInternal("Double", faker => faker.Random.Double());
57+
}
58+
4759

48-
public void ListValuesInternal<T>(string typeName, Func<Faker, T> generator, int? length = null)
60+
private void ListValuesInternal<T>(string typeName, Func<Faker, T> generator, int? length = null)
4961
{
5062
var rows = 2000;
5163
var table = $"managedAppender{typeName}Lists";

0 commit comments

Comments
 (0)