diff --git a/src/common/recordbatch/src/recordbatch.rs b/src/common/recordbatch/src/recordbatch.rs index bb996ea463..cd60b5733f 100644 --- a/src/common/recordbatch/src/recordbatch.rs +++ b/src/common/recordbatch/src/recordbatch.rs @@ -31,6 +31,10 @@ impl RecordBatch { }) } + pub fn num_rows(&self) -> usize { + self.df_recordbatch.num_rows() + } + /// Create an iterator to traverse the data by row pub fn rows(&self) -> RecordBatchRowIterator<'_> { RecordBatchRowIterator::new(self) diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index 6db891537f..95e4c98eac 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -9,7 +9,7 @@ use std::time::Duration; use aide::axum::routing as apirouting; use aide::axum::{ApiRouter, IntoApiResponse}; -use aide::openapi::{Info, OpenApi}; +use aide::openapi::{Info, OpenApi, Server as OpenAPIServer}; use async_trait::async_trait; use axum::response::Html; use axum::Extension; @@ -72,7 +72,10 @@ impl HttpRecordsOutput { } pub fn num_cols(&self) -> usize { - self.schema.map(|x| x.column_schemas.len()).unwrap_or(0) + self.schema + .as_ref() + .map(|x| x.column_schemas.len()) + .unwrap_or(0) } } @@ -102,7 +105,8 @@ impl TryFrom> for HttpRecordsOutput { .collect(), }; - let mut rows = Vec::with_capacity(recordbatches.iter().map(|r| r.rows()).sum::()); + let mut rows = + Vec::with_capacity(recordbatches.iter().map(|r| r.num_rows()).sum::()); for recordbatch in recordbatches { for row in recordbatch.rows() { @@ -251,6 +255,11 @@ impl HttpServer { version: HTTP_API_VERSION.to_string(), ..Info::default() }, + servers: vec![OpenAPIServer { + url: "http://localhost:4000/v1".to_string(), + ..OpenAPIServer::default() + }], + ..OpenApi::default() }; diff --git a/src/servers/src/http/handler.rs b/src/servers/src/http/handler.rs index 8cd80fde0b..aa24321d4b 100644 --- a/src/servers/src/http/handler.rs +++ b/src/servers/src/http/handler.rs @@ -31,8 +31,7 @@ pub async fn sql( } pub(crate) fn sql_docs(op: TransformOperation) -> TransformOperation { - op.description("Execute SQL query provided by `sql` parameter") - .response::<200, Json>() + op.response::<200, Json>() } /// Handler to export metrics