@@ -31,6 +31,7 @@ suite('scalar functions', () => {
3131 }
3232 } ) ;
3333 duckdb . register_scalar_function ( connection , scalar_function ) ;
34+ duckdb . destroy_scalar_function_sync ( scalar_function ) ;
3435
3536 const result = await duckdb . query ( connection , "select my_func()" ) ;
3637 await expectResult ( result , {
@@ -43,7 +44,6 @@ suite('scalar functions', () => {
4344 { rowCount : 1 , vectors : [ data ( 16 , [ true ] , [ 'output_0' ] ) ] }
4445 ] ,
4546 } ) ;
46- duckdb . destroy_scalar_function_sync ( scalar_function ) ;
4747 } ) ;
4848 } ) ;
4949 test ( 'register & run (extra info)' , async ( ) => {
@@ -60,6 +60,7 @@ suite('scalar functions', () => {
6060 }
6161 } , { 'my_extra_info_key' : 'my_extra_info_value' } ) ;
6262 duckdb . register_scalar_function ( connection , scalar_function ) ;
63+ duckdb . destroy_scalar_function_sync ( scalar_function ) ;
6364
6465 const result = await duckdb . query ( connection , "select my_func()" ) ;
6566 await expectResult ( result , {
@@ -72,7 +73,21 @@ suite('scalar functions', () => {
7273 { rowCount : 1 , vectors : [ data ( 16 , [ true ] , [ 'output_0_{"my_extra_info_key":"my_extra_info_value"}' ] ) ] }
7374 ] ,
7475 } ) ;
76+ } ) ;
77+ } ) ;
78+ test ( 'error handling' , async ( ) => {
79+ await withConnection ( async ( connection ) => {
80+ const scalar_function = duckdb . create_scalar_function ( ) ;
81+ duckdb . scalar_function_set_name ( scalar_function , 'my_func' ) ;
82+ const int_type = duckdb . create_logical_type ( duckdb . Type . VARCHAR ) ;
83+ duckdb . scalar_function_set_return_type ( scalar_function , int_type ) ;
84+ duckdb . scalar_function_set_function ( scalar_function , ( _info , _input , _output ) => {
85+ throw new Error ( 'my_error' ) ;
86+ } ) ;
87+ duckdb . register_scalar_function ( connection , scalar_function ) ;
7588 duckdb . destroy_scalar_function_sync ( scalar_function ) ;
89+
90+ await expect ( duckdb . query ( connection , "select my_func()" ) ) . rejects . toThrow ( 'Invalid Input Error: my_error' ) ; ;
7691 } ) ;
7792 } ) ;
7893} ) ;
0 commit comments