Skip to content

Commit 84c3c3a

Browse files
committed
Add testTruncateTable in BaseConnectorSmokeTest
1 parent 60c0042 commit 84c3c3a

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorSmokeTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
2828
switch (connectorBehavior) {
2929
case SUPPORTS_DELETE:
3030
return false;
31+
case SUPPORTS_TRUNCATE:
32+
return true;
3133

3234
default:
3335
return super.hasBehavior(connectorBehavior);

plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ protected QueryRunner createQueryRunner()
194194
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
195195
{
196196
switch (connectorBehavior) {
197+
case SUPPORTS_TRUNCATE:
198+
return false;
199+
197200
case SUPPORTS_CREATE_MATERIALIZED_VIEW:
198201
return false;
199202

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public BaseIcebergConnectorSmokeTest(FileFormat format)
6969
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
7070
{
7171
switch (connectorBehavior) {
72+
case SUPPORTS_TRUNCATE:
73+
return false;
74+
7275
case SUPPORTS_TOPN_PUSHDOWN:
7376
return false;
7477

plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/BaseKuduConnectorSmokeTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ protected QueryRunner createQueryRunner()
4747
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
4848
{
4949
switch (connectorBehavior) {
50+
case SUPPORTS_TRUNCATE:
51+
return false;
52+
5053
case SUPPORTS_TOPN_PUSHDOWN:
5154
return false;
5255

plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorSmokeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
2626
switch (connectorBehavior) {
2727
case SUPPORTS_UPDATE:
2828
case SUPPORTS_MERGE:
29+
case SUPPORTS_TRUNCATE:
2930
return false;
3031

3132
case SUPPORTS_RENAME_SCHEMA:

testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorSmokeTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_RENAME_TABLE;
4040
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS;
4141
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_ROW_LEVEL_DELETE;
42+
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_TRUNCATE;
4243
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_UPDATE;
4344
import static io.trino.testing.TestingNames.randomNameSuffix;
4445
import static io.trino.tpch.TpchTable.NATION;
@@ -247,6 +248,23 @@ public void testRowLevelDelete()
247248
}
248249
}
249250

251+
@Test
252+
public void testTruncateTable()
253+
{
254+
if (!hasBehavior(SUPPORTS_TRUNCATE)) {
255+
assertQueryFails("TRUNCATE TABLE nation", "This connector does not support truncating tables");
256+
return;
257+
}
258+
259+
skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE));
260+
261+
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_truncate", "AS SELECT * FROM region")) {
262+
assertUpdate("TRUNCATE TABLE " + table.getName());
263+
assertThat(query("TABLE " + table.getName()))
264+
.returnsEmptyResult();
265+
}
266+
}
267+
250268
@Test
251269
public void testUpdate()
252270
{

0 commit comments

Comments
 (0)