use std::rc::Rc;
use super::super::errors::*;
use super::common::*;
use arrow::datatypes::*;
pub struct EmptyRelation {
first: bool,
schema: Rc<Schema>,
}
impl EmptyRelation {
pub fn new() -> Self {
EmptyRelation {
first: true,
schema: Rc::new(Schema::new(vec![])),
}
}
}
impl DataSource for EmptyRelation {
fn schema(&self) -> &Rc<Schema> {
&self.schema
}
fn next(&mut self) -> Option<Result<Rc<RecordBatch>>> {
if self.first {
self.first = false;
Some(Ok(Rc::new(DefaultRecordBatch {
schema: self.schema.clone(),
data: Vec::new(),
row_count: 1,
})))
} else {
None
}
}
}