diff --git a/DuckDB.NET.Test/TableFunctionTests.cs b/DuckDB.NET.Test/TableFunctionTests.cs index 88e51ec..95293fe 100644 --- a/DuckDB.NET.Test/TableFunctionTests.cs +++ b/DuckDB.NET.Test/TableFunctionTests.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Numerics; +using DuckDB.NET.Native; using Xunit; namespace DuckDB.NET.Test; @@ -100,9 +102,9 @@ public void RegisterTableFunctionWithFourParameters() var param2 = parameters[1].GetValue(); var param3 = parameters[2].GetValue(); var param4 = parameters[3].GetValue(); - + var enumerable = param4.ToByteArray(param1).Append(param3); - + return new TableFunction(new List() { new ColumnInfo("foo", typeof(byte)), @@ -148,4 +150,28 @@ public void RegisterTableFunctionWithEmptyResult() data.Should().BeEquivalentTo(Enumerable.Empty()); } + + [Fact] + public void RegisterTableFunctionWithBigInteger() + { + Connection.RegisterTableFunction("demo6", parameters => + { + var param1 = parameters[0].GetValue(); + var param2 = parameters[1].GetValue(); + + var timeSpans = param1.ToByteArray().Select(b => param2.Add(TimeSpan.FromDays(b))); + + return new TableFunction(new List() + { + new ColumnInfo("foo", typeof(TimeSpan)), + }, timeSpans); + }, (item, writers, rowIndex) => + { + writers[0].WriteValue((TimeSpan)item, rowIndex); + }); + + var data = Connection.Query("SELECT * FROM demo6('123456789876543210'::HUGEINT, '24:00:00'::INTERVAL);").ToList(); + + data.Should().BeEquivalentTo(BigInteger.Parse("123456789876543210").ToByteArray().Select(b => TimeSpan.FromDays(1 + b))); + } } \ No newline at end of file