mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-30 11:50:38 +00:00
feat: impl QueryEngine#execute, adds numbers table and query engine test (#13)
* feat: impl QueryEngine#execute, adds numbers table and query engine test * fix: clippy warning * fix: reuse runtime in context in table adapter * fix: by CR comments
This commit is contained in:
@@ -5,6 +5,7 @@ use std::pin::Pin;
|
||||
|
||||
use datatypes::schema::SchemaRef;
|
||||
use error::Result;
|
||||
use futures::task::{Context, Poll};
|
||||
use futures::Stream;
|
||||
pub use recordbatch::RecordBatch;
|
||||
|
||||
@@ -13,3 +14,31 @@ pub trait RecordBatchStream: Stream<Item = Result<RecordBatch>> {
|
||||
}
|
||||
|
||||
pub type SendableRecordBatchStream = Pin<Box<dyn RecordBatchStream + Send>>;
|
||||
|
||||
/// EmptyRecordBatchStream can be used to create a RecordBatchStream
|
||||
/// that will produce no results
|
||||
pub struct EmptyRecordBatchStream {
|
||||
/// Schema wrapped by Arc
|
||||
schema: SchemaRef,
|
||||
}
|
||||
|
||||
impl EmptyRecordBatchStream {
|
||||
/// Create an empty RecordBatchStream
|
||||
pub fn new(schema: SchemaRef) -> Self {
|
||||
Self { schema }
|
||||
}
|
||||
}
|
||||
|
||||
impl RecordBatchStream for EmptyRecordBatchStream {
|
||||
fn schema(&self) -> SchemaRef {
|
||||
self.schema.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for EmptyRecordBatchStream {
|
||||
type Item = Result<RecordBatch>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
Poll::Ready(None)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user