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