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

Enable writing to full ACID tables in Hive connector when the table has no partitions #19447

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,11 @@ public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session,
if (isFullAcidTable(table.getParameters())) {
for (PartitionUpdate update : partitionUpdates) {
String deltaSubdir = deltaSubdir(handle.getTransaction().getWriteId(), 0);
String directory = "%s/%s/%s".formatted(table.getStorage().getLocation(), update.getName(), deltaSubdir);
String directory = table.getStorage().getLocation();
if (!update.getName().isEmpty()) {
directory += "/" + update.getName();
}
directory += "/" + deltaSubdir;
createOrcAcidVersionFile(session.getIdentity(), directory);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public void testInsertIntoPartitionedTable()
onTrino().executeQuery(format("DROP TABLE %s", tableName));
}

@Test(groups = {HMS_ONLY, PROFILE_SPECIFIC_TESTS})
public void testInsertIntoNonPartitionedTable()
{
String tableName = "non_partitioned_transactional_insert";
onTrino().executeQuery(format("CREATE TABLE %s (column1 INT, column2 INT) WITH (transactional = true)", tableName));
onTrino().executeQuery(format("INSERT INTO %s VALUES (11, 12), (111, 121)", tableName));
assertThat(onTrino().executeQuery(format("SELECT * FROM %s", tableName))).containsOnly(row(11, 12), row(111, 121));
onTrino().executeQuery(format("DROP TABLE %s", tableName));
}

@Test(groups = {HMS_ONLY, PROFILE_SPECIFIC_TESTS})
public void testUpdateOnUnpartitionedTable()
{
Expand Down
Loading