use std::sync::Arc;
use datafusion::common::DFSchema;
use pyo3::prelude::*;
#[derive(Debug, Clone)]
#[pyclass(
from_py_object,
frozen,
name = "DFSchema",
module = "datafusion.common",
subclass
)]
pub struct PyDFSchema {
schema: Arc<DFSchema>,
}
impl From<PyDFSchema> for DFSchema {
fn from(schema: PyDFSchema) -> DFSchema {
(*schema.schema).clone()
}
}
impl From<DFSchema> for PyDFSchema {
fn from(schema: DFSchema) -> PyDFSchema {
PyDFSchema {
schema: Arc::new(schema),
}
}
}
#[pymethods]
impl PyDFSchema {
#[pyo3(name = "empty")]
#[staticmethod]
fn py_empty() -> PyResult<Self> {
Ok(Self {
schema: Arc::new(DFSchema::empty()),
})
}
#[pyo3(name = "field_names")]
fn py_field_names(&self) -> PyResult<Vec<String>> {
Ok(self.schema.field_names())
}
}