@@ -255,36 +255,13 @@ def test_get_objects_schema(
255255 ]
256256 assert schemas == []
257257
258- def test_get_objects_table (
259- self , conn : adbc_driver_manager .dbapi .Connection , driver : model .DriverQuirks
258+ def test_get_objects_table_not_exist (
259+ self ,
260+ conn : adbc_driver_manager .dbapi .Connection ,
261+ driver : model .DriverQuirks ,
260262 ) -> None :
261- table_name = "getobjectstest"
262- schema = pyarrow .schema (
263- [
264- ("ints" , pyarrow .int32 ()),
265- ("strs" , pyarrow .string ()),
266- ]
267- )
268- data = pyarrow .Table .from_pydict (
269- {
270- "ints" : [1 , None , 42 ],
271- "strs" : [None , "foo" , "spam" ],
272- },
273- schema = schema ,
274- )
275- table_id = (
276- driver .features .current_catalog ,
277- driver .features .current_schema ,
278- table_name ,
279- )
280- with conn .cursor () as cursor :
281- try :
282- cursor .execute (driver .drop_table (table_name = table_name ))
283- except adbc_driver_manager .Error as e :
284- # Some databases have no way to do DROP IF EXISTS
285- if not driver .is_table_not_found (table_name = None , error = e ):
286- raise
287-
263+ # N.B. table tests are split up so we can more easily override/disable
264+ # parts of it
288265 objects = conn .adbc_get_objects (depth = "tables" ).read_all ().to_pylist ()
289266 tables = [
290267 (obj ["catalog_name" ], schema ["db_schema_name" ], table ["table_name" ])
@@ -295,10 +272,20 @@ def test_get_objects_table(
295272 for catalog , schema , table in tables :
296273 assert table != ""
297274 assert list (sorted (set (tables ))) == list (sorted (tables ))
275+ table_id = (
276+ driver .features .current_catalog ,
277+ driver .features .current_schema ,
278+ "getobjectstest2" ,
279+ )
298280 assert table_id not in tables
299281
300- with conn .cursor () as cursor :
301- cursor .adbc_ingest (table_name , data )
282+ def test_get_objects_table_present (
283+ self ,
284+ conn : adbc_driver_manager .dbapi .Connection ,
285+ driver : model .DriverQuirks ,
286+ get_objects_table ,
287+ ) -> None :
288+ table_id = get_objects_table
302289
303290 objects = conn .adbc_get_objects (depth = "tables" ).read_all ().to_pylist ()
304291 tables = [
@@ -310,6 +297,13 @@ def test_get_objects_table(
310297 assert list (sorted (set (tables ))) == list (sorted (tables ))
311298 assert table_id in tables
312299
300+ def test_get_objects_table_invalid_catalog (
301+ self ,
302+ conn : adbc_driver_manager .dbapi .Connection ,
303+ driver : model .DriverQuirks ,
304+ get_objects_table ,
305+ ) -> None :
306+ table_id = get_objects_table
313307 objects = (
314308 conn .adbc_get_objects (
315309 depth = "tables" , catalog_filter = "thiscatalogdoesnotexist"
@@ -326,6 +320,13 @@ def test_get_objects_table(
326320 assert list (sorted (set (tables ))) == list (sorted (tables ))
327321 assert table_id not in tables
328322
323+ def test_get_objects_table_invalid_schema (
324+ self ,
325+ conn : adbc_driver_manager .dbapi .Connection ,
326+ driver : model .DriverQuirks ,
327+ get_objects_table ,
328+ ) -> None :
329+ table_id = get_objects_table
329330 objects = (
330331 conn .adbc_get_objects (
331332 depth = "tables" , db_schema_filter = "thiscatalogdoesnotexist"
@@ -342,6 +343,13 @@ def test_get_objects_table(
342343 assert list (sorted (set (tables ))) == list (sorted (tables ))
343344 assert table_id not in tables
344345
346+ def test_get_objects_table_invalid_table (
347+ self ,
348+ conn : adbc_driver_manager .dbapi .Connection ,
349+ driver : model .DriverQuirks ,
350+ get_objects_table ,
351+ ) -> None :
352+ table_id = get_objects_table
345353 objects = (
346354 conn .adbc_get_objects (
347355 depth = "tables" , table_name_filter = "thiscatalogdoesnotexist"
@@ -358,8 +366,15 @@ def test_get_objects_table(
358366 assert list (sorted (set (tables ))) == list (sorted (tables ))
359367 assert table_id not in tables
360368
369+ def test_get_objects_table_exact_table (
370+ self ,
371+ conn : adbc_driver_manager .dbapi .Connection ,
372+ driver : model .DriverQuirks ,
373+ get_objects_table ,
374+ ) -> None :
375+ table_id = get_objects_table
361376 objects = (
362- conn .adbc_get_objects (depth = "tables" , table_name_filter = table_name )
377+ conn .adbc_get_objects (depth = "tables" , table_name_filter = table_id [ 2 ] )
363378 .read_all ()
364379 .to_pylist ()
365380 )
@@ -634,6 +649,52 @@ def test_get_objects_column_xdbc(
634649 elif field == "xdbc_is_nullable" :
635650 assert column [field ] == "YES"
636651
652+ @pytest .fixture (scope = "class" )
653+ def get_objects_table (
654+ self ,
655+ driver : model .DriverQuirks ,
656+ conn : adbc_driver_manager .dbapi .Connection ,
657+ ):
658+ with conn .cursor () as cursor :
659+ table_name = "getobjectstest"
660+ schema = pyarrow .schema (
661+ [
662+ ("ints" , pyarrow .int32 ()),
663+ ("strs" , pyarrow .string ()),
664+ ]
665+ )
666+ data = pyarrow .Table .from_pydict (
667+ {
668+ "ints" : [1 , None , 42 ],
669+ "strs" : [None , "foo" , "spam" ],
670+ },
671+ schema = schema ,
672+ )
673+ table_id = (
674+ driver .features .current_catalog ,
675+ driver .features .current_schema ,
676+ table_name ,
677+ )
678+ with conn .cursor () as cursor :
679+ try :
680+ cursor .execute (driver .drop_table (table_name = table_name ))
681+ except adbc_driver_manager .Error as e :
682+ # Some databases have no way to do DROP IF EXISTS
683+ if not driver .is_table_not_found (table_name = None , error = e ):
684+ raise
685+
686+ cursor .adbc_ingest (table_name , data )
687+
688+ yield table_id
689+
690+ with conn .cursor () as cursor :
691+ try :
692+ cursor .execute (driver .drop_table (table_name = table_name ))
693+ except adbc_driver_manager .Error as e :
694+ # Some databases have no way to do DROP IF EXISTS
695+ if not driver .is_table_not_found (table_name = None , error = e ):
696+ raise
697+
637698 @pytest .fixture (scope = "class" )
638699 def get_objects_constraints (
639700 self ,
0 commit comments