Skip to content

fix(io): delete only the named directory in FileIO::delete_dir - #1135

Merged
JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/delete-dir-by-directory-path
Oct 16, 2026
Merged

JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/delete-dir-by-directory-path

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

On a FileSystemCatalog over S3 or OSS, DROP TABLE orders also deletes orders_bak and orders2024, and sys.rename_branch from b1 also deletes b10. On these stores, format-table DROP PARTITION month=1 also removes month=10 to month=12, which stay registered.

FileIO::delete_dir passes the path without a trailing /. OpenDAL then trims a trailing space off the name (dropping t1 deletes t1), and its emulated recursive delete matches every key with that prefix. Java's FileSystemCatalog deletes only that directory.

Fix: build the path with normalize_root, as exists_dir, mkdirs and list_status do. This covers every caller, including drop_branch (#941). The new tests fail on main; the memory backend deletes by prefix as S3 and OSS do.

FileIO::rename trims the same way, but OpenDAL rejects a rename path ending in /, so that needs a separate change.

`delete_dir` passed the directory path to OpenDAL without a trailing
slash, unlike `exists_dir`, `mkdirs` and `list_status`. OpenDAL's path
trim then stripped a trailing space from the name, and a backend without
native recursive delete, such as S3 or OSS, removed every key with that
prefix.

Dropping table `orders` also deleted `orders_bak` and `orders2024`,
and renaming branch `b1` on a backend without native rename also
deleted `b10`. Deleting the `<table>/month=1` path that format-table
DROP PARTITION passes also took `month=10` to `month=12`. On a local
filesystem, dropping table `t1 ` deleted `t1`, and dropping format-table
partition `dt=a ` deleted the directory of `dt=a`.

Normalize the path with `normalize_root`, as the other directory
operations do.
@JingsongLi
JingsongLi merged commit 6ef1faa into apache:main Oct 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants