@@ -2621,3 +2621,91 @@ def test_load_table_without_storage_credentials(
26212621 )
26222622 assert actual .metadata .model_dump () == expected .metadata .model_dump ()
26232623 assert actual == expected
2624+
2625+
2626+ def test_plan_scan_with_storage_credentials (rest_mock : Mocker , example_table_metadata_with_snapshot_v1 : dict [str , Any ]) -> None :
2627+ metadata_location = "s3://warehouse/database/table/metadata/00001.metadata.json"
2628+ rest_mock .get (
2629+ f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
2630+ json = {
2631+ "metadata-location" : metadata_location ,
2632+ "metadata" : example_table_metadata_with_snapshot_v1 ,
2633+ "config" : {},
2634+ },
2635+ status_code = 200 ,
2636+ request_headers = TEST_HEADERS ,
2637+ )
2638+ rest_mock .post (
2639+ f"{ TEST_URI } v1/namespaces/fokko/tables/table/plan" ,
2640+ json = {
2641+ "status" : "completed" ,
2642+ "file-scan-tasks" : [],
2643+ "delete-files" : [],
2644+ "plan-tasks" : [],
2645+ "storage-credentials" : [
2646+ {
2647+ "prefix" : "s3://warehouse/database/table" ,
2648+ "config" : {
2649+ "s3.access-key-id" : "plan-vended-key" ,
2650+ "s3.secret-access-key" : "plan-vended-secret" ,
2651+ "s3.session-token" : "plan-vended-token" ,
2652+ },
2653+ }
2654+ ],
2655+ },
2656+ status_code = 200 ,
2657+ request_headers = TEST_HEADERS ,
2658+ )
2659+ from pyiceberg .catalog .rest .scan_planning import PlanTableScanRequest
2660+
2661+ catalog = RestCatalog ("rest" , uri = TEST_URI , token = TEST_TOKEN , ** {"rest-scan-planning-enabled" : "true" })
2662+ tasks , credential_config = catalog ._plan_scan_for_table (
2663+ ("fokko" , "table" ),
2664+ PlanTableScanRequest (),
2665+ table_location = "s3://warehouse/database/table" ,
2666+ )
2667+
2668+ assert tasks == []
2669+ assert credential_config == {
2670+ "s3.access-key-id" : "plan-vended-key" ,
2671+ "s3.secret-access-key" : "plan-vended-secret" ,
2672+ "s3.session-token" : "plan-vended-token" ,
2673+ }
2674+
2675+
2676+ def test_plan_scan_without_storage_credentials (
2677+ rest_mock : Mocker , example_table_metadata_with_snapshot_v1 : dict [str , Any ]
2678+ ) -> None :
2679+ metadata_location = "s3://warehouse/database/table/metadata/00001.metadata.json"
2680+ rest_mock .get (
2681+ f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
2682+ json = {
2683+ "metadata-location" : metadata_location ,
2684+ "metadata" : example_table_metadata_with_snapshot_v1 ,
2685+ "config" : {},
2686+ },
2687+ status_code = 200 ,
2688+ request_headers = TEST_HEADERS ,
2689+ )
2690+ rest_mock .post (
2691+ f"{ TEST_URI } v1/namespaces/fokko/tables/table/plan" ,
2692+ json = {
2693+ "status" : "completed" ,
2694+ "file-scan-tasks" : [],
2695+ "delete-files" : [],
2696+ "plan-tasks" : [],
2697+ },
2698+ status_code = 200 ,
2699+ request_headers = TEST_HEADERS ,
2700+ )
2701+ from pyiceberg .catalog .rest .scan_planning import PlanTableScanRequest
2702+
2703+ catalog = RestCatalog ("rest" , uri = TEST_URI , token = TEST_TOKEN , ** {"rest-scan-planning-enabled" : "true" })
2704+ tasks , credential_config = catalog ._plan_scan_for_table (
2705+ ("fokko" , "table" ),
2706+ PlanTableScanRequest (),
2707+ table_location = "s3://warehouse/database/table" ,
2708+ )
2709+
2710+ assert tasks == []
2711+ assert credential_config == {}
0 commit comments