Skip to content

RFC: rename if not exists#7818

Merged
Xuanwo merged 12 commits into
apache:mainfrom
hfutatzhanghb:codex/rfc-rename-if-not-exists
Jun 25, 2026
Merged

RFC: rename if not exists#7818
Xuanwo merged 12 commits into
apache:mainfrom
hfutatzhanghb:codex/rfc-rename-if-not-exists

Conversation

@hfutatzhanghb

@hfutatzhanghb hfutatzhanghb commented Jun 24, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

N/A.

Rationale for this change

OpenDAL needs a documented cross-service contract for conditional rename before
extending the public API. The design must align with existing write and copy
options while preserving the atomic destination condition.

What changes are included in this PR?

  • Propose rename_with(...).if_not_exists(true) and RenameOptions.
  • Define AlreadyExists and Unsupported behavior.
  • Define the atomic no-replace capability requirement.
  • Analyze HDFS, FS, S3, and other service implementation boundaries.

Are there any user-facing changes?

No implementation is included in this RFC PR. If accepted, the proposed public
API and capability will be implemented separately.

AI Usage Statement

AI assistance (GPT-5.5 with Codex) was used to prepare this RFC.
Reviewed by GLM-5.2 with Codex

@hfutatzhanghb hfutatzhanghb requested a review from Xuanwo as a code owner June 24, 2026 04:53
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/docs The PR modifies docs related content or has a title that begins with "docs" labels Jun 24, 2026
@hfutatzhanghb hfutatzhanghb force-pushed the codex/rfc-rename-if-not-exists branch from dfdbf69 to 4575406 Compare June 24, 2026 07:01
@hfutatzhanghb

Copy link
Copy Markdown
Member Author

@Xuanwo @erickguan Hi, could you please help review this RFC PR when free? Thanks very much!

@erickguan erickguan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good writing. I added some comments. I also have questions on atomicity.

You will also need Xuanwo's approval :)

Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md Outdated
Comment thread core/core/src/docs/rfcs/7818_rename_if_not_exists.md

### Multi-step overwrite services

`aliyun_drive`, `gdrive`, `goosefs`, and `koofr` currently delete or trash an

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on if we are changing rename to be atomic, say yes. Then we are essentially making these services' rename to be a simulation. Either this is way beyond the scope and we register this problem as a future work. Or we would see a way to address this problem in this RFC. e.g., a capability flag for declaring so? or documentation on atomicity with/without rename_with_if_not_exists.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the answer is neither — this RFC does NOT propose making rename atomic. Multi-step delete+rename is a valid implementation of overwrite, not a "simulation." It genuinely fulfills the contract: the destination ends up with the source content.

The atomicity gate is introduced only for rename_with_if_not_exists because it adds a conditional check that would be meaningless without atomic enforcement. Overwrite rename (the default) has no such check, so no new atomicity requirement.

That said, a capability flag like rename_is_atomic for the base rename operation is a reasonable idea, but it is separate from this RFC. I would prefer keeping this RFC scoped to if_not_exists and filing a follow-up issue for rename atomicity documentation/capability if the maintainers agree it is worth tracking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hfutatzhanghb Is zhb your handle on OpenDAL discord?

hfutatzhanghb and others added 4 commits June 24, 2026 20:35
Co-authored-by: Erick Guan <297343+erickguan@users.noreply.github.com>
Co-authored-by: Erick Guan <297343+erickguan@users.noreply.github.com>
Co-authored-by: Erick Guan <297343+erickguan@users.noreply.github.com>
Co-authored-by: Erick Guan <297343+erickguan@users.noreply.github.com>

@hfutatzhanghb hfutatzhanghb left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zhanghaobo@kanzhun.com added 4 commits June 24, 2026 21:04
Address erickguan's review: explicitly document that RenameOptions is
always constructable, matching the existing write and copy pattern where
the correctness_check layer returns Unsupported when the capability is
not advertised.
Replace ambiguous 'the destination condition' with explicit phrasing:
'destination-does-not-exist check' and
'destination already exists (if_not_exists condition fails)'.

Addresses erickguan's review feedback.
Replace the ambiguous 'the operation' with 'the rename' for clarity.
Addresses erickguan's review feedback.
Add an explicit paragraph explaining that overwrite rename does not
require atomicity (multi-step delete+rename achieves the same result),
while the if_not_exists condition must be checked atomically with the
move. A backend with non-atomic overwrite may still support conditional
rename by skipping the pre-delete and relying on the native conflict
rejection. HDFS is the example.

Addresses erickguan's review feedback about the apparent contradiction
between non-atomic overwrite implementations and the atomicity
requirement for conditional rename.
@erickguan

Copy link
Copy Markdown
Member

This RFC will require a tracking issue once approved :)

@hfutatzhanghb

hfutatzhanghb commented Jun 24, 2026 via email

Copy link
Copy Markdown
Member Author

@erickguan

Copy link
Copy Markdown
Member

@hfutatzhanghb Up to you. I would suggest waiting Xuanwo's review.

@hfutatzhanghb

hfutatzhanghb commented Jun 24, 2026 via email

Copy link
Copy Markdown
Member Author

@hfutatzhanghb

Copy link
Copy Markdown
Member Author

Hi, @Xuanwo please cc when have free time. Thanks very much!

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @hfutatzhanghb for working on this and thank you @erickguan for the review!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 25, 2026
@Xuanwo Xuanwo merged commit 5ebfb5b into apache:main Jun 25, 2026
103 checks passed
@hfutatzhanghb hfutatzhanghb deleted the codex/rfc-rename-if-not-exists branch June 25, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/docs The PR modifies docs related content or has a title that begins with "docs" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants