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