Skip to content

Commit 5180bda

Browse files
committed
fix: handle input array for extract_schema
1 parent 9d6b01f commit 5180bda

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/functions/extract_schema.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ namespace duckdb
99
{
1010
// Extract the input from the arguments
1111
auto &input_vector = args.data[0];
12-
auto input = input_vector.GetValue (0).ToString ();
12+
auto result_data = FlatVector::GetData<string_t> (result);
1313

14-
// Extract the schema using the utility function
15-
auto schema = netquack::ExtractSchema (input);
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 (schema));
18+
try
19+
{
20+
// Extract the schema using the utility function
21+
auto schema = netquack::ExtractSchema (input);
22+
result_data[i] = StringVector::AddString (result, schema);
23+
}
24+
catch (const std::exception &e)
25+
{
26+
result_data[i] = "Error extracting schema: " + std::string (e.what ());
27+
}
28+
};
1929
}
2030

2131
namespace netquack

test/sql/extract_schema.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
require 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+
710
# ---------------------------- HTTP/S ----------------------------
811

912
query I
@@ -195,3 +198,16 @@ query I
195198
SELECT extract_schema('sms:a');
196199
----
197200
sms
201+
202+
query I
203+
SELECT extract_schema(uri) from uri_list;
204+
----
205+
(empty)
206+
(empty)
207+
(empty)
208+
(empty)
209+
(empty)
210+
(empty)
211+
https
212+
https
213+
http

0 commit comments

Comments
 (0)