@@ -31,6 +31,7 @@ suite('scalar functions', () => {
31
31
}
32
32
} ) ;
33
33
duckdb . register_scalar_function ( connection , scalar_function ) ;
34
+ duckdb . destroy_scalar_function_sync ( scalar_function ) ;
34
35
35
36
const result = await duckdb . query ( connection , "select my_func()" ) ;
36
37
await expectResult ( result , {
@@ -43,7 +44,6 @@ suite('scalar functions', () => {
43
44
{ rowCount : 1 , vectors : [ data ( 16 , [ true ] , [ 'output_0' ] ) ] }
44
45
] ,
45
46
} ) ;
46
- duckdb . destroy_scalar_function_sync ( scalar_function ) ;
47
47
} ) ;
48
48
} ) ;
49
49
test ( 'register & run (extra info)' , async ( ) => {
@@ -60,6 +60,7 @@ suite('scalar functions', () => {
60
60
}
61
61
} , { 'my_extra_info_key' : 'my_extra_info_value' } ) ;
62
62
duckdb . register_scalar_function ( connection , scalar_function ) ;
63
+ duckdb . destroy_scalar_function_sync ( scalar_function ) ;
63
64
64
65
const result = await duckdb . query ( connection , "select my_func()" ) ;
65
66
await expectResult ( result , {
@@ -72,7 +73,21 @@ suite('scalar functions', () => {
72
73
{ rowCount : 1 , vectors : [ data ( 16 , [ true ] , [ 'output_0_{"my_extra_info_key":"my_extra_info_value"}' ] ) ] }
73
74
] ,
74
75
} ) ;
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 ) ;
75
88
duckdb . destroy_scalar_function_sync ( scalar_function ) ;
89
+
90
+ await expect ( duckdb . query ( connection , "select my_func()" ) ) . rejects . toThrow ( 'Invalid Input Error: my_error' ) ; ;
76
91
} ) ;
77
92
} ) ;
78
93
} ) ;
0 commit comments