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:
dennis zhuang
2022-04-27 15:15:26 +08:00
committed by GitHub
parent 12eefc3cd0
commit bf331ec4ac
19 changed files with 455 additions and 43 deletions

View File

@@ -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)
}
}