1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::Statement;
use arrow::{datatypes::SchemaRef, record_batch::RecordBatch};
#[must_use = "Arrow is lazy and will do nothing unless consumed"]
pub struct Arrow<'stmt> {
pub(crate) stmt: Option<&'stmt Statement<'stmt>>,
}
impl<'stmt> Arrow<'stmt> {
#[inline]
pub(crate) fn new(stmt: &'stmt Statement<'stmt>) -> Arrow<'stmt> {
Arrow { stmt: Some(stmt) }
}
#[inline]
pub fn get_schema(&self) -> SchemaRef {
self.stmt.unwrap().stmt.schema()
}
}
impl<'stmt> Iterator for Arrow<'stmt> {
type Item = RecordBatch;
fn next(&mut self) -> Option<Self::Item> {
Some(RecordBatch::from(&self.stmt?.step()?))
}
}