Skip to content

Commit

Permalink
Merge pull request #1426 from kuzudb/glob-fix
Browse files Browse the repository at this point in the history
Fix copy invalid filepath
  • Loading branch information
acquamarin committed Mar 31, 2023
2 parents 6675cf1 + 2b8241f commit 120410f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/binder/bind/bind_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ std::vector<std::string> Binder::bindFilePaths(const std::vector<std::string>& f
std::vector<std::string> boundFilePaths;
for (auto& filePath : filePaths) {
auto globbedFilePaths = FileUtils::globFilePath(filePath);
if (globbedFilePaths.empty()) {
throw BinderException{StringUtils::string_format(
"No file found that matches the pattern: {}.", filePath)};
}
boundFilePaths.insert(
boundFilePaths.end(), globbedFilePaths.begin(), globbedFilePaths.end());
}
Expand Down
8 changes: 8 additions & 0 deletions test/copy/copy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,11 @@ TEST_F(CopyMultipleFilesTest, CopyFilesWithWildcardPattern) {
->isSuccess());
validateKnowsTableAfterCopying();
}

TEST_F(CopyMultipleFilesTest, CopyFilesWithWrongPath) {
auto result = conn->query(StringUtils::string_format(R"(COPY person FROM ["1.csv", "{}"])",
TestHelper::appendKuzuRootPath("dataset/copy-multiple-files-test/vPerson?.csv")));
ASSERT_FALSE(result->isSuccess());
ASSERT_EQ(result->getErrorMessage(),
"Binder exception: No file found that matches the pattern: 1.csv.");
}

0 comments on commit 120410f

Please sign in to comment.