File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,23 @@ namespace duckdb
1111 {
1212 // Extract the input from the arguments
1313 auto &input_vector = args.data [0 ];
14- auto input = input_vector. GetValue ( 0 ). ToString ( );
14+ auto result_data = FlatVector::GetData< string_t > (result );
1515
16- if (input. empty ())
16+ for ( idx_t i = 0 ; i < args. size (); i++ )
1717 {
18- result.SetValue (0 , Value (" " ));
19- return ;
20- }
21-
22- // Extract the domain using the utility function
23- auto domain = netquack::ExtractDomain (state, input);
18+ auto input = input_vector.GetValue (i).ToString ();
2419
25- result.SetValue (0 , Value (domain));
20+ try
21+ {
22+ // Extract the domain using the utility function
23+ auto domain = netquack::ExtractDomain (state, input);
24+ result_data[i] = StringVector::AddString (result, domain);
25+ }
26+ catch (const std::exception &e)
27+ {
28+ result_data[i] = " Error extracting domain: " + std::string (e.what ());
29+ }
30+ }
2631 }
2732
2833 namespace netquack
Original file line number Diff line number Diff line change 44
55require netquack
66
7+ statement ok
8+ CREATE TABLE uri_list AS SELECT * FROM read_csv('test/data/examples.csv', header=false, columns={'uri': 'VARCHAR'});
9+
710query I
811SELECT extract_domain('example.com');
912----
@@ -172,4 +175,17 @@ SELECT extract_domain('http:/example.com.ac/path');
172175query I
173176SELECT extract_domain('http:/example.com.ac:443/path');
174177----
175- (empty)
178+ (empty)
179+
180+ query I
181+ SELECT extract_domain(uri) from uri_list;
182+ ----
183+ example.com
184+ example.com.ac
185+ example.com.co
186+ example.com
187+ example.com
188+ example.com.ac
189+ example.com
190+ example.com
191+ example.com.ac
You can’t perform that action at this time.
0 commit comments