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 @@ -28,6 +28,8 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
switch (connectorBehavior) {
case SUPPORTS_DELETE:
return false;
case SUPPORTS_TRUNCATE:
return true;

default:
return super.hasBehavior(connectorBehavior);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ protected QueryRunner createQueryRunner()
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_TRUNCATE:
return false;

case SUPPORTS_CREATE_MATERIALIZED_VIEW:
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public BaseIcebergConnectorSmokeTest(FileFormat format)
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_TRUNCATE:
return false;

case SUPPORTS_TOPN_PUSHDOWN:
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ protected QueryRunner createQueryRunner()
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_TRUNCATE:
return false;

case SUPPORTS_TOPN_PUSHDOWN:
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
switch (connectorBehavior) {
case SUPPORTS_UPDATE:
case SUPPORTS_MERGE:
case SUPPORTS_TRUNCATE:
return false;

case SUPPORTS_RENAME_SCHEMA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_RENAME_TABLE;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_ROW_LEVEL_DELETE;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_TRUNCATE;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_UPDATE;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tpch.TpchTable.NATION;
Expand Down Expand Up @@ -247,6 +248,23 @@ public void testRowLevelDelete()
}
}

@Test
public void testTruncateTable()
{
if (!hasBehavior(SUPPORTS_TRUNCATE)) {
assertQueryFails("TRUNCATE TABLE nation", "This connector does not support truncating tables");
return;
}

skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE));

try (TestTable table = new TestTable(getQueryRunner()::execute, "test_truncate", "AS SELECT * FROM region")) {
assertUpdate("TRUNCATE TABLE " + table.getName());
assertThat(query("TABLE " + table.getName()))
.returnsEmptyResult();
}
}

@Test
public void testUpdate()
{
Expand Down