@@ -76,6 +76,12 @@ def table_exist(self, name: str) -> bool:
7676 return name in self .tables
7777
7878
79+ class CustomErrorSchemaProvider (CustomSchemaProvider ):
80+ def table (self , name : str ) -> Table | None :
81+ message = f"{ name } is not an acceptable name"
82+ raise ValueError (message )
83+
84+
7985class CustomCatalogProvider (dfn .catalog .CatalogProvider ):
8086 def __init__ (self ):
8187 self .schemas = {"my_schema" : CustomSchemaProvider ()}
@@ -164,6 +170,33 @@ def test_python_table_provider(ctx: SessionContext):
164170 assert schema .table_names () == {"table4" }
165171
166172
173+ def test_exception_not_mangled (ctx : SessionContext ):
174+ """Test registering all python providers and running a query against them."""
175+
176+ catalog_name = "custom_catalog"
177+ schema_name = "custom_schema"
178+
179+ ctx .register_catalog_provider (catalog_name , CustomCatalogProvider ())
180+
181+ catalog = ctx .catalog (catalog_name )
182+
183+ # Clean out previous schemas if they exist so we can start clean
184+ for schema_name in catalog .schema_names ():
185+ catalog .deregister_schema (schema_name , cascade = False )
186+
187+ catalog .register_schema (schema_name , CustomErrorSchemaProvider ())
188+
189+ schema = catalog .schema (schema_name )
190+
191+ for table_name in schema .table_names ():
192+ schema .deregister_table (table_name )
193+
194+ schema .register_table ("test_table" , create_dataset ())
195+
196+ with pytest .raises (ValueError , match = "^test_table is not an acceptable name$" ):
197+ ctx .sql (f"select * from { catalog_name } .{ schema_name } .test_table" )
198+
199+
167200def test_in_end_to_end_python_providers (ctx : SessionContext ):
168201 """Test registering all python providers and running a query against them."""
169202
0 commit comments