datafusion_python/expr/
drop_function.rs1use std::fmt::{self, Display, Formatter};
19use std::sync::Arc;
20
21use datafusion::logical_expr::DropFunction;
22use pyo3::prelude::*;
23use pyo3::IntoPyObjectExt;
24
25use super::logical_node::LogicalNode;
26use crate::common::df_schema::PyDFSchema;
27use crate::sql::logical::PyLogicalPlan;
28
29#[pyclass(frozen, name = "DropFunction", module = "datafusion.expr", subclass)]
30#[derive(Clone)]
31pub struct PyDropFunction {
32 drop: DropFunction,
33}
34
35impl From<PyDropFunction> for DropFunction {
36 fn from(drop: PyDropFunction) -> Self {
37 drop.drop
38 }
39}
40
41impl From<DropFunction> for PyDropFunction {
42 fn from(drop: DropFunction) -> PyDropFunction {
43 PyDropFunction { drop }
44 }
45}
46
47impl Display for PyDropFunction {
48 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
49 write!(f, "DropFunction")
50 }
51}
52
53#[pymethods]
54impl PyDropFunction {
55 #[new]
56 fn new(name: String, schema: PyDFSchema, if_exists: bool) -> PyResult<Self> {
57 Ok(PyDropFunction {
58 drop: DropFunction {
59 name,
60 schema: Arc::new(schema.into()),
61 if_exists,
62 },
63 })
64 }
65 fn name(&self) -> PyResult<String> {
66 Ok(self.drop.name.clone())
67 }
68
69 fn schema(&self) -> PyDFSchema {
70 (*self.drop.schema).clone().into()
71 }
72
73 fn if_exists(&self) -> PyResult<bool> {
74 Ok(self.drop.if_exists)
75 }
76
77 fn __repr__(&self) -> PyResult<String> {
78 Ok(format!("DropFunction({self})"))
79 }
80
81 fn __name__(&self) -> PyResult<String> {
82 Ok("DropFunction".to_string())
83 }
84}
85
86impl LogicalNode for PyDropFunction {
87 fn inputs(&self) -> Vec<PyLogicalPlan> {
88 vec![]
89 }
90
91 fn to_variant<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
92 self.clone().into_bound_py_any(py)
93 }
94}