@@ -53,9 +53,7 @@ def generate_tests(
5353 "test_temporary" : quirks .features .statement_bulk_ingest_temporary ,
5454 "test_schema" : quirks .features .statement_bulk_ingest_schema ,
5555 "test_catalog" : quirks .features .statement_bulk_ingest_catalog ,
56- "test_replace_schema" : quirks .features .statement_bulk_ingest_schema ,
5756 "test_many_columns" : quirks .features .statement_bulk_ingest ,
58- "test_replace_catalog" : quirks .features .statement_bulk_ingest_catalog ,
5957 }.get (metafunc .definition .name , None )
6058 if enabled is not None :
6159 marks = []
@@ -69,8 +67,14 @@ def generate_tests(
6967 continue
7068
7169 param_string = "driver,query"
70+ enabled = {
71+ "test_replace_catalog" : quirks .features .statement_bulk_ingest_catalog ,
72+ "test_replace_schema" : quirks .features .statement_bulk_ingest_schema ,
73+ }.get (metafunc .definition .name , None )
7274 for query in quirks .query_set .queries .values ():
7375 marks = []
76+ if enabled is not None and not enabled :
77+ marks .append (pytest .mark .skip (reason = "not implemented" ))
7478 marks .extend (query .pytest_marks )
7579
7680 if not isinstance (query .query , model .IngestQuery ):
@@ -538,27 +542,28 @@ def test_replace_schema(
538542 self ,
539543 driver : model .DriverQuirks ,
540544 conn : adbc_driver_manager .dbapi .Connection ,
545+ query : Query ,
541546 ) -> None :
547+ subquery = query .query
548+ assert isinstance (subquery , model .IngestQuery )
549+ data = subquery .input ()
550+ expected = subquery .expected ()
542551 # Create a table in the default schema
543- default_data = pyarrow .Table .from_pydict (
544- {
545- "idx" : [10 , 20 , 30 ],
546- "value" : ["original" , "default" , "schema" ],
547- }
548- )
552+ default_data = data
549553 # Create different data for the secondary schema
550- data = pyarrow .Table .from_pydict (
551- {
552- "idx" : [1 , 2 , 3 ],
553- "value" : ["foo" , "bar" , "baz" ],
554- }
555- )
554+ data = data .slice (0 , 2 )
556555 data2 = data .slice (0 , 1 )
557556
558557 table_name = "test_ingest_replace_schema"
559558 schema_name = driver .features .secondary_schema
560559 assert schema_name is not None
561560
561+ fields = []
562+ for field in data .schema :
563+ fields .append (driver .quote_identifier (field .name ))
564+ select_default = f"SELECT { ', ' .join (fields )} FROM { driver .quote_identifier (table_name )} ORDER BY { fields [0 ]} ASC"
565+ select_secondary = f"SELECT { ', ' .join (fields )} FROM { driver .quote_identifier (schema_name , table_name )} ORDER BY { fields [0 ]} ASC"
566+
562567 with conn .cursor () as cursor :
563568 # Create table in default schema
564569 driver .try_drop_table (cursor , table_name = table_name )
@@ -591,41 +596,31 @@ def test_replace_schema(
591596 else :
592597 assert modified == - 1
593598
594- idx = driver .quote_identifier ("idx" )
595- value = driver .quote_identifier ("value" )
596-
597599 # Verify secondary schema table has the replaced data
598- select_secondary = f"SELECT { idx } , { value } FROM { driver .quote_identifier (schema_name , table_name )} ORDER BY { idx } ASC"
599600 with conn .cursor () as cursor :
600601 result_secondary = execute_query_without_prepare (cursor , select_secondary )
601- expected_secondary = data .slice (0 , 1 )
602+ expected_secondary = expected .slice (0 , 1 )
602603 compare .compare_tables (expected_secondary , result_secondary )
603604
604605 # Verify default schema table is unchanged
605- select_default = f"SELECT { idx } , { value } FROM { driver .quote_identifier (table_name )} ORDER BY { idx } ASC"
606606 with conn .cursor () as cursor :
607607 result_default = execute_query_without_prepare (cursor , select_default )
608- compare .compare_tables (default_data , result_default )
608+ compare .compare_tables (expected , result_default )
609609
610610 def test_replace_catalog (
611611 self ,
612612 driver : model .DriverQuirks ,
613613 conn : adbc_driver_manager .dbapi .Connection ,
614+ query : Query ,
614615 ) -> None :
615- # Create a table in the default catalog/schema
616- default_data = pyarrow .Table .from_pydict (
617- {
618- "idx" : [10 , 20 , 30 ],
619- "value" : ["original" , "default" , "catalog" ],
620- }
621- )
616+ subquery = query .query
617+ assert isinstance (subquery , model .IngestQuery )
618+ data = subquery .input ()
619+ expected = subquery .expected ()
620+ # Create a table in the default catalog
621+ default_data = data
622622 # Create different data for the secondary catalog
623- data = pyarrow .Table .from_pydict (
624- {
625- "idx" : [1 , 2 , 3 ],
626- "value" : ["foo" , "bar" , "baz" ],
627- }
628- )
623+ data = data .slice (0 , 2 )
629624 data2 = data .slice (0 , 1 )
630625
631626 table_name = "test_ingest_replace_catalog"
@@ -678,14 +673,14 @@ def test_replace_catalog(
678673 select_secondary = f"SELECT { idx } , { value } FROM { driver .quote_identifier (catalog_name , schema_name , table_name )} ORDER BY { idx } ASC"
679674 with conn .cursor () as cursor :
680675 result_secondary = execute_query_without_prepare (cursor , select_secondary )
681- expected_secondary = data .slice (0 , 1 )
676+ expected_secondary = expected .slice (0 , 1 )
682677 compare .compare_tables (expected_secondary , result_secondary )
683678
684679 # Verify default catalog/schema table is unchanged
685680 select_default = f"SELECT { idx } , { value } FROM { driver .quote_identifier (table_name )} ORDER BY { idx } ASC"
686681 with conn .cursor () as cursor :
687682 result_default = execute_query_without_prepare (cursor , select_default )
688- compare .compare_tables (default_data , result_default )
683+ compare .compare_tables (expected , result_default )
689684
690685 def test_create_multiple_batches (
691686 self ,
0 commit comments