feat(gcs): implement delete for GCS object store#6958
Conversation
Greptile SummaryThis PR implements the
Confidence Score: 5/5The change is narrowly scoped to adding a new delete operation on GCS; existing read/list paths are untouched and the refactored client-construction logic preserves the same behavior for callers of get_client. The idempotency guards correctly cover both the API-level (GError::Response) and transport-level (GError::HttpClient) 404/410 cases, the semaphore and IO-stats wiring match the pattern used by other methods, and the client-config refactor is straightforward. The only finding is a cosmetic dead-code pattern (is_success always true). No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant GCSSource
participant GCSClientWrapper
participant GCSClient as google_cloud_storage Client
Caller->>GCSSource: delete(uri, io_stats)
GCSSource->>GCSClientWrapper: delete(uri, io_stats)
GCSClientWrapper->>GCSClientWrapper: parse_raw_uri(uri)
alt key is empty
GCSClientWrapper-->>Caller: Err(NotAFile)
else key is non-empty
GCSClientWrapper->>GCSClientWrapper: acquire semaphore permit
GCSClientWrapper->>GCSClient: delete_object(bucket, key)
alt Ok(())
GCSClient-->>GCSClientWrapper: Ok(())
GCSClientWrapper->>GCSClientWrapper: mark_delete_requests(1)
GCSClientWrapper-->>Caller: Ok(())
else Err — 404 or 410
GCSClient-->>GCSClientWrapper: Err(GError::Response 404/410 OR HttpClient 404/410)
GCSClientWrapper->>GCSClientWrapper: is_delete_idempotent_error → true
GCSClientWrapper->>GCSClientWrapper: mark_delete_requests(1)
GCSClientWrapper-->>Caller: Ok(())
else Err — other error
GCSClient-->>GCSClientWrapper: Err(other)
GCSClientWrapper->>GCSClientWrapper: is_delete_idempotent_error → false
GCSClientWrapper-->>Caller: Err(UnableToDeleteFile → super::Error)
end
end
Reviews (2): Last reviewed commit: "test(gcs): add delete and overwrite regr..." | Re-trigger Greptile |
c056856 to
3178914
Compare
## Summary - Implements `delete` method for the GCS object store backend (`GCSSource`) - Fixes `write_parquet(write_mode='overwrite')` on GCS paths (closes Eventual-Inc#6928) ## Changes - Adds `UnableToDeleteFile` error variant to the GCS error enum - Implements `delete` on `GCSClientWrapper` using `google_cloud_storage`'s `delete_object` API - Handles 404/410 responses as success (idempotent delete per `ObjectSource` trait contract) - Overrides `delete` in `ObjectSource` impl for `GCSSource` ## Test plan - Verify `write_parquet(write_mode="overwrite")` succeeds on a `gs://` path - Verify delete is idempotent (overwriting a non-existent path does not fail) - `make build` passes - `DAFT_RUNNER=native make test EXTRA_ARGS="-v tests/io/"` passes Author: daiping8 <dai.ping88@zte.com.cn>
3178914 to
b7e5386
Compare
|
@daiping8 is this ready for review or are you still working on it? |
22b5560 to
2cca089
Compare
Sorry for the late reply. I've added a commit with test code and have tested the PR as thoroughly as possible. The PR now includes two commits: one for the implementation and one for the tests. Please review, thank you. |
Summary
deletemethod for the GCS object store backend (GCSSource)write_parquet(write_mode='overwrite')on GCS paths (closeswrite_parquet(write_mode='overwrite')on GCS fails withMethod not implemented: Deletes is not yet supported!#6928)Changes
UnableToDeleteFileerror variant to the GCS error enumdeleteonGCSClientWrapperusinggoogle_cloud_storage'sdelete_objectAPIObjectSourcetrait contract)deleteinObjectSourceimpl forGCSSourceTest plan
write_parquet(write_mode="overwrite")succeeds on ags://pathmake buildpassesDAFT_RUNNER=native make test EXTRA_ARGS="-v tests/io/"passes