@@ -81,6 +81,12 @@ def table_exist(self, name: str) -> bool:
8181 return name in self .tables
8282
8383
84+ class CustomErrorSchemaProvider (CustomSchemaProvider ):
85+ def table (self , name : str ) -> Table | None :
86+ message = f"{ name } is not an acceptable name"
87+ raise ValueError (message )
88+
89+
8490class CustomCatalogProvider (dfn .catalog .CatalogProvider ):
8591 def __init__ (self ):
8692 self .schemas = {"my_schema" : CustomSchemaProvider ()}
@@ -219,6 +225,33 @@ def test_schema_register_table_with_pyarrow_dataset(ctx: SessionContext):
219225 schema .deregister_table (table_name )
220226
221227
228+ def test_exception_not_mangled (ctx : SessionContext ):
229+ """Test registering all python providers and running a query against them."""
230+
231+ catalog_name = "custom_catalog"
232+ schema_name = "custom_schema"
233+
234+ ctx .register_catalog_provider (catalog_name , CustomCatalogProvider ())
235+
236+ catalog = ctx .catalog (catalog_name )
237+
238+ # Clean out previous schemas if they exist so we can start clean
239+ for schema_name in catalog .schema_names ():
240+ catalog .deregister_schema (schema_name , cascade = False )
241+
242+ catalog .register_schema (schema_name , CustomErrorSchemaProvider ())
243+
244+ schema = catalog .schema (schema_name )
245+
246+ for table_name in schema .table_names ():
247+ schema .deregister_table (table_name )
248+
249+ schema .register_table ("test_table" , create_dataset ())
250+
251+ with pytest .raises (ValueError , match = "^test_table is not an acceptable name$" ):
252+ ctx .sql (f"select * from { catalog_name } .{ schema_name } .test_table" )
253+
254+
222255def test_in_end_to_end_python_providers (ctx : SessionContext ):
223256 """Test registering all python providers and running a query against them."""
224257
0 commit comments