File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,25 @@ namespace duckdb
77 // Function to extract the query string from a URL
88 void ExtractQueryStringFunction (DataChunk &args, ExpressionState &state, Vector &result)
99 {
10- // Extract the URL from the input
11- auto &url_vector = args.data [0 ];
12- auto url = url_vector. GetValue ( 0 ). ToString ( );
10+ // Extract the input from the arguments
11+ auto &input_vector = args.data [0 ];
12+ auto result_data = FlatVector::GetData< string_t > (result );
1313
14- // Extract the query string
15- auto query_string = netquack::ExtractQueryString (url);
14+ for (idx_t i = 0 ; i < args.size (); i++)
15+ {
16+ auto input = input_vector.GetValue (i).ToString ();
1617
17- // Set the result
18- result.SetValue (0 , Value (query_string));
18+ try
19+ {
20+ // Extract the query string using the utility function
21+ auto query_string = netquack::ExtractQueryString (input);
22+ result_data[i] = StringVector::AddString (result, query_string);
23+ }
24+ catch (const std::exception &e)
25+ {
26+ result_data[i] = " Error extracting query string: " + std::string (e.what ());
27+ }
28+ };
1929 }
2030
2131 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_query_string('http://example.com.ac?a=1');
912----
@@ -28,3 +31,16 @@ query I
2831SELECT extract_query_string('http://example.com.ac/path/?a=1');
2932----
3033a=1
34+
35+ query I
36+ SELECT extract_query_string(uri) from uri_list;
37+ ----
38+ (empty)
39+ (empty)
40+ (empty)
41+ (empty)
42+ (empty)
43+ (empty)
44+ (empty)
45+ (empty)
46+ a=1&b=2&
You can’t perform that action at this time.
0 commit comments