Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix cannot insert into overwrite a hive partition when files are written by hive (backport #53792) #53870

Open
wants to merge 1 commit into
base: branch-3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[BugFix] Fix cannot insert into overwrite a hive partition when files…
… are written by hive (#53792)

Signed-off-by: Jiao Mingye <mxdzs0612@gmail.com>
(cherry picked from commit 6c70844)
  • Loading branch information
mxdzs0612 authored and mergify[bot] committed Dec 12, 2024
commit 2180f9a63c390b604b7c379f453359310b97a551
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"));
}
}
Loading