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