@@ -296,7 +296,7 @@ impl PySQLOptions {
296
296
/// `PySessionContext` is able to plan and execute DataFusion plans.
297
297
/// It has a powerful optimizer, a physical planner for local execution, and a
298
298
/// multi-threaded execution engine to perform the execution.
299
- #[ pyclass( name = "SessionContext" , module = "datafusion" , subclass) ]
299
+ #[ pyclass( frozen , name = "SessionContext" , module = "datafusion" , subclass) ]
300
300
#[ derive( Clone ) ]
301
301
pub struct PySessionContext {
302
302
pub ctx : SessionContext ,
@@ -348,7 +348,7 @@ impl PySessionContext {
348
348
/// Register an object store with the given name
349
349
#[ pyo3( signature = ( scheme, store, host=None ) ) ]
350
350
pub fn register_object_store (
351
- & mut self ,
351
+ & self ,
352
352
scheme : & str ,
353
353
store : StorageContexts ,
354
354
host : Option < & str > ,
@@ -380,7 +380,7 @@ impl PySessionContext {
380
380
schema=None ,
381
381
file_sort_order=None ) ) ]
382
382
pub fn register_listing_table (
383
- & mut self ,
383
+ & self ,
384
384
name : & str ,
385
385
path : & str ,
386
386
table_partition_cols : Vec < ( String , PyArrowType < DataType > ) > ,
@@ -426,22 +426,22 @@ impl PySessionContext {
426
426
Ok ( ( ) )
427
427
}
428
428
429
- pub fn register_udtf ( & mut self , func : PyTableFunction ) {
429
+ pub fn register_udtf ( & self , func : PyTableFunction ) {
430
430
let name = func. name . clone ( ) ;
431
431
let func = Arc :: new ( func) ;
432
432
self . ctx . register_udtf ( & name, func) ;
433
433
}
434
434
435
435
/// Returns a PyDataFrame whose plan corresponds to the SQL statement.
436
- pub fn sql ( & mut self , query : & str , py : Python ) -> PyDataFusionResult < PyDataFrame > {
436
+ pub fn sql ( & self , query : & str , py : Python ) -> PyDataFusionResult < PyDataFrame > {
437
437
let result = self . ctx . sql ( query) ;
438
438
let df = wait_for_future ( py, result) ??;
439
439
Ok ( PyDataFrame :: new ( df) )
440
440
}
441
441
442
442
#[ pyo3( signature = ( query, options=None ) ) ]
443
443
pub fn sql_with_options (
444
- & mut self ,
444
+ & self ,
445
445
query : & str ,
446
446
options : Option < PySQLOptions > ,
447
447
py : Python ,
@@ -458,7 +458,7 @@ impl PySessionContext {
458
458
459
459
#[ pyo3( signature = ( partitions, name=None , schema=None ) ) ]
460
460
pub fn create_dataframe (
461
- & mut self ,
461
+ & self ,
462
462
partitions : PyArrowType < Vec < Vec < RecordBatch > > > ,
463
463
name : Option < & str > ,
464
464
schema : Option < PyArrowType < Schema > > ,
@@ -493,14 +493,14 @@ impl PySessionContext {
493
493
}
494
494
495
495
/// Create a DataFrame from an existing logical plan
496
- pub fn create_dataframe_from_logical_plan ( & mut self , plan : PyLogicalPlan ) -> PyDataFrame {
496
+ pub fn create_dataframe_from_logical_plan ( & self , plan : PyLogicalPlan ) -> PyDataFrame {
497
497
PyDataFrame :: new ( DataFrame :: new ( self . ctx . state ( ) , plan. plan . as_ref ( ) . clone ( ) ) )
498
498
}
499
499
500
500
/// Construct datafusion dataframe from Python list
501
501
#[ pyo3( signature = ( data, name=None ) ) ]
502
502
pub fn from_pylist (
503
- & mut self ,
503
+ & self ,
504
504
data : Bound < ' _ , PyList > ,
505
505
name : Option < & str > ,
506
506
) -> PyResult < PyDataFrame > {
@@ -520,7 +520,7 @@ impl PySessionContext {
520
520
/// Construct datafusion dataframe from Python dictionary
521
521
#[ pyo3( signature = ( data, name=None ) ) ]
522
522
pub fn from_pydict (
523
- & mut self ,
523
+ & self ,
524
524
data : Bound < ' _ , PyDict > ,
525
525
name : Option < & str > ,
526
526
) -> PyResult < PyDataFrame > {
@@ -540,7 +540,7 @@ impl PySessionContext {
540
540
/// Construct datafusion dataframe from Arrow Table
541
541
#[ pyo3( signature = ( data, name=None ) ) ]
542
542
pub fn from_arrow (
543
- & mut self ,
543
+ & self ,
544
544
data : Bound < ' _ , PyAny > ,
545
545
name : Option < & str > ,
546
546
py : Python ,
@@ -574,11 +574,7 @@ impl PySessionContext {
574
574
/// Construct datafusion dataframe from pandas
575
575
#[ allow( clippy:: wrong_self_convention) ]
576
576
#[ pyo3( signature = ( data, name=None ) ) ]
577
- pub fn from_pandas (
578
- & mut self ,
579
- data : Bound < ' _ , PyAny > ,
580
- name : Option < & str > ,
581
- ) -> PyResult < PyDataFrame > {
577
+ pub fn from_pandas ( & self , data : Bound < ' _ , PyAny > , name : Option < & str > ) -> PyResult < PyDataFrame > {
582
578
// Obtain GIL token
583
579
let py = data. py ( ) ;
584
580
@@ -594,11 +590,7 @@ impl PySessionContext {
594
590
595
591
/// Construct datafusion dataframe from polars
596
592
#[ pyo3( signature = ( data, name=None ) ) ]
597
- pub fn from_polars (
598
- & mut self ,
599
- data : Bound < ' _ , PyAny > ,
600
- name : Option < & str > ,
601
- ) -> PyResult < PyDataFrame > {
593
+ pub fn from_polars ( & self , data : Bound < ' _ , PyAny > , name : Option < & str > ) -> PyResult < PyDataFrame > {
602
594
// Convert Polars dataframe to Arrow Table
603
595
let table = data. call_method0 ( "to_arrow" ) ?;
604
596
@@ -607,18 +599,18 @@ impl PySessionContext {
607
599
Ok ( df)
608
600
}
609
601
610
- pub fn register_table ( & mut self , name : & str , table : & PyTable ) -> PyDataFusionResult < ( ) > {
602
+ pub fn register_table ( & self , name : & str , table : & PyTable ) -> PyDataFusionResult < ( ) > {
611
603
self . ctx . register_table ( name, table. table ( ) ) ?;
612
604
Ok ( ( ) )
613
605
}
614
606
615
- pub fn deregister_table ( & mut self , name : & str ) -> PyDataFusionResult < ( ) > {
607
+ pub fn deregister_table ( & self , name : & str ) -> PyDataFusionResult < ( ) > {
616
608
self . ctx . deregister_table ( name) ?;
617
609
Ok ( ( ) )
618
610
}
619
611
620
612
pub fn register_catalog_provider (
621
- & mut self ,
613
+ & self ,
622
614
name : & str ,
623
615
provider : Bound < ' _ , PyAny > ,
624
616
) -> PyDataFusionResult < ( ) > {
@@ -647,7 +639,7 @@ impl PySessionContext {
647
639
648
640
/// Construct datafusion dataframe from Arrow Table
649
641
pub fn register_table_provider (
650
- & mut self ,
642
+ & self ,
651
643
name : & str ,
652
644
provider : Bound < ' _ , PyAny > ,
653
645
) -> PyDataFusionResult < ( ) > {
@@ -671,7 +663,7 @@ impl PySessionContext {
671
663
}
672
664
673
665
pub fn register_record_batches (
674
- & mut self ,
666
+ & self ,
675
667
name : & str ,
676
668
partitions : PyArrowType < Vec < Vec < RecordBatch > > > ,
677
669
) -> PyDataFusionResult < ( ) > {
@@ -689,7 +681,7 @@ impl PySessionContext {
689
681
schema=None ,
690
682
file_sort_order=None ) ) ]
691
683
pub fn register_parquet (
692
- & mut self ,
684
+ & self ,
693
685
name : & str ,
694
686
path : & str ,
695
687
table_partition_cols : Vec < ( String , PyArrowType < DataType > ) > ,
@@ -732,7 +724,7 @@ impl PySessionContext {
732
724
file_extension=".csv" ,
733
725
file_compression_type=None ) ) ]
734
726
pub fn register_csv (
735
- & mut self ,
727
+ & self ,
736
728
name : & str ,
737
729
path : & Bound < ' _ , PyAny > ,
738
730
schema : Option < PyArrowType < Schema > > ,
@@ -780,7 +772,7 @@ impl PySessionContext {
780
772
table_partition_cols=vec![ ] ,
781
773
file_compression_type=None ) ) ]
782
774
pub fn register_json (
783
- & mut self ,
775
+ & self ,
784
776
name : & str ,
785
777
path : PathBuf ,
786
778
schema : Option < PyArrowType < Schema > > ,
@@ -819,7 +811,7 @@ impl PySessionContext {
819
811
file_extension=".avro" ,
820
812
table_partition_cols=vec![ ] ) ) ]
821
813
pub fn register_avro (
822
- & mut self ,
814
+ & self ,
823
815
name : & str ,
824
816
path : PathBuf ,
825
817
schema : Option < PyArrowType < Schema > > ,
@@ -860,17 +852,17 @@ impl PySessionContext {
860
852
Ok ( ( ) )
861
853
}
862
854
863
- pub fn register_udf ( & mut self , udf : PyScalarUDF ) -> PyResult < ( ) > {
855
+ pub fn register_udf ( & self , udf : PyScalarUDF ) -> PyResult < ( ) > {
864
856
self . ctx . register_udf ( udf. function ) ;
865
857
Ok ( ( ) )
866
858
}
867
859
868
- pub fn register_udaf ( & mut self , udaf : PyAggregateUDF ) -> PyResult < ( ) > {
860
+ pub fn register_udaf ( & self , udaf : PyAggregateUDF ) -> PyResult < ( ) > {
869
861
self . ctx . register_udaf ( udaf. function ) ;
870
862
Ok ( ( ) )
871
863
}
872
864
873
- pub fn register_udwf ( & mut self , udwf : PyWindowUDF ) -> PyResult < ( ) > {
865
+ pub fn register_udwf ( & self , udwf : PyWindowUDF ) -> PyResult < ( ) > {
874
866
self . ctx . register_udwf ( udwf. function ) ;
875
867
Ok ( ( ) )
876
868
}
@@ -942,7 +934,7 @@ impl PySessionContext {
942
934
#[ allow( clippy:: too_many_arguments) ]
943
935
#[ pyo3( signature = ( path, schema=None , schema_infer_max_records=1000 , file_extension=".json" , table_partition_cols=vec![ ] , file_compression_type=None ) ) ]
944
936
pub fn read_json (
945
- & mut self ,
937
+ & self ,
946
938
path : PathBuf ,
947
939
schema : Option < PyArrowType < Schema > > ,
948
940
schema_infer_max_records : usize ,
0 commit comments