diff --git a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java index 2cace95590bc..adfbb319c0dc 100644 --- a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java +++ b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java @@ -52,47 +52,27 @@ protected QueryRunner createQueryRunner() return createAccumuloQueryRunner(ImmutableMap.of()); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - case SUPPORTS_DROP_SCHEMA_CASCADE: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_DELETE, + SUPPORTS_DROP_SCHEMA_CASCADE, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java index 699b35a2a992..6b379de08f5a 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java @@ -134,28 +134,18 @@ public void afterClass() @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_UPDATE: // not supported by any JDBC connector - case SUPPORTS_MERGE: // not supported by any JDBC connector - return false; - - case SUPPORTS_CREATE_VIEW: // not supported by DefaultJdbcMetadata - case SUPPORTS_CREATE_MATERIALIZED_VIEW: // not supported by DefaultJdbcMetadata - return false; - - case SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN: - // TODO support pushdown of complex expressions in predicates - return false; - - case SUPPORTS_DYNAMIC_FILTER_PUSHDOWN: - // Dynamic filters can be pushed down only if predicate push down is supported. - // It is possible for a connector to have predicate push down support but not push down dynamic filters. - // TODO default SUPPORTS_DYNAMIC_FILTER_PUSHDOWN to SUPPORTS_PREDICATE_PUSHDOWN - return super.hasBehavior(SUPPORTS_PREDICATE_PUSHDOWN); - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_MERGE, + SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN, + SUPPORTS_UPDATE -> false; + // Dynamic filters can be pushed down only if predicate push down is supported. + // It is possible for a connector to have predicate push down support but not push down dynamic filters. + // TODO default SUPPORTS_DYNAMIC_FILTER_PUSHDOWN to SUPPORTS_PREDICATE_PUSHDOWN + case SUPPORTS_DYNAMIC_FILTER_PUSHDOWN -> super.hasBehavior(SUPPORTS_PREDICATE_PUSHDOWN); + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java index 055bd544179e..497172c8e8ec 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java @@ -56,35 +56,23 @@ protected QueryRunner createQueryRunner() return createH2QueryRunner(REQUIRED_TPCH_TABLES, properties); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_LIMIT_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_AGGREGATION_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_LIMIT_PUSHDOWN, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_TOPN_PUSHDOWN -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorSmokeTest.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorSmokeTest.java index f9f3daf23d48..d8e31af5d289 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorSmokeTest.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorSmokeTest.java @@ -19,28 +19,19 @@ public abstract class BaseBigQueryConnectorSmokeTest extends BaseConnectorSmokeTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - case SUPPORTS_TRUNCATE: - return true; - - case SUPPORTS_RENAME_TABLE: - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_TRUNCATE -> true; + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_MERGE, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } } diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorTest.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorTest.java index 1bbb572e41b6..8a4fb213c62a 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorTest.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryConnectorTest.java @@ -63,46 +63,27 @@ public void initBigQueryExecutor(String gcpStorageBucket) this.gcpStorageBucket = gcpStorageBucket; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - case SUPPORTS_TRUNCATE: - return true; - - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_DEREFERENCE_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_TRUNCATE -> true; + case SUPPORTS_ADD_COLUMN, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_DEREFERENCE_PUSHDOWN, + SUPPORTS_MERGE, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/BaseCassandraConnectorSmokeTest.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/BaseCassandraConnectorSmokeTest.java index 507e48d909cd..2bd0b9080bd2 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/BaseCassandraConnectorSmokeTest.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/BaseCassandraConnectorSmokeTest.java @@ -32,41 +32,23 @@ public abstract class BaseCassandraConnectorSmokeTest public static final String KEYSPACE = "smoke_test"; public static final ZonedDateTime TIMESTAMP_VALUE = ZonedDateTime.of(1970, 1, 1, 3, 4, 5, 0, ZoneId.of("UTC")); - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_UPDATE: - return false; - case SUPPORTS_DELETE: - return true; - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_ARRAY: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_DELETE -> true; + case SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_VIEW, + SUPPORTS_MERGE, + SUPPORTS_RENAME_TABLE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java index 4c0111c801a6..c9c4dd9bcf40 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java @@ -86,53 +86,31 @@ public class TestCassandraConnectorTest private CassandraServer server; private CassandraSession session; - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_DELETE: - case SUPPORTS_TRUNCATE: - return true; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_DELETE, + SUPPORTS_TRUNCATE -> true; + case SUPPORTS_ADD_COLUMN, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_CREATE_VIEW, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java index 91e19029750d..1cb6305ea77c 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java @@ -59,43 +59,28 @@ public class TestClickHouseConnectorTest { private TestingClickHouseServer clickhouseServer; - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - return false; - case SUPPORTS_TRUNCATE: - return true; - - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY: - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV: - case SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - case SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT: - return false; - - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - case SUPPORTS_NATIVE_QUERY: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_TRUNCATE -> true; + case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV, + SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE, + SUPPORTS_ARRAY, + SUPPORTS_DELETE, + SUPPORTS_NATIVE_QUERY, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java index d6178f20ab3f..4ac8d64507b4 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java @@ -227,23 +227,15 @@ private DistributedQueryRunner createDeltaLakeQueryRunner() queryRunner -> {}); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java index 12276e30f0c4..4b4565b8bc0c 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java @@ -140,39 +140,25 @@ public void tearDown() minioClient = null; // closed by closeAfterClass } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_PREDICATE_PUSHDOWN: - case SUPPORTS_LIMIT_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_AGGREGATION_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - case SUPPORTS_DROP_SCHEMA_CASCADE: - return false; - - case SUPPORTS_ADD_FIELD: - case SUPPORTS_DROP_FIELD: - case SUPPORTS_RENAME_FIELD: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_REPORTING_WRITTEN_BYTES: - return true; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_REPORTING_WRITTEN_BYTES -> true; + case SUPPORTS_ADD_FIELD, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_DROP_FIELD, + SUPPORTS_DROP_SCHEMA_CASCADE, + SUPPORTS_LIMIT_PUSHDOWN, + SUPPORTS_PREDICATE_PUSHDOWN, + SUPPORTS_RENAME_FIELD, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-druid/src/test/java/io/trino/plugin/druid/BaseDruidConnectorTest.java b/plugin/trino-druid/src/test/java/io/trino/plugin/druid/BaseDruidConnectorTest.java index b85eee999eed..2e0643b2b6d9 100644 --- a/plugin/trino-druid/src/test/java/io/trino/plugin/druid/BaseDruidConnectorTest.java +++ b/plugin/trino-druid/src/test/java/io/trino/plugin/druid/BaseDruidConnectorTest.java @@ -63,43 +63,27 @@ public void destroy() } } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_AGGREGATION_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - return false; - case SUPPORTS_TRUNCATE: - return true; // TODO ATM Truncate doesn't work in Druid, but testTruncateTable doesn't fail as CREATE TABLE is not supported - - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + // TODO: at the moment, truncate doesn't work in Druid, but testTruncateTable doesn't fail as CREATE TABLE is not supported + case SUPPORTS_TRUNCATE -> true; + case SUPPORTS_ADD_COLUMN, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java index 54a328c32823..8fe0d4c3b93d 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java @@ -95,47 +95,29 @@ public final void destroy() client = null; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_LIMIT_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_LIMIT_PUSHDOWN, + SUPPORTS_MERGE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } /** diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index b7caf45fcc29..7b63f8e50eda 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -241,40 +241,23 @@ protected static QueryRunner createHiveQueryRunner(HiveQueryRunner.Builder bu return queryRunner; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_ADD_FIELD: - case SUPPORTS_DROP_FIELD: - case SUPPORTS_RENAME_FIELD: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_MERGE: - // FIXME: Fails because only allowed with transactional tables - return false; - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_MULTI_STATEMENT_WRITES: - return true; - case SUPPORTS_REPORTING_WRITTEN_BYTES: - return true; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_MULTI_STATEMENT_WRITES, + SUPPORTS_REPORTING_WRITTEN_BYTES -> true; // FIXME: Fails because only allowed with transactional tables + case SUPPORTS_ADD_FIELD, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_DROP_FIELD, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_FIELD, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorSmokeTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorSmokeTest.java index f4b9cba8f2d5..3d68a45847a0 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorSmokeTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorSmokeTest.java @@ -36,26 +36,16 @@ protected QueryRunner createQueryRunner() .build(); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_MULTI_STATEMENT_WRITES: - return true; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_MULTI_STATEMENT_WRITES -> true; + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiConnectorTest.java b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiConnectorTest.java index b0affd32372c..d877e0194e1f 100644 --- a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiConnectorTest.java +++ b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiConnectorTest.java @@ -38,44 +38,28 @@ protected QueryRunner createQueryRunner() new TpchHudiTablesInitializer(COPY_ON_WRITE, REQUIRED_TPCH_TABLES)); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_DEREFERENCE_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_DEREFERENCE_PUSHDOWN, + SUPPORTS_INSERT, + SUPPORTS_MERGE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java index 80ca796acb65..40518fdbe0ee 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java @@ -71,20 +71,14 @@ public void initFileSystem() fileSystem = getFileSystemFactory(getDistributedQueryRunner()).create(SESSION); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java index 0a19c9b8b5c8..5fbff1d94d18 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java @@ -212,29 +212,17 @@ public void initStorageTimePrecision() } } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_MATERIALIZED_VIEW_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_REPORTING_WRITTEN_BYTES: - return true; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_REPORTING_WRITTEN_BYTES -> true; + case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_MATERIALIZED_VIEW_ACROSS_SCHEMAS, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/jdbc/TestIcebergJdbcCatalogConnectorSmokeTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/jdbc/TestIcebergJdbcCatalogConnectorSmokeTest.java index 0c57fcc95b97..5a9aef435698 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/jdbc/TestIcebergJdbcCatalogConnectorSmokeTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/jdbc/TestIcebergJdbcCatalogConnectorSmokeTest.java @@ -58,14 +58,16 @@ public TestIcebergJdbcCatalogConnectorSmokeTest() super(new IcebergConfig().getFileFormat().toIceberg()); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { return switch (connectorBehavior) { - case SUPPORTS_RENAME_SCHEMA -> false; - case SUPPORTS_CREATE_VIEW, SUPPORTS_COMMENT_ON_VIEW, SUPPORTS_COMMENT_ON_VIEW_COLUMN -> false; - case SUPPORTS_CREATE_MATERIALIZED_VIEW, SUPPORTS_RENAME_MATERIALIZED_VIEW -> false; + case SUPPORTS_COMMENT_ON_VIEW, + SUPPORTS_COMMENT_ON_VIEW_COLUMN, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_RENAME_MATERIALIZED_VIEW, + SUPPORTS_RENAME_SCHEMA -> false; default -> super.hasBehavior(connectorBehavior); }; } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergTrinoRestCatalogConnectorSmokeTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergTrinoRestCatalogConnectorSmokeTest.java index 860bfe7f1470..29ff135aea4c 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergTrinoRestCatalogConnectorSmokeTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergTrinoRestCatalogConnectorSmokeTest.java @@ -53,14 +53,16 @@ public TestIcebergTrinoRestCatalogConnectorSmokeTest() super(new IcebergConfig().getFileFormat().toIceberg()); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { return switch (connectorBehavior) { - case SUPPORTS_RENAME_SCHEMA -> false; - case SUPPORTS_CREATE_VIEW, SUPPORTS_COMMENT_ON_VIEW, SUPPORTS_COMMENT_ON_VIEW_COLUMN -> false; - case SUPPORTS_CREATE_MATERIALIZED_VIEW, SUPPORTS_RENAME_MATERIALIZED_VIEW -> false; + case SUPPORTS_COMMENT_ON_VIEW, + SUPPORTS_COMMENT_ON_VIEW_COLUMN, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_RENAME_MATERIALIZED_VIEW, + SUPPORTS_RENAME_SCHEMA -> false; default -> super.hasBehavior(connectorBehavior); }; } diff --git a/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteConnectorTest.java b/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteConnectorTest.java index 9bf6e4f1dd0d..aaddab434b2b 100644 --- a/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteConnectorTest.java +++ b/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteConnectorTest.java @@ -63,56 +63,37 @@ protected SqlExecutor onRemoteDatabase() return igniteServer::execute; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_CREATE_SCHEMA: - case SUPPORTS_RENAME_TABLE: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT: - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - case SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN_WITH_LIKE: - case SUPPORTS_TOPN_PUSHDOWN_WITH_VARCHAR: - return true; - - case SUPPORTS_NATIVE_QUERY: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN: - return true; - case SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV: - case SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_JOIN_PUSHDOWN, + SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN_WITH_LIKE, + SUPPORTS_TOPN_PUSHDOWN_WITH_VARCHAR -> true; + case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT, + SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV, + SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_NATIVE_QUERY, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConnectorTest.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConnectorTest.java index c2683d54bf73..f687fcde1ccd 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConnectorTest.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConnectorTest.java @@ -163,43 +163,27 @@ protected QueryRunner createQueryRunner() return queryRunner; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_DEREFERENCE_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_DEREFERENCE_PUSHDOWN, + SUPPORTS_MERGE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaLatestConnectorSmokeTest.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaLatestConnectorSmokeTest.java index 35d6bdc27906..09163a6f4c2c 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaLatestConnectorSmokeTest.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaLatestConnectorSmokeTest.java @@ -34,30 +34,20 @@ protected QueryRunner createQueryRunner() .build(); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_MERGE, + SUPPORTS_RENAME_TABLE, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/BaseKuduConnectorSmokeTest.java b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/BaseKuduConnectorSmokeTest.java index fd0b65062696..e9ecbf6b30f6 100644 --- a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/BaseKuduConnectorSmokeTest.java +++ b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/BaseKuduConnectorSmokeTest.java @@ -45,39 +45,23 @@ protected QueryRunner createQueryRunner() getKuduSchemaEmulationPrefix(), REQUIRED_TPCH_TABLES); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_ROW_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java index 658689c327d2..fa29a047fb6a 100644 --- a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java +++ b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java @@ -60,45 +60,25 @@ protected QueryRunner createQueryRunner() REQUIRED_TPCH_TABLES); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_VIEW, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java index b4285e526d4d..e7de87601107 100644 --- a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java +++ b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java @@ -37,48 +37,29 @@ public abstract class BaseMariaDbConnectorTest { protected TestingMariaDbServer server; - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY: - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - case SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_JOIN_PUSHDOWN -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java b/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java index 9e56a6de50af..f0b57fc28123 100644 --- a/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java +++ b/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java @@ -81,40 +81,26 @@ protected QueryRunner createQueryRunner() .build()); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_PREDICATE_PUSHDOWN: - case SUPPORTS_LIMIT_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_AGGREGATION_PUSHDOWN: - case SUPPORTS_DEREFERENCE_PUSHDOWN: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_DELETE, + SUPPORTS_DEREFERENCE_PUSHDOWN, + SUPPORTS_LIMIT_PUSHDOWN, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_PREDICATE_PUSHDOWN, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorSmokeTest.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorSmokeTest.java index 5da1e555bc57..747abb141bf2 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorSmokeTest.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorSmokeTest.java @@ -24,29 +24,19 @@ public abstract class BaseMongoConnectorSmokeTest extends BaseConnectorSmokeTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_TRUNCATE, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java index 7b1f0cce13b8..3245f461a98b 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java @@ -95,37 +95,24 @@ public final void destroy() client = null; } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DELETE: - return true; - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_ADD_FIELD: - case SUPPORTS_RENAME_FIELD: - case SUPPORTS_DROP_FIELD: - case SUPPORTS_SET_FIELD_TYPE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_DELETE -> true; + case SUPPORTS_ADD_FIELD, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DROP_FIELD, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_FIELD, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_SET_FIELD_TYPE, + SUPPORTS_TRUNCATE, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java index 8b2e7359cbb2..b154c8576bc4 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java @@ -55,50 +55,30 @@ public abstract class BaseMySqlConnectorTest { protected TestingMySqlServer mySqlServer; - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY: - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN: - return true; - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - case SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_JOIN_PUSHDOWN -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorSmokeTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorSmokeTest.java index b77adf2a9218..2cdcaa3ae0d2 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorSmokeTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorSmokeTest.java @@ -23,20 +23,14 @@ public abstract class BaseOracleConnectorSmokeTest extends BaseJdbcConnectorSmokeTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_CREATE_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java index 3b48c3a4889a..4f0da8494551 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java @@ -44,41 +44,24 @@ public abstract class BaseOracleConnectorTest extends BaseJdbcConnectorTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_JOIN_PUSHDOWN -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_ARRAY, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java index acb3961a64cc..65083dd9342f 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java @@ -79,55 +79,31 @@ protected QueryRunner createQueryRunner() return createPhoenixQueryRunner(testingPhoenixServer, ImmutableMap.of(), REQUIRED_TPCH_TABLES); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_LIMIT_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_AGGREGATION_PUSHDOWN: - return false; - - case SUPPORTS_PREDICATE_ARITHMETIC_EXPRESSION_PUSHDOWN: - return true; - - case SUPPORTS_RENAME_SCHEMA: - case SUPPORTS_DROP_SCHEMA_CASCADE: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_ROW_TYPE: - return false; - - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return true; - - case SUPPORTS_NATIVE_QUERY: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_MERGE, + SUPPORTS_PREDICATE_ARITHMETIC_EXPRESSION_PUSHDOWN, + SUPPORTS_UPDATE -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_DROP_SCHEMA_CASCADE, + SUPPORTS_LIMIT_PUSHDOWN, + SUPPORTS_NATIVE_QUERY, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } // TODO: wait https://github.com/trinodb/trino/pull/14939 done and then remove this test diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/BasePinotConnectorSmokeTest.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/BasePinotConnectorSmokeTest.java index 72f9807ffe0f..7f823ae61377 100644 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/BasePinotConnectorSmokeTest.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/BasePinotConnectorSmokeTest.java @@ -646,23 +646,19 @@ private void createAndPopulateNationAndRegionData(TestingKafka kafka, TestingPin pinot.addRealTimeTable(getClass().getClassLoader().getResourceAsStream("nation_realtimeSpec.json"), nationTableName); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { return switch (connectorBehavior) { - case SUPPORTS_CREATE_SCHEMA -> false; - - case SUPPORTS_CREATE_TABLE, SUPPORTS_RENAME_TABLE -> false; - - case SUPPORTS_INSERT -> false; - case SUPPORTS_UPDATE -> false; - case SUPPORTS_DELETE -> false; - case SUPPORTS_MERGE -> false; - - case SUPPORTS_CREATE_VIEW -> false; - case SUPPORTS_CREATE_MATERIALIZED_VIEW -> false; - + case SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_MERGE, + SUPPORTS_RENAME_TABLE, + SUPPORTS_UPDATE -> false; default -> super.hasBehavior(connectorBehavior); }; } diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java index 75a1607f9e09..0af17d0c6e17 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java @@ -94,47 +94,30 @@ public void setExtensions() onRemoteDatabase().execute("CREATE EXTENSION file_fdw"); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - return false; - case SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN: + return switch (connectorBehavior) { + case SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN -> { // TODO remove once super has this set to true verify(!super.hasBehavior(connectorBehavior)); - return true; - - case SUPPORTS_TOPN_PUSHDOWN: - case SUPPORTS_TOPN_PUSHDOWN_WITH_VARCHAR: - return true; - - case SUPPORTS_JOIN_PUSHDOWN: - case SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - return false; - - case SUPPORTS_ARRAY: - // Arrays are supported conditionally. Check the defaults. - return new PostgreSqlConfig().getArrayMapping() != PostgreSqlConfig.ArrayMapping.DISABLED; - case SUPPORTS_ROW_TYPE: - return false; - - case SUPPORTS_CANCELLATION: - return true; - - default: - return super.hasBehavior(connectorBehavior); - } + yield true; + } + // Arrays are supported conditionally. Check the defaults. + case SUPPORTS_ARRAY -> new PostgreSqlConfig().getArrayMapping() != PostgreSqlConfig.ArrayMapping.DISABLED; + case SUPPORTS_CANCELLATION, + SUPPORTS_JOIN_PUSHDOWN, + SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TOPN_PUSHDOWN_WITH_VARCHAR -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java index 4eacd582890b..2f4ed2286118 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java @@ -68,44 +68,24 @@ public abstract class BaseRaptorConnectorTest extends BaseConnectorTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TRUNCATE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_TRUNCATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/BaseRedisConnectorTest.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/BaseRedisConnectorTest.java index 80d2d82d5910..90f929c11f2c 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/BaseRedisConnectorTest.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/BaseRedisConnectorTest.java @@ -23,47 +23,29 @@ public abstract class BaseRedisConnectorTest extends BaseConnectorTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_MERGE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorSmokeTest.java b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorSmokeTest.java index 365a226d3036..1cffa1519965 100644 --- a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorSmokeTest.java +++ b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorSmokeTest.java @@ -24,16 +24,12 @@ public class TestRedshiftConnectorSmokeTest extends BaseJdbcConnectorSmokeTest { @Override - @SuppressWarnings("DuplicateBranchesInSwitch") // options here are grouped per-feature protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java index 031d167ff5c2..0b458b229d15 100644 --- a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java +++ b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java @@ -64,46 +64,27 @@ protected QueryRunner createQueryRunner() } @Override - @SuppressWarnings("DuplicateBranchesInSwitch") // options here are grouped per-feature protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_DROP_SCHEMA_CASCADE: - return false; - - case SUPPORTS_COMMENT_ON_COLUMN: - return true; - - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - case SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_JOIN_PUSHDOWN, + SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY -> true; + case SUPPORTS_ADD_COLUMN_NOT_NULL_CONSTRAINT, + SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_ARRAY, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_DROP_SCHEMA_CASCADE, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java index aa807b3a9e36..7c9243212187 100644 --- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java +++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java @@ -63,47 +63,28 @@ public final void destroy() singleStoreServer.close(); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY: - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - return false; - - case SUPPORTS_AGGREGATION_PUSHDOWN: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - return false; - - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_JOIN_PUSHDOWN -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreLatestConnectorSmokeTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreLatestConnectorSmokeTest.java index 63588c8d7b2c..a934e018c33a 100644 --- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreLatestConnectorSmokeTest.java +++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreLatestConnectorSmokeTest.java @@ -31,19 +31,13 @@ protected QueryRunner createQueryRunner() return createSingleStoreQueryRunner(singleStoreServer, ImmutableMap.of(), ImmutableMap.of(), REQUIRED_TPCH_TABLES); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS -> false; + default -> super.hasBehavior(connectorBehavior); + }; } } diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorSmokeTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorSmokeTest.java index 4eca36ac014c..414743539e0d 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorSmokeTest.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorSmokeTest.java @@ -22,20 +22,14 @@ public abstract class BaseSqlServerConnectorSmokeTest extends BaseJdbcConnectorSmokeTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_RENAME_SCHEMA: - return false; - - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java index e12dc0452515..2efdff76eeee 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java @@ -49,56 +49,34 @@ public abstract class BaseSqlServerConnectorTest extends BaseJdbcConnectorTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY: - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY: - return true; - case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY: - return false; - - case SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN: - return true; - - case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE: - case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION: - case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION: - case SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT: - return false; - - case SUPPORTS_JOIN_PUSHDOWN: - return true; - case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: - return false; - - case SUPPORTS_RENAME_SCHEMA: - case SUPPORTS_DROP_SCHEMA_CASCADE: - return false; - - case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT: - case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: - case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: - return false; - - case SUPPORTS_ADD_COLUMN_WITH_COMMENT: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - case SUPPORTS_NEGATIVE_DATE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_JOIN_PUSHDOWN, + SUPPORTS_JOIN_PUSHDOWN_WITH_VARCHAR_EQUALITY, + SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY -> true; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT, + SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION, + SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT, + SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE, + SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT, + SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT, + SUPPORTS_DROP_SCHEMA_CASCADE, + SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM, + SUPPORTS_NEGATIVE_DATE, + SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY, + SUPPORTS_RENAME_SCHEMA, + SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftConnectorTest.java b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftConnectorTest.java index 43d6d8e6007b..3058586ac112 100644 --- a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftConnectorTest.java +++ b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftConnectorTest.java @@ -27,49 +27,29 @@ public class TestThriftConnectorTest extends BaseConnectorTest { - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_NOT_NULL_CONSTRAINT: - return false; - - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_MERGE, + SUPPORTS_NOT_NULL_CONSTRAINT, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Override diff --git a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TestTpchConnectorTest.java b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TestTpchConnectorTest.java index b5e898e40570..0fac01156129 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TestTpchConnectorTest.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TestTpchConnectorTest.java @@ -49,47 +49,29 @@ protected QueryRunner createQueryRunner() return TpchQueryRunnerBuilder.builder().build(); } - @SuppressWarnings("DuplicateBranchesInSwitch") @Override protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) { - switch (connectorBehavior) { - case SUPPORTS_INSERT: - case SUPPORTS_DELETE: - case SUPPORTS_UPDATE: - case SUPPORTS_MERGE: - return false; - - case SUPPORTS_TOPN_PUSHDOWN: - return false; - - case SUPPORTS_CREATE_SCHEMA: - return false; - - case SUPPORTS_CREATE_TABLE: - case SUPPORTS_RENAME_TABLE: - return false; - - case SUPPORTS_ADD_COLUMN: - case SUPPORTS_RENAME_COLUMN: - case SUPPORTS_SET_COLUMN_TYPE: - return false; - - case SUPPORTS_COMMENT_ON_TABLE: - case SUPPORTS_COMMENT_ON_COLUMN: - return false; - - case SUPPORTS_CREATE_VIEW: - case SUPPORTS_CREATE_MATERIALIZED_VIEW: - return false; - - case SUPPORTS_ARRAY: - case SUPPORTS_ROW_TYPE: - return false; - - default: - return super.hasBehavior(connectorBehavior); - } + return switch (connectorBehavior) { + case SUPPORTS_ADD_COLUMN, + SUPPORTS_ARRAY, + SUPPORTS_COMMENT_ON_COLUMN, + SUPPORTS_COMMENT_ON_TABLE, + SUPPORTS_CREATE_MATERIALIZED_VIEW, + SUPPORTS_CREATE_SCHEMA, + SUPPORTS_CREATE_TABLE, + SUPPORTS_CREATE_VIEW, + SUPPORTS_DELETE, + SUPPORTS_INSERT, + SUPPORTS_MERGE, + SUPPORTS_RENAME_COLUMN, + SUPPORTS_RENAME_TABLE, + SUPPORTS_ROW_TYPE, + SUPPORTS_SET_COLUMN_TYPE, + SUPPORTS_TOPN_PUSHDOWN, + SUPPORTS_UPDATE -> false; + default -> super.hasBehavior(connectorBehavior); + }; } @Test