table/test_util/
empty_table.rs1use std::sync::Arc;
16
17use common_error::ext::BoxedError;
18use common_recordbatch::{EmptyRecordBatchStream, SendableRecordBatchStream};
19use datatypes::schema::SchemaRef;
20use store_api::data_source::DataSource;
21use store_api::storage::ScanRequest;
22
23use crate::metadata::{FilterPushDownType, TableInfo};
24use crate::{Table, TableRef};
25
26pub struct EmptyTable;
27
28impl EmptyTable {
29 pub fn from_table_info(info: &TableInfo) -> TableRef {
30 let data_source = Arc::new(EmptyDataSource {
31 schema: info.meta.schema.clone(),
32 });
33 let table = Table::new(
34 Arc::new(info.clone()),
35 FilterPushDownType::Unsupported,
36 data_source,
37 );
38 Arc::new(table)
39 }
40}
41
42struct EmptyDataSource {
43 schema: SchemaRef,
44}
45
46impl DataSource for EmptyDataSource {
47 fn get_stream(
48 &self,
49 _request: ScanRequest,
50 ) -> std::result::Result<SendableRecordBatchStream, BoxedError> {
51 Ok(Box::pin(EmptyRecordBatchStream::new(self.schema.clone())))
52 }
53}