Skip to content

Commit

Permalink
Use a temporary table to verify if deletes are supported
Browse files Browse the repository at this point in the history
Not all connector tests run within containers so any operation that
deletes data from the TPCH tables can change state of the testing
infrastructure leading to hard to diagnose failures.

So we create temporary tables to verify if deletes are supported or not.
  • Loading branch information
hashhar committed Jul 8, 2021
1 parent 8b2dabd commit 9fb91ca
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.testing;

import com.google.common.collect.ImmutableList;
import io.trino.testing.sql.TestTable;
import io.trino.tpch.TpchTable;
import org.testng.SkipException;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -169,14 +170,16 @@ public void testInsert()
@Test
public void testDelete()
{
if (!hasBehavior(SUPPORTS_DELETE)) {
assertQueryFails("DELETE FROM region", "This connector does not support deletes");
return;
}

if (!hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)) {
assertQueryFails("DELETE FROM region WHERE regionkey = 2", ".*[Dd]elet(e|ing).*(not |un)supported.*");
return;
skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE));
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_delete", "(col bigint)", ImmutableList.of("1", "2"))) {
if (!hasBehavior(SUPPORTS_DELETE)) {
assertQueryFails("DELETE FROM " + table.getName(), "This connector does not support deletes");
throw new SkipException("This connector does not support deletes");
}
if (!hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)) {
assertQueryFails("DELETE FROM " + table.getName() + " WHERE col = 2", ".*[Dd]elet(e|ing).*(not |un)supported.*");
throw new SkipException("This connector does not support row-level deletes");
}
}

String tableName = "test_delete_" + randomTableSuffix();
Expand Down

0 comments on commit 9fb91ca

Please sign in to comment.