55using System . Collections . Generic ;
66using System . Diagnostics . CodeAnalysis ;
77using System . Linq ;
8+ using System . Numerics ;
9+ using DuckDB . NET . Native ;
810using Xunit ;
911
1012namespace DuckDB . NET . Test ;
@@ -100,9 +102,9 @@ public void RegisterTableFunctionWithFourParameters()
100102 var param2 = parameters [ 1 ] . GetValue < decimal > ( ) ;
101103 var param3 = parameters [ 2 ] . GetValue < byte > ( ) ;
102104 var param4 = parameters [ 3 ] . GetValue < Guid > ( ) ;
103-
105+
104106 var enumerable = param4 . ToByteArray ( param1 ) . Append ( param3 ) ;
105-
107+
106108 return new TableFunction ( new List < ColumnInfo > ( )
107109 {
108110 new ColumnInfo ( "foo" , typeof ( byte ) ) ,
@@ -148,4 +150,28 @@ public void RegisterTableFunctionWithEmptyResult()
148150
149151 data . Should ( ) . BeEquivalentTo ( Enumerable . Empty < int > ( ) ) ;
150152 }
153+
154+ [ Fact ]
155+ public void RegisterTableFunctionWithBigInteger ( )
156+ {
157+ Connection . RegisterTableFunction < BigInteger , TimeSpan > ( "demo6" , parameters =>
158+ {
159+ var param1 = parameters [ 0 ] . GetValue < BigInteger > ( ) ;
160+ var param2 = parameters [ 1 ] . GetValue < TimeSpan > ( ) ;
161+
162+ var timeSpans = param1 . ToByteArray ( ) . Select ( b => param2 . Add ( TimeSpan . FromDays ( b ) ) ) ;
163+
164+ return new TableFunction ( new List < ColumnInfo > ( )
165+ {
166+ new ColumnInfo ( "foo" , typeof ( TimeSpan ) ) ,
167+ } , timeSpans ) ;
168+ } , ( item , writers , rowIndex ) =>
169+ {
170+ writers [ 0 ] . WriteValue ( ( TimeSpan ) item , rowIndex ) ;
171+ } ) ;
172+
173+ var data = Connection . Query < TimeSpan > ( "SELECT * FROM demo6('123456789876543210'::HUGEINT, '24:00:00'::INTERVAL);" ) . ToList ( ) ;
174+
175+ data . Should ( ) . BeEquivalentTo ( BigInteger . Parse ( "123456789876543210" ) . ToByteArray ( ) . Select ( b => TimeSpan . FromDays ( 1 + b ) ) ) ;
176+ }
151177}
0 commit comments