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