@@ -27,7 +27,7 @@ use datafusion::arrow::datatypes::Schema;
27
27
use datafusion:: arrow:: record_batch:: RecordBatch ;
28
28
use datafusion:: datasource:: datasource:: TableProvider ;
29
29
use datafusion:: datasource:: MemTable ;
30
- use datafusion:: execution:: context:: SessionContext ;
30
+ use datafusion:: execution:: context:: { SessionConfig , SessionContext } ;
31
31
use datafusion:: prelude:: { CsvReadOptions , ParquetReadOptions } ;
32
32
33
33
use crate :: catalog:: { PyCatalog , PyTable } ;
@@ -47,11 +47,47 @@ pub(crate) struct PySessionContext {
47
47
48
48
#[ pymethods]
49
49
impl PySessionContext {
50
- // TODO(kszucs): should expose the configuration options as keyword arguments
50
+ #[ allow( clippy:: too_many_arguments) ]
51
+ #[ args(
52
+ default_catalog = "\" datafusion\" " ,
53
+ default_schema = "\" public\" " ,
54
+ create_default_catalog_and_schema = "true" ,
55
+ information_schema = "false" ,
56
+ repartition_joins = "true" ,
57
+ repartition_aggregations = "true" ,
58
+ repartition_windows = "true" ,
59
+ parquet_pruning = "true" ,
60
+ target_partitions = "None"
61
+ ) ]
51
62
#[ new]
52
- fn new ( ) -> Self {
63
+ fn new (
64
+ default_catalog : & str ,
65
+ default_schema : & str ,
66
+ create_default_catalog_and_schema : bool ,
67
+ information_schema : bool ,
68
+ repartition_joins : bool ,
69
+ repartition_aggregations : bool ,
70
+ repartition_windows : bool ,
71
+ parquet_pruning : bool ,
72
+ target_partitions : Option < usize > ,
73
+ // TODO: config_options
74
+ ) -> Self {
75
+ let cfg = SessionConfig :: new ( )
76
+ . create_default_catalog_and_schema ( create_default_catalog_and_schema)
77
+ . with_default_catalog_and_schema ( default_catalog, default_schema)
78
+ . with_information_schema ( information_schema)
79
+ . with_repartition_joins ( repartition_joins)
80
+ . with_repartition_aggregations ( repartition_aggregations)
81
+ . with_repartition_windows ( repartition_windows)
82
+ . with_parquet_pruning ( parquet_pruning) ;
83
+
84
+ let cfg_full = match target_partitions {
85
+ None => cfg,
86
+ Some ( x) => cfg. with_target_partitions ( x) ,
87
+ } ;
88
+
53
89
PySessionContext {
54
- ctx : SessionContext :: new ( ) ,
90
+ ctx : SessionContext :: with_config ( cfg_full ) ,
55
91
}
56
92
}
57
93
0 commit comments