diff --git a/src/functions/ducklake_cleanup_files.cpp b/src/functions/ducklake_cleanup_files.cpp index 31530efd6f2..d9dac84cbe4 100644 --- a/src/functions/ducklake_cleanup_files.cpp +++ b/src/functions/ducklake_cleanup_files.cpp @@ -131,9 +131,12 @@ void DuckLakeCleanupExecute(ClientContext &context, TableFunctionInput &data_p, if (!state.executed && !data.dry_run) { // delete the files auto &fs = FileSystem::GetFileSystem(context); - for (auto &file : data.files) { - fs.TryRemoveFile(file.path); + vector paths; + paths.reserve(data.files.size()); + for (const auto &file : data.files) { + paths.push_back(file.path); } + fs.RemoveFiles(paths); if (data.type == CleanupType::OLD_FILES) { // If we are removing old files, we need to remove them from the catalog auto &transaction = DuckLakeTransaction::Get(context, data.catalog);