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

Fix creating empty non-bucketed Hive partition #12204

Merged
merged 1 commit into from
Jan 31, 2019

Conversation

wenleix
Copy link
Contributor

@wenleix wenleix commented Jan 9, 2019

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

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.
@wenleix
Copy link
Contributor Author

wenleix commented Jan 30, 2019

Blocked #11376

Copy link
Contributor

@shixuan-fan shixuan-fan left a 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";
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@wenleix wenleix Jan 31, 2019

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

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

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.

Copy link
Contributor

@jessesleeping jessesleeping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

electrum pushed a commit to electrum/trino that referenced this pull request Jan 30, 2019
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
@wenleix wenleix merged commit e81d1d6 into prestodb:master Jan 31, 2019
@wenleix wenleix deleted the fix-empty-partition branch January 31, 2019 04:46
electrum pushed a commit to trinodb/trino that referenced this pull request Jan 31, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants