File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ # name: test/sql/httpclient.test
2+ # description: test httpclient extension
3+ # group: [httpclient]
4+
5+ # Before we load the extension, this will fail
6+ statement error
7+ SELECT http_get('Sam');
8+ ----
9+ Catalog Error: Scalar Function with name http_get does not exist!
10+
11+ # Require statement will ensure this test is run with this extension loaded
12+ require http_client
13+
14+ require json
15+
16+ # Confirm the GET extension works
17+ query I
18+ WITH __input AS (
19+ SELECT
20+ http_get(
21+ 'https://httpbin.org/delay/0'
22+ ) AS data
23+ ),
24+ __features AS (
25+ SELECT
26+ unnest( from_json((data::JSON)->'headers', '{"Host": "VARCHAR"}') )
27+ AS features
28+ FROM
29+ __input
30+ )
31+ SELECT
32+ __features.Host AS host,
33+ FROM
34+ __features
35+ ;
36+ ----
37+ httpbin.org
38+
39+ # Confirm the POST extension works
40+ query I
41+ WITH __input AS (
42+ SELECT
43+ http_post(
44+ 'https://httpbin.org/delay/0',
45+ headers => MAP {
46+ 'accept': 'application/json',
47+ }::VARCHAR,
48+ params => MAP {}::VARCHAR
49+ ) AS data
50+ ),
51+ __features AS (
52+ SELECT
53+ unnest( from_json((data::JSON)->'headers', '{"Host": "VARCHAR"}') )
54+ AS features
55+ FROM
56+ __input
57+ )
58+ SELECT
59+ __features.Host AS host,
60+ FROM
61+ __features
62+ ;
63+ ----
64+ httpbin.org
You can’t perform that action at this time.
0 commit comments