@@ -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 ()}
@@ -197,6 +203,33 @@ def test_python_table_provider(ctx: SessionContext):
197203 assert schema .table_names () == {"table4" }
198204
199205
206+ def test_exception_not_mangled (ctx : SessionContext ):
207+ """Test registering all python providers and running a query against them."""
208+
209+ catalog_name = "custom_catalog"
210+ schema_name = "custom_schema"
211+
212+ ctx .register_catalog_provider (catalog_name , CustomCatalogProvider ())
213+
214+ catalog = ctx .catalog (catalog_name )
215+
216+ # Clean out previous schemas if they exist so we can start clean
217+ for schema_name in catalog .schema_names ():
218+ catalog .deregister_schema (schema_name , cascade = False )
219+
220+ catalog .register_schema (schema_name , CustomErrorSchemaProvider ())
221+
222+ schema = catalog .schema (schema_name )
223+
224+ for table_name in schema .table_names ():
225+ schema .deregister_table (table_name )
226+
227+ schema .register_table ("test_table" , create_dataset ())
228+
229+ with pytest .raises (ValueError , match = "^test_table is not an acceptable name$" ):
230+ ctx .sql (f"select * from { catalog_name } .{ schema_name } .test_table" )
231+
232+
200233def test_schema_register_table_with_pyarrow_dataset (ctx : SessionContext ):
201234 schema = ctx .catalog ().schema ()
202235 batch = pa .RecordBatch .from_arrays (
0 commit comments