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