@@ -162,3 +162,51 @@ def test_python_table_provider(ctx: SessionContext):
162162 schema .deregister_table ("table3" )
163163 schema .register_table ("table4" , create_dataset ())
164164 assert schema .table_names () == {"table4" }
165+
166+
167+ def test_in_end_to_end_python_providers (ctx : SessionContext ):
168+ """Test registering all python providers and running a query against them."""
169+
170+ all_catalog_names = [
171+ "datafusion" ,
172+ "custom_catalog" ,
173+ "in_mem_catalog" ,
174+ ]
175+
176+ all_schema_names = [
177+ "custom_schema" ,
178+ "in_mem_schema" ,
179+ ]
180+
181+ ctx .register_catalog_provider (all_catalog_names [1 ], CustomCatalogProvider ())
182+ ctx .register_catalog_provider (
183+ all_catalog_names [2 ], dfn .catalog .Catalog .memory_catalog ()
184+ )
185+
186+ for catalog_name in all_catalog_names :
187+ catalog = ctx .catalog (catalog_name )
188+
189+ # Clean out previous schemas if they exist so we can start clean
190+ for schema_name in catalog .schema_names ():
191+ catalog .deregister_schema (schema_name , cascade = False )
192+
193+ catalog .register_schema (all_schema_names [0 ], CustomSchemaProvider ())
194+ catalog .register_schema (all_schema_names [1 ], dfn .catalog .Schema .memory_schema ())
195+
196+ for schema_name in all_schema_names :
197+ schema = catalog .schema (schema_name )
198+
199+ for table_name in schema .table_names ():
200+ schema .deregister_table (table_name )
201+
202+ schema .register_table ("test_table" , create_dataset ())
203+
204+ for catalog_name in all_catalog_names :
205+ for schema_name in all_schema_names :
206+ table_full_name = f"{ catalog_name } .{ schema_name } .test_table"
207+
208+ batches = ctx .sql (f"select * from { table_full_name } " ).collect ()
209+
210+ assert len (batches ) == 1
211+ assert batches [0 ].column (0 ) == pa .array ([1 , 2 , 3 ])
212+ assert batches [0 ].column (1 ) == pa .array ([4 , 5 , 6 ])
0 commit comments