diff --git a/DuckDB.NET.Test/QueryTests.cs b/DuckDB.NET.Test/QueryTests.cs index 4cc1f675..75d25311 100644 --- a/DuckDB.NET.Test/QueryTests.cs +++ b/DuckDB.NET.Test/QueryTests.cs @@ -41,7 +41,27 @@ public void QueryTest() var columnCount = NativeMethods.Query.DuckDBColumnCount(ref queryResult); columnCount.Should().Be(2); + // Using Data Chunks API + var chunkCount = NativeMethods.Types.DuckDBResultChunkCount(queryResult); + chunkCount.Should().Be(1); + + using var chunk = NativeMethods.Types.DuckDBResultGetChunk(queryResult, 0); + var columnCountInChunk = NativeMethods.DataChunks.DuckDBDataChunkGetColumnCount(chunk); + columnCountInChunk.Should().Be(2); + var chunkRowCount = NativeMethods.DataChunks.DuckDBDataChunkGetSize(chunk); + chunkRowCount.Should().Be(3); + + var columnA = NativeMethods.DataChunks.DuckDBDataChunkGetVector(chunk, 0); + using var columnALogicalType = NativeMethods.DataChunks.DuckDBVectorGetColumnType(columnA); + var columnAType = NativeMethods.LogicalType.DuckDBGetTypeId(columnALogicalType); + columnAType.Should().Be(DuckDBType.DuckdbTypeInteger); + + var columnB = NativeMethods.DataChunks.DuckDBDataChunkGetVector(chunk, 1); + using var columnBLogicalType = NativeMethods.DataChunks.DuckDBVectorGetColumnType(columnB); + var columnBType = NativeMethods.LogicalType.DuckDBGetTypeId(columnBLogicalType); + columnBType.Should().Be(DuckDBType.DuckdbTypeBoolean); + NativeMethods.Query.DuckDBDestroyResult(ref queryResult); } } -} \ No newline at end of file +}