Skip to content
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 @@ -40,7 +40,6 @@
import java.util.Optional;
import java.util.Set;

import static com.google.common.base.Verify.verify;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.spi.transaction.IsolationLevel.READ_COMMITTED;
import static io.trino.spi.transaction.IsolationLevel.checkConnectorSupports;
Expand Down Expand Up @@ -193,7 +192,6 @@ public Iterable<EventListener> getEventListeners()
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit)
{
checkConnectorSupports(READ_COMMITTED, isolationLevel);
verify(autoCommit, "Catalog only supports writes using autocommit: DeltaLake");
Comment thread
findepi marked this conversation as resolved.
ConnectorTransactionHandle transaction = new HiveTransactionHandle(true);
transactionManager.begin(transaction);
return transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,16 @@ public void testSelectAll()
assertQuery("SELECT * FROM orders");
}

@Test
public void testSelectInTransaction()
{
inTransaction(session -> {
assertQuery(session, "SELECT nationkey, name, regionkey FROM nation");
assertQuery(session, "SELECT regionkey, name FROM region");
assertQuery(session, "SELECT nationkey, name, regionkey FROM nation");
});
}

/**
* Test interactions between optimizer (including CBO), scheduling and connector metadata APIs.
*/
Expand Down Expand Up @@ -2359,6 +2369,22 @@ protected String errorMessageForInsertIntoNotNullColumn(String columnName)
throw new UnsupportedOperationException("This method should be overridden");
}

@Test
public void testInsertInTransaction()
{
skipTestUnless(hasBehavior(SUPPORTS_INSERT));
skipTestUnless(hasBehavior(SUPPORTS_MULTI_STATEMENT_WRITES)); // covered by testWriteNotAllowedInTransaction

try (TestTable table = new TestTable(
getQueryRunner()::execute,
"test_tx_insert",
"(a bigint)")) {
String tableName = table.getName();
inTransaction(session -> assertUpdate(session, "INSERT INTO " + tableName + " VALUES 42", 1));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just to make sure, this would work without your change(removing that 'verify') right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for Detla, the test would break at the skipTestUnless(hasBehavior(SUPPORTS_MULTI_STATEMENT_WRITES)); because Delta doesn't support this. Only Hive does ATM, AFAIR.

assertQuery("TABLE " + tableName, "VALUES 42");
}
}

@Test
public void testDelete()
{
Expand Down