Skip to content

Commit

Permalink
[BugFix] Fix cannot insert into overwrite a hive partition when files…
Browse files Browse the repository at this point in the history
… are written by hive (#53792)

Signed-off-by: Jiao Mingye <[email protected]>
  • Loading branch information
mxdzs0612 authored Dec 12, 2024
1 parent 66b78c4 commit 6c70844
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ public static String getStagingDir(HiveTable table, String tempStagingDir) {
}

public static boolean fileCreatedByQuery(String fileName, String queryId) {
Preconditions.checkState(fileName.length() > queryId.length() && queryId.length() > 8,
"file name or query id is invalid");
Preconditions.checkState(queryId.length() > 8, "file name or query id is invalid");
if (fileName.length() <= queryId.length()) {
// file is created by other engine like hive
return false;
}
String checkQueryId = queryId.substring(0, queryId.length() - 8);
return fileName.startsWith(checkQueryId) || fileName.endsWith(checkQueryId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ public FileSystem get(URI uri, Configuration conf) {
"Failed to create directory",
() -> HiveWriteUtils.createDirectory(path, new Configuration()));
}

@Test
public void testFileCreateByQuery() {
Assert.assertFalse(HiveWriteUtils.fileCreatedByQuery("000000_0", "aaaa-bbbb"));
}
}

0 comments on commit 6c70844

Please sign in to comment.