1pub use datafusion::{
20 self, common as datafusion_common, logical_expr as datafusion_expr, optimizer,
21 sql as datafusion_sql,
22};
23#[cfg(feature = "substrait")]
24pub use datafusion_substrait;
25#[cfg(feature = "mimalloc")]
26use mimalloc::MiMalloc;
27use pyo3::prelude::*;
28
29pub mod analyzer;
30pub mod catalog;
31pub mod codec;
32pub mod common;
33
34pub mod context;
35pub mod dataframe;
36mod dataset;
37mod dataset_exec;
38pub mod errors;
39pub mod expr;
40mod functions;
41pub mod metrics;
42mod options;
43pub mod physical_plan;
44mod pyarrow_filter_expression;
45pub mod pyarrow_util;
46mod record_batch;
47mod spark_functions;
48pub mod sql;
49pub mod store;
50pub mod table;
51pub mod unparser;
52
53mod array;
54#[cfg(feature = "substrait")]
55pub mod substrait;
56mod udaf;
57mod udf;
58pub mod udtf;
59mod udwf;
60
61pub use udaf::to_rust_accumulator;
64pub use udwf::{MultiColumnWindowUDF, PythonFunctionWindowUDF, to_rust_partition_evaluator};
65
66#[cfg(feature = "mimalloc")]
67#[global_allocator]
68static GLOBAL: MiMalloc = MiMalloc;
69
70#[pymodule]
75fn _internal(py: Python, m: Bound<'_, PyModule>) -> PyResult<()> {
76 pyo3_log::init();
78
79 m.add_class::<context::PyRuntimeEnvBuilder>()?;
81 m.add_class::<context::PySessionConfig>()?;
82 m.add_class::<context::PySessionContext>()?;
83 m.add_class::<context::PySQLOptions>()?;
84 m.add_class::<dataframe::PyDataFrame>()?;
85 m.add_class::<dataframe::PyInsertOp>()?;
86 m.add_class::<dataframe::PyDataFrameWriteOptions>()?;
87 m.add_class::<dataframe::PyParquetColumnOptions>()?;
88 m.add_class::<dataframe::PyParquetWriterOptions>()?;
89 m.add_class::<udf::PyScalarUDF>()?;
90 m.add_class::<udaf::PyAggregateUDF>()?;
91 m.add_class::<udwf::PyWindowUDF>()?;
92 m.add_class::<udtf::PyTableFunction>()?;
93 m.add_class::<sql::logical::PyLogicalPlan>()?;
94 m.add_class::<metrics::PyMetricsSet>()?;
95 m.add_class::<metrics::PyMetric>()?;
96 m.add_class::<physical_plan::PyExecutionPlan>()?;
97 m.add_class::<record_batch::PyRecordBatch>()?;
98 m.add_class::<record_batch::PyRecordBatchStream>()?;
99
100 let catalog = PyModule::new(py, "catalog")?;
101 catalog::init_module(&catalog)?;
102 m.add_submodule(&catalog)?;
103
104 let common = PyModule::new(py, "common")?;
106 common::init_module(&common)?;
107 m.add_submodule(&common)?;
108
109 let expr = PyModule::new(py, "expr")?;
111 expr::init_module(&expr)?;
112 m.add_submodule(&expr)?;
113
114 let unparser = PyModule::new(py, "unparser")?;
115 unparser::init_module(&unparser)?;
116 m.add_submodule(&unparser)?;
117
118 let funcs = PyModule::new(py, "functions")?;
120 functions::init_module(&funcs)?;
121 let spark_funcs = PyModule::new(py, "spark")?;
123 spark_functions::init_module(&spark_funcs)?;
124 funcs.add_submodule(&spark_funcs)?;
125 m.add_submodule(&funcs)?;
126
127 let store = PyModule::new(py, "object_store")?;
128 store::init_module(&store)?;
129 m.add_submodule(&store)?;
130
131 let options = PyModule::new(py, "options")?;
132 options::init_module(&options)?;
133 m.add_submodule(&options)?;
134
135 #[cfg(feature = "substrait")]
137 setup_substrait_module(py, &m)?;
138
139 Ok(())
140}
141
142#[cfg(feature = "substrait")]
143fn setup_substrait_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
144 let substrait = PyModule::new(py, "substrait")?;
145 substrait::init_module(&substrait)?;
146 m.add_submodule(&substrait)?;
147 Ok(())
148}