mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-27 18:30:38 +00:00
feat: frontend instance (#238)
* feat: frontend instance * no need to carry column length in `Column` proto * add more tests * rebase develop * create a new variant with already provisioned RecordBatches in Output * resolve code review comments * new frontend instance does not connect datanode grpc * add more tests * add more tests * rebase develop Co-authored-by: luofucong <luofucong@greptime.com>
This commit is contained in:
@@ -65,6 +65,12 @@ pub enum Error {
|
||||
|
||||
#[snafu(display("Not supported: {}", feat))]
|
||||
NotSupported { feat: String },
|
||||
|
||||
#[snafu(display("Invalid query: {}", reason))]
|
||||
InvalidQuery {
|
||||
reason: String,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
@@ -86,7 +92,7 @@ impl ErrorExt for Error {
|
||||
| ExecuteScript { source, .. }
|
||||
| ExecuteQuery { source, .. } => source.status_code(),
|
||||
|
||||
NotSupported { .. } => StatusCode::InvalidArguments,
|
||||
NotSupported { .. } | InvalidQuery { .. } => StatusCode::InvalidArguments,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +81,13 @@ impl JsonResponse {
|
||||
Ok(Output::AffectedRows(rows)) => {
|
||||
Self::with_output(Some(JsonOutput::AffectedRows(rows)))
|
||||
}
|
||||
Ok(Output::RecordBatch(stream)) => match util::collect(stream).await {
|
||||
Ok(Output::Stream(stream)) => match util::collect(stream).await {
|
||||
Ok(rows) => Self::with_output(Some(JsonOutput::Rows(rows))),
|
||||
Err(e) => Self::with_error(Some(format!("Recordbatch error: {}", e))),
|
||||
},
|
||||
Ok(Output::RecordBatches(recordbatches)) => {
|
||||
Self::with_output(Some(JsonOutput::Rows(recordbatches.to_vec())))
|
||||
}
|
||||
Err(e) => Self::with_error(Some(format!("Query engine output error: {}", e))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl<'a, W: io::Write> MysqlResultWriter<'a, W> {
|
||||
})?;
|
||||
match output {
|
||||
Ok(output) => match output {
|
||||
Output::RecordBatch(stream) => {
|
||||
Output::Stream(stream) => {
|
||||
let schema = stream.schema().clone();
|
||||
let recordbatches = util::collect(stream)
|
||||
.await
|
||||
@@ -45,6 +45,13 @@ impl<'a, W: io::Write> MysqlResultWriter<'a, W> {
|
||||
};
|
||||
Self::write_query_result(query_result, writer)?
|
||||
}
|
||||
Output::RecordBatches(recordbatches) => {
|
||||
let query_result = QueryResult {
|
||||
schema: recordbatches.schema(),
|
||||
recordbatches: recordbatches.to_vec(),
|
||||
};
|
||||
Self::write_query_result(query_result, writer)?
|
||||
}
|
||||
Output::AffectedRows(rows) => Self::write_affected_rows(writer, rows)?,
|
||||
},
|
||||
Err(error) => Self::write_query_error(error, writer)?,
|
||||
|
||||
Reference in New Issue
Block a user