mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-03 11:52:54 +00:00
feat: add json format output for http interface (#4797)
* feat: json output format for http * feat: add json result test case * fix: typo and refactor a piece of code * fix: cargo check * move affected_rows to top level
This commit is contained in:
@@ -182,6 +182,22 @@ pub async fn test_sql_api(store_type: StorageType) {
|
||||
})).unwrap()
|
||||
);
|
||||
|
||||
// test json result format
|
||||
let res = client
|
||||
.get("/v1/sql?format=json&sql=select * from numbers limit 10")
|
||||
.send()
|
||||
.await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
|
||||
let body = res.json::<Value>().await;
|
||||
let data = body.get("data").expect("Missing 'data' field in response");
|
||||
|
||||
let expected = json!([
|
||||
{"number": 0}, {"number": 1}, {"number": 2}, {"number": 3}, {"number": 4},
|
||||
{"number": 5}, {"number": 6}, {"number": 7}, {"number": 8}, {"number": 9}
|
||||
]);
|
||||
assert_eq!(data, &expected);
|
||||
|
||||
// test insert and select
|
||||
let res = client
|
||||
.get("/v1/sql?sql=insert into demo values('host', 66.6, 1024, 0)")
|
||||
@@ -1307,7 +1323,7 @@ transform:
|
||||
.send()
|
||||
.await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
let body: serde_json::Value = res.json().await;
|
||||
let body: Value = res.json().await;
|
||||
let schema = &body["schema"];
|
||||
let rows = &body["rows"];
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user