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 non-bucketed empty partition #12119

Closed

Conversation

jessesleeping
Copy link
Contributor

Fix a bug where creating empty parition using CALL statement
throws exceptions when using file based metastore implementation.

#12002

Fix a bug where creating empty parition using CALL statement
throws exceptions when using file based metastore implementation.
@@ -1220,6 +1220,13 @@ public HiveInsertTableHandle beginInsert(ConnectorSession session, ConnectorTabl
Map<List<String>, ComputedStatistics> partitionComputedStatistics = createComputedStatisticsToPartitionMap(computedStatistics, partitionedBy, columnTypes);

for (PartitionUpdate partitionUpdate : partitionUpdates) {
if (partitionUpdate.getFileNames().size() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use isEmpty()

@@ -1220,6 +1220,13 @@ public HiveInsertTableHandle beginInsert(ConnectorSession session, ConnectorTabl
Map<List<String>, ComputedStatistics> partitionComputedStatistics = createComputedStatisticsToPartitionMap(computedStatistics, partitionedBy, columnTypes);

for (PartitionUpdate partitionUpdate : partitionUpdates) {
if (partitionUpdate.getFileNames().size() == 0) {
HiveWriteUtils.createDirectory(
Copy link
Contributor

Choose a reason for hiding this comment

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

Static import

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think creating the directory here is there correct place. We should be doing it in SemiTransactionalHiveMetastore as part of the commit. We probably also need to handle it in the rollback cleaup. @haozhun should take a look

" FORMAT = 'ORC', " +
" partitioned_by = ARRAY['p_varchar'] " +
") " +
"AS " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Creating an empty table should be sufficient. We should be able to create a new table and then add an empty partition. Is there a reason why another partition was needed, or something you wanted test?

assertUpdate(format("" +
"CREATE TABLE %s " +
"WITH ( " +
" FORMAT = 'ORC', " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: lowercase the name format and use consistent indentation with the other property (two spaces)

@wenleix
Copy link
Contributor

wenleix commented Jan 9, 2019

Superseded by #12204

@wenleix wenleix closed this Jan 31, 2019
@jessesleeping jessesleeping deleted the fix-empty-partition branch June 5, 2019 18:30
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.

4 participants