@@ -50,7 +50,6 @@ def generate_tests(
5050 driver_param = f"{ quirks .name } :{ quirks .short_version } "
5151 enabled = {
5252 "test_not_null" : quirks .features .statement_bulk_ingest ,
53- "test_temporary" : quirks .features .statement_bulk_ingest_temporary ,
5453 "test_schema" : quirks .features .statement_bulk_ingest_schema ,
5554 "test_catalog" : quirks .features .statement_bulk_ingest_catalog ,
5655 "test_many_columns" : quirks .features .statement_bulk_ingest ,
@@ -70,6 +69,7 @@ def generate_tests(
7069 enabled = {
7170 "test_replace_catalog" : quirks .features .statement_bulk_ingest_catalog ,
7271 "test_replace_schema" : quirks .features .statement_bulk_ingest_schema ,
72+ "test_temporary" : quirks .features .statement_bulk_ingest_temporary ,
7373 }.get (metafunc .definition .name , None )
7474 for query in quirks .query_set .queries .values ():
7575 marks = []
@@ -422,51 +422,69 @@ def test_temporary(
422422 self ,
423423 driver : model .DriverQuirks ,
424424 conn_factory : typing .Callable [[], adbc_driver_manager .dbapi .Connection ],
425+ query : Query ,
425426 ) -> None :
426- data1 = pyarrow .Table .from_pydict (
427- {
428- "idx" : [1 , 2 , 3 ],
429- "value" : ["foo" , "bar" , "baz" ],
430- }
431- )
432- data2 = pyarrow .Table .from_pydict (
433- {
434- "idx" : [4 , 5 , 6 ],
435- "value" : ["qux" , "quux" , "spam" ],
436- }
437- )
427+ subquery = query .query
428+ assert isinstance (subquery , model .IngestQuery )
429+ data = subquery .input ()
430+ expected = subquery .expected ()
431+
438432 table_name = "test_ingest_temporary"
439433
440434 idx = driver .quote_identifier ("idx" )
441435 value = driver .quote_identifier ("value" )
442-
443- with conn_factory () as conn :
444- with conn .cursor () as cursor :
445- driver .try_drop_table (cursor , table_name = table_name )
446- cursor .adbc_ingest (table_name , data1 , temporary = True )
447- cursor .adbc_ingest (table_name , data2 , temporary = False )
448-
449- with conn .cursor () as cursor :
450- assert driver .features .current_schema is not None
451- normal_table = driver .quote_identifier (
452- driver .features .current_schema , table_name
453- )
454- temp_table = driver .qualify_temp_table (cursor , table_name )
455- select_normal = (
456- f"SELECT { idx } , { value } FROM { normal_table } ORDER BY { idx } ASC"
457- )
458- select_temporary = (
459- f"SELECT { idx } , { value } FROM { temp_table } ORDER BY { idx } ASC"
460- )
461-
462- result_normal = execute_query_without_prepare (cursor , select_normal )
463-
464- result_temporary = execute_query_without_prepare (
465- cursor , select_temporary
466- )
467-
468- compare .compare_tables (data1 , result_temporary )
469- compare .compare_tables (data2 , result_normal )
436+ if driver .features .quirk_bulk_ingest_temporary_shares_namespace :
437+ with conn_factory () as conn :
438+ with conn .cursor () as cursor :
439+ driver .try_drop_table (cursor , table_name = table_name )
440+ cursor .adbc_ingest (table_name , data , temporary = True )
441+ temp_table = driver .qualify_temp_table (cursor , table_name )
442+ select_temporary = (
443+ f"SELECT { idx } , { value } FROM { temp_table } ORDER BY { idx } ASC"
444+ )
445+ result_temporary = execute_query_without_prepare (
446+ cursor , select_temporary
447+ )
448+ compare .compare_tables (expected , result_temporary )
449+
450+ with conn_factory () as conn :
451+ with conn .cursor () as cursor :
452+ temp_table = driver .qualify_temp_table (cursor , table_name )
453+ select_temporary = (
454+ f"SELECT { idx } , { value } FROM { temp_table } ORDER BY { idx } ASC"
455+ )
456+ with pytest .raises (Exception ) as excinfo :
457+ execute_query_without_prepare (cursor , select_temporary )
458+ assert driver .is_table_not_found (table_name , excinfo .value )
459+ else :
460+ with conn_factory () as conn :
461+ with conn .cursor () as cursor :
462+ driver .try_drop_table (cursor , table_name = table_name )
463+ cursor .adbc_ingest (table_name , data .slice (0 , 1 ), temporary = True )
464+ cursor .adbc_ingest (table_name , data .slice (1 ), temporary = False )
465+
466+ with conn .cursor () as cursor :
467+ assert driver .features .current_schema is not None
468+ normal_table = driver .quote_identifier (
469+ driver .features .current_catalog ,
470+ driver .features .current_schema ,
471+ table_name ,
472+ )
473+ temp_table = driver .qualify_temp_table (cursor , table_name )
474+ select_normal = (
475+ f"SELECT { idx } , { value } FROM { normal_table } ORDER BY { idx } ASC"
476+ )
477+ select_temporary = (
478+ f"SELECT { idx } , { value } FROM { temp_table } ORDER BY { idx } ASC"
479+ )
480+
481+ result_normal = execute_query_without_prepare (cursor , select_normal )
482+ result_temporary = execute_query_without_prepare (
483+ cursor , select_temporary
484+ )
485+
486+ compare .compare_tables (expected .slice (0 , 1 ), result_temporary )
487+ compare .compare_tables (expected .slice (1 ), result_normal )
470488
471489 def test_schema (
472490 self ,
0 commit comments