-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Fix creating empty non-bucketed Hive partition #12204
Conversation
Previously, creating empty non-bucketed Hive partition procedure call does not work when the WriteMode is STAGE_AND_MOVE_TO_TARGET_DIRECTORY, since no file is created and the stage directory will not exist.
0d63a57
to
8534b1d
Compare
Blocked #11376 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Will let @jessesleeping take a look.
@Test | ||
public void testCreateEmptyNonBucketedPartition() | ||
{ | ||
String tableName = "test_insert_empty_partitioned_unbucketed_table"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test the scenario of STAGE_AND_MOVE_TO_TARGET_DIRECTORY
? This might sound noob but I didn't see where the write mode is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't matter. For empty partition, we just need to create an empty directory and we can directly create it as the target path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shixuan-fan : STAGE_AND_MOVE_TO_TARGET_DIRECTORY
is used in open source Hive Connector, unless underlying file system is S3 in which rename is expensive . See
presto/presto-hive/src/main/java/com/facebook/presto/hive/HiveLocationService.java
Lines 63 to 66 in 2eafd86
if (shouldUseTemporaryDirectory(session, context, targetPath)) { | |
Path writePath = createTemporaryPath(session, context, hdfsEnvironment, targetPath); | |
return new LocationHandle(targetPath, writePath, false, STAGE_AND_MOVE_TO_TARGET_DIRECTORY); | |
} |
and
presto/presto-hive/src/main/java/com/facebook/presto/hive/HiveLocationService.java
Lines 87 to 92 in 2eafd86
private boolean shouldUseTemporaryDirectory(ConnectorSession session, HdfsContext context, Path path) | |
{ | |
return isTemporaryStagingDirectoryEnabled(session) | |
// skip using temporary directory for S3 | |
&& !isS3FileSystem(context, hdfsEnvironment, path); | |
} |
The session property hive.temporary-staging-directory-enabled
was added recently by #12199 for S3 filesystem in disguise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Previously, creating empty non-bucketed Hive partition procedure call does not work when the WriteMode is STAGE_AND_MOVE_TO_TARGET_DIRECTORY, since no file is created and the stage directory will not exist. Extracted-From: prestodb/presto#12204
Previously, creating empty non-bucketed Hive partition procedure call does not work when the WriteMode is STAGE_AND_MOVE_TO_TARGET_DIRECTORY, since no file is created and the stage directory will not exist. Extracted-From: prestodb/presto#12204
Previously, creating empty non-bucketed Hive partition procedure call
does not work when the WriteMode is STAGE_AND_MOVE_TO_TARGET_DIRECTORY,
since no file is created and the stage directory will not exist.
Fixes #12002