From c25cf1785706cc483dab24f033ff68def9d9fbd3 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 10 Jan 2024 11:12:34 +0100 Subject: [PATCH] Fix auto formatting of throwing blocks `{ throw ...; }` lambdas read very well. However, all recent IntelliJ versions insist on removing whitespace before `throw` and after final `;`. This results in checkstyle violation when IDE automatic formatting is used. Reformat lambdas in a way that IDE automatic formatting does not violate checkstyle rules, in order to save time when working with code. --- .../io/trino/metadata/FunctionManager.java | 12 +++++++--- .../io/trino/metadata/MetadataManager.java | 16 +++++++++---- .../trino/sql/analyzer/StatementAnalyzer.java | 4 +++- .../dispatcher/TestLocalDispatchQuery.java | 12 +++++++--- .../metadata/TestGlobalFunctionCatalog.java | 24 ++++++++++++++----- .../sql/planner/TestingPlannerContext.java | 12 +++++++--- .../ExchangeSourceOutputSelector.java | 4 +++- .../io/trino/spi/predicate/TupleDomain.java | 4 +++- .../plugin/jdbc/DefaultQueryBuilder.java | 4 +++- .../deltalake/DeltaLakeSessionProperties.java | 4 +++- .../trino/plugin/ignite/TestIgniteClient.java | 4 +++- .../plugin/postgresql/PostgreSqlClient.java | 8 +++++-- .../postgresql/TestPostgreSqlClient.java | 4 +++- 13 files changed, 84 insertions(+), 28 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/metadata/FunctionManager.java b/core/trino-main/src/main/java/io/trino/metadata/FunctionManager.java index 9a7c208380ea..9f53356708ad 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/FunctionManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/FunctionManager.java @@ -325,9 +325,15 @@ public static FunctionManager createTestingFunctionManager() { TypeOperators typeOperators = new TypeOperators(); GlobalFunctionCatalog functionCatalog = new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }); + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }); functionCatalog.addFunctions(SystemFunctionBundle.create(new FeaturesConfig(), typeOperators, new BlockTypeOperators(typeOperators), UNKNOWN)); functionCatalog.addFunctions(new InternalFunctionBundle(new LiteralFunction(new InternalBlockEncodingSerde(new BlockEncodingManager(), TESTING_TYPE_MANAGER)))); return new FunctionManager(CatalogServiceProvider.fail(), functionCatalog, LanguageFunctionProvider.DISABLED); diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java index 9c9221e38ebf..52db06bdb7e9 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java @@ -2044,7 +2044,9 @@ private void verifyProjection(TableHandle table, List proje .map(Variable::getName) .filter(variableName -> !assignedVariables.contains(variableName)) .findAny() - .ifPresent(variableName -> { throw new IllegalStateException("Unbound variable: " + variableName); }); + .ifPresent(variableName -> { + throw new IllegalStateException("Unbound variable: " + variableName); + }); } @Override @@ -2762,9 +2764,15 @@ public MetadataManager build() GlobalFunctionCatalog globalFunctionCatalog = this.globalFunctionCatalog; if (globalFunctionCatalog == null) { globalFunctionCatalog = new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }); + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }); TypeOperators typeOperators = new TypeOperators(); globalFunctionCatalog.addFunctions(SystemFunctionBundle.create(new FeaturesConfig(), typeOperators, new BlockTypeOperators(typeOperators), UNKNOWN)); globalFunctionCatalog.addFunctions(new InternalFunctionBundle(new LiteralFunction(new InternalBlockEncodingSerde(new BlockEncodingManager(), typeManager)))); diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java index 4a935a59777c..1560b5e60244 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java @@ -2532,7 +2532,9 @@ private Scope createScopeForView( analysis.unregisterTableForView(); checkViewStaleness(columns, descriptor.getVisibleFields(), name, table) - .ifPresent(explanation -> { throw semanticException(VIEW_IS_STALE, table, "View '%s' is stale or in invalid state: %s", name, explanation); }); + .ifPresent(explanation -> { + throw semanticException(VIEW_IS_STALE, table, "View '%s' is stale or in invalid state: %s", name, explanation); + }); // Derive the type of the view from the stored definition, not from the analysis of the underlying query. // This is needed in case the underlying table(s) changed and the query in the view now produces types that diff --git a/core/trino-main/src/test/java/io/trino/dispatcher/TestLocalDispatchQuery.java b/core/trino-main/src/test/java/io/trino/dispatcher/TestLocalDispatchQuery.java index 3a0b59b5b195..6cc0e9e990f3 100644 --- a/core/trino-main/src/test/java/io/trino/dispatcher/TestLocalDispatchQuery.java +++ b/core/trino-main/src/test/java/io/trino/dispatcher/TestLocalDispatchQuery.java @@ -134,9 +134,15 @@ public void testSubmittedForDispatchedQuery() new FunctionManager( new ConnectorCatalogServiceProvider<>("function provider", new NoConnectorServicesProvider(), ConnectorServices::getFunctionProvider), new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }), + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }), LanguageFunctionProvider.DISABLED), new QueryMonitorConfig()); CreateTable createTable = new CreateTable(QualifiedName.of("table"), ImmutableList.of(), FAIL, ImmutableList.of(), Optional.empty()); diff --git a/core/trino-main/src/test/java/io/trino/metadata/TestGlobalFunctionCatalog.java b/core/trino-main/src/test/java/io/trino/metadata/TestGlobalFunctionCatalog.java index 2c6a42d9e975..28746fffbd70 100644 --- a/core/trino-main/src/test/java/io/trino/metadata/TestGlobalFunctionCatalog.java +++ b/core/trino-main/src/test/java/io/trino/metadata/TestGlobalFunctionCatalog.java @@ -101,9 +101,15 @@ public void testDuplicateFunctions() TypeOperators typeOperators = new TypeOperators(); GlobalFunctionCatalog globalFunctionCatalog = new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }); + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }); globalFunctionCatalog.addFunctions(SystemFunctionBundle.create(new FeaturesConfig(), typeOperators, new BlockTypeOperators(typeOperators), NodeVersion.UNKNOWN)); globalFunctionCatalog.addFunctions(functionBundle); assertThatThrownBy(() -> globalFunctionCatalog.addFunctions(functionBundle)) @@ -118,9 +124,15 @@ public void testConflictingScalarAggregation() TypeOperators typeOperators = new TypeOperators(); GlobalFunctionCatalog globalFunctionCatalog = new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }); + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }); globalFunctionCatalog.addFunctions(SystemFunctionBundle.create(new FeaturesConfig(), typeOperators, new BlockTypeOperators(typeOperators), NodeVersion.UNKNOWN)); assertThatThrownBy(() -> globalFunctionCatalog.addFunctions(functions)) .isInstanceOf(IllegalStateException.class) diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestingPlannerContext.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestingPlannerContext.java index f2e8d9647efd..1b3ce8e8c4b4 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestingPlannerContext.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestingPlannerContext.java @@ -120,9 +120,15 @@ public PlannerContext build() parametricTypes.forEach(typeRegistry::addParametricType); GlobalFunctionCatalog globalFunctionCatalog = new GlobalFunctionCatalog( - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }, - () -> { throw new UnsupportedOperationException(); }); + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }, + () -> { + throw new UnsupportedOperationException(); + }); globalFunctionCatalog.addFunctions(SystemFunctionBundle.create(featuresConfig, typeOperators, new BlockTypeOperators(typeOperators), UNKNOWN)); functionBundles.forEach(globalFunctionCatalog::addFunctions); diff --git a/core/trino-spi/src/main/java/io/trino/spi/exchange/ExchangeSourceOutputSelector.java b/core/trino-spi/src/main/java/io/trino/spi/exchange/ExchangeSourceOutputSelector.java index 14ee2c3870a0..99c023ecc03c 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/exchange/ExchangeSourceOutputSelector.java +++ b/core/trino-spi/src/main/java/io/trino/spi/exchange/ExchangeSourceOutputSelector.java @@ -173,7 +173,9 @@ public String toString() .collect(toMap( Entry::getKey, Entry::getValue, - (a, b) -> { throw new IllegalArgumentException("got duplicate key " + a + ", " + b); }, + (a, b) -> { + throw new IllegalArgumentException("got duplicate key " + a + ", " + b); + }, TreeMap::new))) .add("finalSelector=" + finalSelector) .toString(); diff --git a/core/trino-spi/src/main/java/io/trino/spi/predicate/TupleDomain.java b/core/trino-spi/src/main/java/io/trino/spi/predicate/TupleDomain.java index 7be8cb97bb5d..7a8786868ac6 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/predicate/TupleDomain.java +++ b/core/trino-spi/src/main/java/io/trino/spi/predicate/TupleDomain.java @@ -640,7 +640,9 @@ public Domain getDomain() return toMap( keyMapper, valueMapper, - (u, v) -> { throw new IllegalStateException(format("Duplicate values for a key: %s and %s", u, v)); }, + (u, v) -> { + throw new IllegalStateException(format("Duplicate values for a key: %s and %s", u, v)); + }, LinkedHashMap::new); } diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultQueryBuilder.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultQueryBuilder.java index dfd3b0674329..760f9bc32bec 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultQueryBuilder.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultQueryBuilder.java @@ -86,7 +86,9 @@ public PreparedQuery prepareSelectQuery( .filter(domains::containsKey) .filter(column -> columnExpressions.containsKey(column.getColumnName())) .findFirst() - .ifPresent(column -> { throw new IllegalArgumentException(format("Column %s has an expression and a constraint attached at the same time", column)); }); + .ifPresent(column -> { + throw new IllegalArgumentException(format("Column %s has an expression and a constraint attached at the same time", column)); + }); } ImmutableList.Builder conjuncts = ImmutableList.builder(); diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSessionProperties.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSessionProperties.java index 065ac2e187fa..74697fc72bfd 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSessionProperties.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSessionProperties.java @@ -167,7 +167,9 @@ public DeltaLakeSessionProperties( "Internal Delta Lake connector property", HiveTimestampPrecision.class, MILLISECONDS, - value -> { throw new IllegalStateException("The property cannot be set"); }, + value -> { + throw new IllegalStateException("The property cannot be set"); + }, true), durationProperty( DYNAMIC_FILTERING_WAIT_TIMEOUT, diff --git a/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteClient.java b/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteClient.java index 955d0519177d..ccb88464f350 100644 --- a/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteClient.java +++ b/plugin/trino-ignite/src/test/java/io/trino/plugin/ignite/TestIgniteClient.java @@ -79,7 +79,9 @@ public class TestIgniteClient public static final JdbcClient JDBC_CLIENT = new IgniteClient( new BaseJdbcConfig(), - session -> { throw new UnsupportedOperationException(); }, + session -> { + throw new UnsupportedOperationException(); + }, new DefaultQueryBuilder(RemoteQueryModifier.NONE), new DefaultIdentifierMapping(), RemoteQueryModifier.NONE); diff --git a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java index affd261a925b..2dd1875d3ecf 100644 --- a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java +++ b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java @@ -1390,7 +1390,9 @@ private ColumnMapping arrayAsJsonColumnMapping(ConnectorSession session, ColumnM return ColumnMapping.sliceMapping( jsonType, arrayAsJsonReadFunction(session, baseElementMapping), - (statement, index, block) -> { throw new UnsupportedOperationException(); }, + (statement, index, block) -> { + throw new UnsupportedOperationException(); + }, DISABLE_PUSHDOWN); } @@ -1518,7 +1520,9 @@ public Slice readSlice(ResultSet resultSet, int columnIndex) return utf8Slice(resultSet.getString(columnIndex)); } }, - (statement, index, value) -> { throw new TrinoException(NOT_SUPPORTED, "Money type is not supported for INSERT"); }, + (statement, index, value) -> { + throw new TrinoException(NOT_SUPPORTED, "Money type is not supported for INSERT"); + }, DISABLE_PUSHDOWN); } diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java index fd47c631f77d..c2da5213729d 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java @@ -108,7 +108,9 @@ public class TestPostgreSqlClient new BaseJdbcConfig(), new PostgreSqlConfig(), new JdbcStatisticsConfig(), - session -> { throw new UnsupportedOperationException(); }, + session -> { + throw new UnsupportedOperationException(); + }, new DefaultQueryBuilder(RemoteQueryModifier.NONE), TESTING_TYPE_MANAGER, new DefaultIdentifierMapping(),