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:
Ruihang Xia
2025-02-20 21:13:09 -08:00
committed by GitHub
parent 76083892cd
commit d69e93b91a
7 changed files with 159 additions and 13 deletions

View File

@@ -15,7 +15,7 @@
use std::fmt::{Display, Formatter};
use serde::Serialize;
use sqlparser::ast::Statement as SpStatement;
use sqlparser::ast::{AnalyzeFormat, Statement as SpStatement};
use sqlparser_derive::{Visit, VisitMut};
use crate::error::Error;
@@ -26,6 +26,15 @@ pub struct Explain {
pub inner: SpStatement,
}
impl Explain {
pub fn format(&self) -> Option<AnalyzeFormat> {
match self.inner {
SpStatement::Explain { format, .. } => format,
_ => None,
}
}
}
impl TryFrom<SpStatement> for Explain {
type Error = Error;