mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-24 08:50:40 +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:
@@ -79,14 +79,14 @@ impl QueryEngine for DatafusionQueryEngine {
|
||||
let physical_plan = self.create_physical_plan(&mut ctx, &logical_plan).await?;
|
||||
let physical_plan = self.optimize_physical_plan(&mut ctx, physical_plan)?;
|
||||
|
||||
Ok(Output::RecordBatch(
|
||||
Ok(Output::Stream(
|
||||
self.execute_stream(&ctx, &physical_plan).await?,
|
||||
))
|
||||
}
|
||||
|
||||
async fn execute_physical(&self, plan: &Arc<dyn PhysicalPlan>) -> Result<Output> {
|
||||
let ctx = QueryContext::new(self.state.clone());
|
||||
Ok(Output::RecordBatch(self.execute_stream(&ctx, plan).await?))
|
||||
Ok(Output::Stream(self.execute_stream(&ctx, plan).await?))
|
||||
}
|
||||
|
||||
fn register_udf(&self, udf: ScalarUdf) {
|
||||
@@ -267,7 +267,7 @@ mod tests {
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
|
||||
match output {
|
||||
Output::RecordBatch(recordbatch) => {
|
||||
Output::Stream(recordbatch) => {
|
||||
let numbers = util::collect(recordbatch).await.unwrap();
|
||||
assert_eq!(1, numbers.len());
|
||||
assert_eq!(numbers[0].df_recordbatch.num_columns(), 1);
|
||||
|
||||
@@ -7,7 +7,7 @@ use catalog::CatalogList;
|
||||
use common_function::scalars::aggregate::AggregateFunctionMetaRef;
|
||||
use common_function::scalars::{FunctionRef, FUNCTION_REGISTRY};
|
||||
use common_query::prelude::ScalarUdf;
|
||||
use common_recordbatch::SendableRecordBatchStream;
|
||||
use common_recordbatch::{RecordBatches, SendableRecordBatchStream};
|
||||
use sql::statements::statement::Statement;
|
||||
|
||||
use crate::datafusion::DatafusionQueryEngine;
|
||||
@@ -19,7 +19,8 @@ pub use crate::query_engine::state::QueryEngineState;
|
||||
/// Sql output
|
||||
pub enum Output {
|
||||
AffectedRows(usize),
|
||||
RecordBatch(SendableRecordBatchStream),
|
||||
RecordBatches(RecordBatches),
|
||||
Stream(SendableRecordBatchStream),
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
||||
@@ -86,7 +86,7 @@ async fn execute_argmax<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -87,7 +87,7 @@ async fn execute_argmin<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -67,7 +67,7 @@ where
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let numbers = util::collect(recordbatch_stream).await.unwrap();
|
||||
|
||||
@@ -80,7 +80,7 @@ async fn execute_mean<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -222,7 +222,7 @@ where
|
||||
|
||||
let output = engine.execute(&plan).await?;
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let recordbatch = util::collect(recordbatch_stream).await.unwrap();
|
||||
|
||||
@@ -48,7 +48,7 @@ async fn test_percentile_correctness() -> Result<()> {
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let record_batch = util::collect(recordbatch_stream).await.unwrap();
|
||||
@@ -108,7 +108,7 @@ async fn execute_percentile<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -83,7 +83,7 @@ async fn execute_polyval<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -63,7 +63,7 @@ async fn test_datafusion_query_engine() -> Result<()> {
|
||||
let output = engine.execute(&plan).await?;
|
||||
|
||||
let recordbatch = match output {
|
||||
Output::RecordBatch(recordbatch) => recordbatch,
|
||||
Output::Stream(recordbatch) => recordbatch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@@ -121,7 +121,7 @@ async fn test_udf() -> Result<()> {
|
||||
|
||||
let output = engine.execute(&plan).await?;
|
||||
let recordbatch = match output {
|
||||
Output::RecordBatch(recordbatch) => recordbatch,
|
||||
Output::Stream(recordbatch) => recordbatch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@@ -244,7 +244,7 @@ where
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let numbers = util::collect(recordbatch_stream).await.unwrap();
|
||||
@@ -349,7 +349,7 @@ async fn execute_median<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -85,7 +85,7 @@ async fn execute_scipy_stats_norm_cdf<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
@@ -85,7 +85,7 @@ async fn execute_scipy_stats_norm_pdf<'a>(
|
||||
|
||||
let output = engine.execute(&plan).await.unwrap();
|
||||
let recordbatch_stream = match output {
|
||||
Output::RecordBatch(batch) => batch,
|
||||
Output::Stream(batch) => batch,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
util::collect(recordbatch_stream).await
|
||||
|
||||
Reference in New Issue
Block a user