-
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 non-bucketed empty partition #12119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1220,6 +1220,13 @@ public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session, | |
Map<List<String>, ComputedStatistics> partitionComputedStatistics = createComputedStatisticsToPartitionMap(computedStatistics, partitionedBy, columnTypes); | ||
|
||
for (PartitionUpdate partitionUpdate : partitionUpdates) { | ||
if (partitionUpdate.getFileNames().size() == 0) { | ||
HiveWriteUtils.createDirectory( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Static import There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
new HdfsContext(session, table.get().getDatabaseName(), table.get().getTableName()), | ||
hdfsEnvironment, | ||
partitionUpdate.getWritePath()); | ||
} | ||
|
||
if (partitionUpdate.getName().isEmpty()) { | ||
// insert into unpartitioned table | ||
metastore.finishInsertIntoExistingTable( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -937,6 +937,30 @@ public void testCastNullToColumnTypes() | |
assertUpdate("DROP TABLE " + tableName); | ||
} | ||
|
||
@Test | ||
public void testCreateEmptyPartition() | ||
{ | ||
String tableName = "empty_partition_table"; | ||
assertUpdate(format("" + | ||
"CREATE TABLE %s " + | ||
"WITH ( " + | ||
" FORMAT = 'ORC', " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: lowercase the name |
||
" partitioned_by = ARRAY['p_varchar'] " + | ||
") " + | ||
"AS " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
"SELECT c_bigint, p_varchar " + | ||
"FROM ( " + | ||
" VALUES " + | ||
" (BIGINT '7', 'longlonglong')" + | ||
") AS x (c_bigint, p_varchar)", tableName), 1); | ||
assertQuery(format("SELECT count(*) FROM \"%s$partitions\"", tableName), "SELECT 1"); | ||
|
||
// create an empty partition | ||
assertUpdate(format("CALL system.create_empty_partition('%s', '%s', ARRAY['p_varchar'], ARRAY['%s'])", TPCH_SCHEMA, tableName, "empty")); | ||
assertQuery(format("SELECT count(*) FROM \"%s$partitions\"", tableName), "SELECT 2"); | ||
assertUpdate("DROP TABLE " + tableName); | ||
} | ||
|
||
@Test | ||
public void testCreateEmptyBucketedPartition() | ||
{ | ||
|
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.
Use
isEmpty()