Skip to main content

datafusion_pg_catalog/pg_catalog/
empty_table.rs

1use std::sync::Arc;
2
3use datafusion::arrow::datatypes::SchemaRef;
4use datafusion::catalog::MemTable;
5use datafusion::error::Result;
6
7#[derive(Debug, Clone)]
8pub struct EmptyTable {
9    schema: SchemaRef,
10}
11
12impl EmptyTable {
13    pub(crate) fn new(schema: SchemaRef) -> Self {
14        Self { schema }
15    }
16
17    pub fn schema(&self) -> SchemaRef {
18        self.schema.clone()
19    }
20
21    pub fn try_into_memtable(&self) -> Result<Arc<MemTable>> {
22        MemTable::try_new(self.schema.clone(), vec![vec![]]).map(Arc::new)
23    }
24}