@@ -73,21 +73,69 @@ use pyo3::types::{PyCapsule, PyDict, PyList, PyTuple, PyType};
7373use tokio:: task:: JoinHandle ;
7474
7575/// Configuration for displaying DataFrames
76+ #[ pyclass( name = "DataframeDisplayConfig" , module = "datafusion" , subclass) ]
77+ #[ derive( Clone ) ]
78+ pub struct PyDataframeDisplayConfig {
79+ /// Maximum bytes to display for table presentation (default: 2MB)
80+ #[ pyo3( get, set) ]
81+ pub max_table_bytes : usize ,
82+ /// Minimum number of table rows to display (default: 20)
83+ #[ pyo3( get, set) ]
84+ pub min_table_rows : usize ,
85+ /// Maximum length of a cell before it gets minimized (default: 25)
86+ #[ pyo3( get, set) ]
87+ pub max_cell_length : usize ,
88+ /// Maximum number of rows to display in repr string output (default: 10)
89+ #[ pyo3( get, set) ]
90+ pub max_table_rows_in_repr : usize ,
91+ }
92+
93+ #[ pymethods]
94+ impl PyDataframeDisplayConfig {
95+ #[ new]
96+ #[ pyo3( signature = ( max_table_bytes=None , min_table_rows=None , max_cell_length=None , max_table_rows_in_repr=None ) ) ]
97+ fn new (
98+ max_table_bytes : Option < usize > ,
99+ min_table_rows : Option < usize > ,
100+ max_cell_length : Option < usize > ,
101+ max_table_rows_in_repr : Option < usize > ,
102+ ) -> Self {
103+ let default = Self :: default ( ) ;
104+ Self {
105+ max_table_bytes : max_table_bytes. unwrap_or ( default. max_table_bytes ) ,
106+ min_table_rows : min_table_rows. unwrap_or ( default. min_table_rows ) ,
107+ max_cell_length : max_cell_length. unwrap_or ( default. max_cell_length ) ,
108+ max_table_rows_in_repr : max_table_rows_in_repr
109+ . unwrap_or ( default. max_table_rows_in_repr ) ,
110+ }
111+ }
112+ }
113+
114+ impl Default for PyDataframeDisplayConfig {
115+ fn default ( ) -> Self {
116+ Self {
117+ max_table_bytes : 2 * 1024 * 1024 , // 2 MB
118+ min_table_rows : 20 ,
119+ max_cell_length : 25 ,
120+ max_table_rows_in_repr : 10 ,
121+ }
122+ }
123+ }
76124
77125/// Configuration options for a SessionContext
78126#[ pyclass( name = "SessionConfig" , module = "datafusion" , subclass) ]
79127#[ derive( Clone , Default ) ]
80128pub struct PySessionConfig {
81129 pub config : SessionConfig ,
82130 #[ pyo3( get, set) ]
83- pub display_config : DataframeDisplayConfig ,
131+ pub display_config : PyDataframeDisplayConfig ,
84132}
85133
86134impl From < SessionConfig > for PySessionConfig {
87135 fn from ( config : SessionConfig ) -> Self {
88136 Self {
89137 config,
90- display_config : DataframeDisplayConfig :: default ( ) ,
138+ display_config : PyDataframeDisplayConfig :: default ( ) ,
91139 }
92140 }
93141}
@@ -106,7 +154,7 @@ impl PySessionConfig {
106154
107155 Self {
108156 config,
109- display_config : DataframeDisplayConfig :: default ( ) ,
157+ display_config : PyDataframeDisplayConfig :: default ( ) ,
110158 }
111159 }
112160
@@ -166,7 +214,7 @@ impl PySessionConfig {
166214 Self :: from ( self . config . clone ( ) . with_repartition_file_min_size ( size) )
167215 }
168216
169- fn with_dataframe_display_config ( & self , display_config : DataframeDisplayConfig ) -> Self {
217+ fn with_dataframe_display_config ( & self , display_config : PyDataframeDisplayConfig ) -> Self {
170218 let mut config = self . clone ( ) ;
171219 config. display_config = display_config;
172220 config
@@ -181,55 +229,6 @@ impl PySessionConfig {
181229 }
182230}
183231
184- #[ pyclass( name = "DataframeDisplayConfig" , module = "datafusion" , subclass) ]
185- #[ derive( Clone ) ]
186- pub struct DataframeDisplayConfig {
187- /// Maximum bytes to display for table presentation (default: 2MB)
188- #[ pyo3( get, set) ]
189- pub max_table_bytes : usize ,
190- /// Minimum number of table rows to display (default: 20)
191- #[ pyo3( get, set) ]
192- pub min_table_rows : usize ,
193- /// Maximum length of a cell before it gets minimized (default: 25)
194- #[ pyo3( get, set) ]
195- pub max_cell_length : usize ,
196- /// Maximum number of rows to display in repr string output (default: 10)
197- #[ pyo3( get, set) ]
198- pub max_table_rows_in_repr : usize ,
199- }
200-
201- #[ pymethods]
202- impl DataframeDisplayConfig {
203- #[ new]
204- #[ pyo3( signature = ( max_table_bytes=None , min_table_rows=None , max_cell_length=None , max_table_rows_in_repr=None ) ) ]
205- fn new (
206- max_table_bytes : Option < usize > ,
207- min_table_rows : Option < usize > ,
208- max_cell_length : Option < usize > ,
209- max_table_rows_in_repr : Option < usize > ,
210- ) -> Self {
211- let default = Self :: default ( ) ;
212- Self {
213- max_table_bytes : max_table_bytes. unwrap_or ( default. max_table_bytes ) ,
214- min_table_rows : min_table_rows. unwrap_or ( default. min_table_rows ) ,
215- max_cell_length : max_cell_length. unwrap_or ( default. max_cell_length ) ,
216- max_table_rows_in_repr : max_table_rows_in_repr
217- . unwrap_or ( default. max_table_rows_in_repr ) ,
218- }
219- }
220- }
221-
222- impl Default for DataframeDisplayConfig {
223- fn default ( ) -> Self {
224- Self {
225- max_table_bytes : 2 * 1024 * 1024 , // 2 MB
226- min_table_rows : 20 ,
227- max_cell_length : 25 ,
228- max_table_rows_in_repr : 10 ,
229- }
230- }
231- }
232-
233232/// Runtime options for a SessionContext
234233#[ pyclass( name = "RuntimeEnvBuilder" , module = "datafusion" , subclass) ]
235234#[ derive( Clone ) ]
0 commit comments