mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 13:22:57 +00:00
feat: support to generate json output for explain analyze in http api (#5567)
* impl Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * integration test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * Update src/servers/src/http/hints.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: with FORMAT option for explain format * lift some well-known metrics Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ning Sun <sunning@greptime.com>
This commit is contained in:
@@ -413,6 +413,18 @@ pub async fn test_sql_api(store_type: StorageType) {
|
||||
let body = serde_json::from_str::<ErrorResponse>(&res.text().await).unwrap();
|
||||
assert_eq!(body.code(), ErrorCode::DatabaseNotFound as u32);
|
||||
|
||||
// test analyze format
|
||||
let res = client
|
||||
.get("/v1/sql?sql=explain analyze format json select cpu, ts from demo limit 1")
|
||||
.send()
|
||||
.await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
let body = serde_json::from_str::<GreptimedbV1Response>(&res.text().await).unwrap();
|
||||
let output = body.output();
|
||||
assert_eq!(output.len(), 1);
|
||||
// this is something only json format can show
|
||||
assert!(format!("{:?}", output[0]).contains("\\\"param\\\""));
|
||||
|
||||
// test parse method
|
||||
let res = client.get("/v1/sql/parse?sql=desc table t").send().await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
|
||||
Reference in New Issue
Block a user