File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -11,13 +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- // Extract the top-level domain using the utility function
17- auto tld = netquack::ExtractTLD (state, input);
16+ for (idx_t i = 0 ; i < args.size (); i++)
17+ {
18+ auto input = input_vector.GetValue (i).ToString ();
1819
19- // Set the result
20- result.SetValue (0 , Value (tld));
20+ try
21+ {
22+ // Extract the top-level domain using the utility function
23+ auto tld = netquack::ExtractTLD (state, input);
24+ result_data[i] = StringVector::AddString (result, tld);
25+ }
26+ catch (const std::exception &e)
27+ {
28+ result_data[i] = " Error extracting tld: " + std::string (e.what ());
29+ }
30+ }
2131 }
2232
2333 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_tld('example.com');
912----
@@ -174,3 +177,16 @@ query I
174177SELECT extract_tld('http:/example.com.ac:443/path');
175178----
176179(empty)
180+
181+ query I
182+ SELECT extract_tld(uri) from uri_list;
183+ ----
184+ com
185+ com.ac
186+ com.co
187+ com
188+ com
189+ com.ac
190+ com
191+ com
192+ com.ac
You can’t perform that action at this time.
0 commit comments