@@ -41,14 +41,12 @@ use crate::record_batch::PyRecordBatchStream;
4141use crate :: sql:: exceptions:: py_value_err;
4242use crate :: sql:: logical:: PyLogicalPlan ;
4343use crate :: store:: StorageContexts ;
44- use crate :: table:: PyTableProvider ;
4544use crate :: udaf:: PyAggregateUDF ;
4645use crate :: udf:: PyScalarUDF ;
4746use crate :: udtf:: PyTableFunction ;
4847use crate :: udwf:: PyWindowUDF ;
4948use crate :: utils:: {
50- get_global_ctx, get_tokio_runtime, table_provider_from_pycapsule, validate_pycapsule,
51- wait_for_future, EXPECTED_PROVIDER_MSG ,
49+ extract_table_provider, get_global_ctx, get_tokio_runtime, validate_pycapsule, wait_for_future,
5250} ;
5351use datafusion:: arrow:: datatypes:: { DataType , Schema , SchemaRef } ;
5452use datafusion:: arrow:: pyarrow:: PyArrowType ;
@@ -610,17 +608,7 @@ impl PySessionContext {
610608 name : & str ,
611609 table_provider : Bound < ' _ , PyAny > ,
612610 ) -> PyDataFusionResult < ( ) > {
613- let provider = if let Ok ( py_table) = table_provider. extract :: < PyTable > ( ) {
614- py_table. table ( )
615- } else if let Ok ( py_provider) = table_provider. extract :: < PyTableProvider > ( ) {
616- py_provider. into_inner ( )
617- } else if let Some ( provider) = table_provider_from_pycapsule ( & table_provider) ? {
618- provider
619- } else {
620- return Err ( crate :: errors:: PyDataFusionError :: Common (
621- EXPECTED_PROVIDER_MSG . to_string ( ) ,
622- ) ) ;
623- } ;
611+ let provider = extract_table_provider ( & table_provider) ?;
624612
625613 self . ctx . register_table ( name, provider) ?;
626614 Ok ( ( ) )
0 commit comments