diff --git a/client/trino-cli/src/main/java/io/trino/cli/ClientOptions.java b/client/trino-cli/src/main/java/io/trino/cli/ClientOptions.java index 9ed14411bf78..52fbc8e6cfd4 100644 --- a/client/trino-cli/src/main/java/io/trino/cli/ClientOptions.java +++ b/client/trino-cli/src/main/java/io/trino/cli/ClientOptions.java @@ -244,7 +244,7 @@ public static Map toProperties(List sessi } builder.put(name, sessionProperty.getValue()); } - return builder.build(); + return builder.buildOrThrow(); } public static Map toResourceEstimates(List estimates) @@ -253,7 +253,7 @@ public static Map toResourceEstimates(List toExtraCredentials(List extraCredentials) @@ -262,7 +262,7 @@ public static Map toExtraCredentials(List for (ClientExtraCredential credential : extraCredentials) { builder.put(credential.getName(), credential.getValue()); } - return builder.build(); + return builder.buildOrThrow(); } public static final class ClientResourceEstimate diff --git a/client/trino-client/src/main/java/io/trino/client/auth/kerberos/LoginBasedSubjectProvider.java b/client/trino-client/src/main/java/io/trino/client/auth/kerberos/LoginBasedSubjectProvider.java index 0e27a1c013fc..e385cbefc8d1 100644 --- a/client/trino-client/src/main/java/io/trino/client/auth/kerberos/LoginBasedSubjectProvider.java +++ b/client/trino-client/src/main/java/io/trino/client/auth/kerberos/LoginBasedSubjectProvider.java @@ -110,7 +110,7 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) principal.ifPresent(value -> options.put("principal", value)); return new AppConfigurationEntry[] { - new AppConfigurationEntry(Krb5LoginModule.class.getName(), REQUIRED, options.build()) + new AppConfigurationEntry(Krb5LoginModule.class.getName(), REQUIRED, options.buildOrThrow()) }; } }); diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractTrinoResultSet.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractTrinoResultSet.java index ec587074a46f..85dbc0141469 100644 --- a/client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractTrinoResultSet.java +++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractTrinoResultSet.java @@ -141,7 +141,7 @@ abstract class AbstractTrinoResultSet .put("interval day to second", TrinoIntervalDayTime.class) .put("map", Map.class) .put("row", Row.class) - .build(); + .buildOrThrow(); @VisibleForTesting static final TypeConversions TYPE_CONVERSIONS = diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/ConnectionProperties.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/ConnectionProperties.java index 982332434845..16dfacc8aea3 100644 --- a/client/trino-jdbc/src/main/java/io/trino/jdbc/ConnectionProperties.java +++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/ConnectionProperties.java @@ -131,7 +131,7 @@ enum SslVerificationMode for (ConnectionProperty property : ALL_PROPERTIES) { property.getDefault().ifPresent(value -> defaults.put(property.getKey(), value)); } - DEFAULTS = defaults.build(); + DEFAULTS = defaults.buildOrThrow(); } private ConnectionProperties() {} diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java index 2536b04b1921..9e4feace4d65 100644 --- a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java +++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java @@ -227,7 +227,7 @@ private Map getStatementSessionProperties() if (queryTimeoutSeconds.get() > 0) { sessionProperties.put("query_max_run_time", queryTimeoutSeconds.get() + "s"); } - return sessionProperties.build(); + return sessionProperties.buildOrThrow(); } @Override diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcConnection.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcConnection.java index e342be2a0e9b..7d12e68ec320 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcConnection.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcConnection.java @@ -91,7 +91,7 @@ public void setupServer() .put("hive.metastore", "file") .put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toAbsolutePath().toString()) .put("hive.security", "sql-standard") - .build()); + .buildOrThrow()); server.installPlugin(new BlackHolePlugin()); server.createCatalog("blackhole", "blackhole", ImmutableMap.of()); @@ -350,7 +350,7 @@ public void testExtraCredentials() .put("test.token.foo", "bar") .put("test.token.abc", "xyz") .put("colon", "-::-") - .build(); + .buildOrThrow(); TrinoConnection trinoConnection = connection.unwrap(TrinoConnection.class); assertEquals(trinoConnection.getExtraCredentials(), expectedCredentials); assertEquals(listExtraCredentials(connection), expectedCredentials); @@ -591,7 +591,7 @@ private static Map listExtraCredentials(Connection connection) builder.put(rs.getString("name"), rs.getString("value")); } } - return builder.build(); + return builder.buildOrThrow(); } private static Set listCurrentRoles(Connection connection) diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcExternalAuthentication.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcExternalAuthentication.java index 8bc1cf91f3c9..d6fc9e94da78 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcExternalAuthentication.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcExternalAuthentication.java @@ -106,7 +106,7 @@ public void setup() .put("http-server.https.keystore.path", new File(getResource("localhost.keystore").toURI()).getPath()) .put("http-server.https.keystore.key", "changeit") .put("web-ui.enabled", "false") - .build()) + .buildOrThrow()) .build(); server.installPlugin(new TpchPlugin()); server.createCatalog(TEST_CATALOG, "tpch"); diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcWarnings.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcWarnings.java index d0bfcb68df45..daba7f34344d 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcWarnings.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcWarnings.java @@ -75,7 +75,7 @@ public void setupServer() .setProperties(ImmutableMap.builder() .put("testing-warning-collector.add-warnings", "true") .put("testing-warning-collector.preloaded-warnings", String.valueOf(PRELOADED_WARNINGS)) - .build()) + .buildOrThrow()) .build(); server.installPlugin(new BlackHolePlugin()); server.createCatalog("blackhole", "blackhole"); diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDatabaseMetaData.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDatabaseMetaData.java index 76a4d4f70d72..6503ba72545a 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDatabaseMetaData.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDatabaseMetaData.java @@ -119,7 +119,7 @@ public void setupServer() .put("hive.metastore", "file") .put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toAbsolutePath().toString()) .put("hive.security", "sql-standard") - .build()); + .buildOrThrow()); countingMockConnector = new CountingMockConnector(); server.installPlugin(countingMockConnector.getPlugin()); diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverAuth.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverAuth.java index 40aa86179895..099c16a9a421 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverAuth.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverAuth.java @@ -81,7 +81,7 @@ public void setup() .put("http-server.https.enabled", "true") .put("http-server.https.keystore.path", new File(getResource("localhost.keystore").toURI()).getPath()) .put("http-server.https.keystore.key", "changeit") - .build()) + .buildOrThrow()) .build(); server.installPlugin(new TpchPlugin()); server.createCatalog(TEST_CATALOG, "tpch"); diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverImpersonateUser.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverImpersonateUser.java index e50b27816c6c..acb7e919e2f8 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverImpersonateUser.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverImpersonateUser.java @@ -60,7 +60,7 @@ public void setup() .put("http-server.https.enabled", "true") .put("http-server.https.keystore.path", new File(getResource("localhost.keystore").toURI()).getPath()) .put("http-server.https.keystore.key", "changeit") - .build()) + .buildOrThrow()) .build(); server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestTrinoDriverImpersonateUser::authenticate); diff --git a/core/trino-main/src/main/java/io/trino/Session.java b/core/trino-main/src/main/java/io/trino/Session.java index b387883f6b59..d1c6e026e951 100644 --- a/core/trino-main/src/main/java/io/trino/Session.java +++ b/core/trino-main/src/main/java/io/trino/Session.java @@ -138,13 +138,13 @@ public Session( connectorProperties.entrySet().stream() .map(entry -> Maps.immutableEntry(entry.getKey(), ImmutableMap.copyOf(entry.getValue()))) .forEach(catalogPropertiesBuilder::put); - this.connectorProperties = catalogPropertiesBuilder.build(); + this.connectorProperties = catalogPropertiesBuilder.buildOrThrow(); ImmutableMap.Builder> unprocessedCatalogPropertiesBuilder = ImmutableMap.builder(); unprocessedCatalogProperties.entrySet().stream() .map(entry -> Maps.immutableEntry(entry.getKey(), ImmutableMap.copyOf(entry.getValue()))) .forEach(unprocessedCatalogPropertiesBuilder::put); - this.unprocessedCatalogProperties = unprocessedCatalogPropertiesBuilder.build(); + this.unprocessedCatalogProperties = unprocessedCatalogPropertiesBuilder.buildOrThrow(); checkArgument(transactionId.isEmpty() || unprocessedCatalogProperties.isEmpty(), "Catalog session properties cannot be set if there is an open transaction"); @@ -352,7 +352,7 @@ public Session beginTransactionId(TransactionId transactionId, TransactionManage Optional.of(transactionId), clientTransactionSupport, Identity.from(identity) - .withConnectorRoles(connectorRoles.build()) + .withConnectorRoles(connectorRoles.buildOrThrow()) .build(), source, catalog, @@ -369,7 +369,7 @@ public Session beginTransactionId(TransactionId transactionId, TransactionManage resourceEstimates, start, systemProperties, - connectorProperties.build(), + connectorProperties.buildOrThrow(), ImmutableMap.of(), sessionPropertyManager, preparedStatements, diff --git a/core/trino-main/src/main/java/io/trino/SessionRepresentation.java b/core/trino-main/src/main/java/io/trino/SessionRepresentation.java index f0c6ee60cf7a..7d269f414ba2 100644 --- a/core/trino-main/src/main/java/io/trino/SessionRepresentation.java +++ b/core/trino-main/src/main/java/io/trino/SessionRepresentation.java @@ -129,13 +129,13 @@ public SessionRepresentation( for (Entry> entry : catalogProperties.entrySet()) { catalogPropertiesBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); } - this.catalogProperties = catalogPropertiesBuilder.build(); + this.catalogProperties = catalogPropertiesBuilder.buildOrThrow(); ImmutableMap.Builder> unprocessedCatalogPropertiesBuilder = ImmutableMap.builder(); for (Entry> entry : unprocessedCatalogProperties.entrySet()) { unprocessedCatalogPropertiesBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); } - this.unprocessedCatalogProperties = unprocessedCatalogPropertiesBuilder.build(); + this.unprocessedCatalogProperties = unprocessedCatalogPropertiesBuilder.buildOrThrow(); } @JsonProperty diff --git a/core/trino-main/src/main/java/io/trino/connector/system/SystemTablesMetadata.java b/core/trino-main/src/main/java/io/trino/connector/system/SystemTablesMetadata.java index 13c5af412178..21b75218f657 100644 --- a/core/trino-main/src/main/java/io/trino/connector/system/SystemTablesMetadata.java +++ b/core/trino-main/src/main/java/io/trino/connector/system/SystemTablesMetadata.java @@ -136,7 +136,7 @@ public Map> listTableColumns(ConnectorSess builder.put(tableMetadata.getTable(), tableMetadata.getColumns()); } } - return builder.build(); + return builder.buildOrThrow(); } @Override diff --git a/core/trino-main/src/main/java/io/trino/connector/system/jdbc/ColumnJdbcTable.java b/core/trino-main/src/main/java/io/trino/connector/system/jdbc/ColumnJdbcTable.java index a0a68850e2a5..91f36a9de634 100644 --- a/core/trino-main/src/main/java/io/trino/connector/system/jdbc/ColumnJdbcTable.java +++ b/core/trino-main/src/main/java/io/trino/connector/system/jdbc/ColumnJdbcTable.java @@ -197,7 +197,7 @@ TABLE_SCHEMA_COLUMN, toNullableValue(schemaName)))) .map(CatalogSchemaName::getSchemaName) .collect(toVarcharDomain()) .simplify(MAX_DOMAIN_SIZE)) - .build()); + .buildOrThrow()); } List tables = schemas.stream() @@ -227,7 +227,7 @@ TABLE_NAME_COLUMN, toNullableValue(schemaTableName.getTableName())))) .map(catalogSchemaTableName -> catalogSchemaTableName.getSchemaTableName().getTableName()) .collect(toVarcharDomain()) .simplify(MAX_DOMAIN_SIZE)) - .build()); + .buildOrThrow()); } @Override diff --git a/core/trino-main/src/main/java/io/trino/cost/StatsAndCosts.java b/core/trino-main/src/main/java/io/trino/cost/StatsAndCosts.java index 8005b2767724..d69f9eb67dac 100644 --- a/core/trino-main/src/main/java/io/trino/cost/StatsAndCosts.java +++ b/core/trino-main/src/main/java/io/trino/cost/StatsAndCosts.java @@ -74,7 +74,7 @@ public StatsAndCosts getForSubplan(PlanNode root) filteredCosts.put(node.getId(), costs.get(node.getId())); } } - return new StatsAndCosts(filteredStats.build(), filteredCosts.build()); + return new StatsAndCosts(filteredStats.buildOrThrow(), filteredCosts.buildOrThrow()); } public static StatsAndCosts create(PlanNode root, StatsProvider statsProvider, CostProvider costProvider) @@ -87,7 +87,7 @@ public static StatsAndCosts create(PlanNode root, StatsProvider statsProvider, C stats.put(node.getId(), statsProvider.getStats(node)); costs.put(node.getId(), costProvider.getCost(node)); } - return new StatsAndCosts(stats.build(), costs.build()); + return new StatsAndCosts(stats.buildOrThrow(), costs.buildOrThrow()); } public static StatsAndCosts create(StageInfo stageInfo) @@ -95,7 +95,7 @@ public static StatsAndCosts create(StageInfo stageInfo) ImmutableMap.Builder planNodeStats = ImmutableMap.builder(); ImmutableMap.Builder planNodeCosts = ImmutableMap.builder(); reconstructStatsAndCosts(stageInfo, planNodeStats, planNodeCosts); - return new StatsAndCosts(planNodeStats.build(), planNodeCosts.build()); + return new StatsAndCosts(planNodeStats.buildOrThrow(), planNodeCosts.buildOrThrow()); } private static void reconstructStatsAndCosts( diff --git a/core/trino-main/src/main/java/io/trino/execution/SqlTaskExecution.java b/core/trino-main/src/main/java/io/trino/execution/SqlTaskExecution.java index 15529df5aa74..b702d17edc70 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SqlTaskExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/SqlTaskExecution.java @@ -211,7 +211,7 @@ private SqlTaskExecution( } } } - this.driverRunnerFactoriesWithSplitLifeCycle = driverRunnerFactoriesWithSplitLifeCycle.build(); + this.driverRunnerFactoriesWithSplitLifeCycle = driverRunnerFactoriesWithSplitLifeCycle.buildOrThrow(); this.driverRunnerFactoriesWithDriverGroupLifeCycle = driverRunnerFactoriesWithDriverGroupLifeCycle.build(); this.driverRunnerFactoriesWithTaskLifeCycle = driverRunnerFactoriesWithTaskLifeCycle.build(); @@ -1176,8 +1176,8 @@ public Status(TaskContext taskContext, Map p } this.pipelineWithTaskLifeCycleCount = pipelineWithTaskLifeCycleCount; this.pipelineWithDriverGroupLifeCycleCount = pipelineWithDriverGroupLifeCycleCount; - this.perPipelineAndLifespan = perPipelineAndLifespan.build(); - this.perPipeline = perPipeline.build(); + this.perPipelineAndLifespan = perPipelineAndLifespan.buildOrThrow(); + this.perPipeline = perPipeline.buildOrThrow(); } public synchronized void setNoMoreLifespans() diff --git a/core/trino-main/src/main/java/io/trino/execution/buffer/OutputBuffers.java b/core/trino-main/src/main/java/io/trino/execution/buffer/OutputBuffers.java index a4c42fd922bc..4c8555902886 100644 --- a/core/trino-main/src/main/java/io/trino/execution/buffer/OutputBuffers.java +++ b/core/trino-main/src/main/java/io/trino/execution/buffer/OutputBuffers.java @@ -186,7 +186,7 @@ public OutputBuffers withBuffer(OutputBufferId bufferId, int partition) ImmutableMap.builder() .putAll(buffers) .put(bufferId, partition) - .build()); + .buildOrThrow()); } public OutputBuffers withBuffers(Map buffers) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/FileBasedNetworkTopology.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/FileBasedNetworkTopology.java index 2ea9c6f14d54..85c03eb946d6 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/FileBasedNetworkTopology.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/FileBasedNetworkTopology.java @@ -131,7 +131,7 @@ private static Map loadTopologyFile(File topologyFile) topology.put(parts.get(0), new NetworkLocation(segments)); } - return topology.build(); + return topology.buildOrThrow(); } private static RuntimeException invalidFile(int lineNumber, String message) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/PartitionedOutputBufferManager.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/PartitionedOutputBufferManager.java index 21a4df964fb8..6eeea8b6a1b0 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/PartitionedOutputBufferManager.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/PartitionedOutputBufferManager.java @@ -40,7 +40,7 @@ public PartitionedOutputBufferManager(PartitioningHandle partitioningHandle, int } outputBuffers = createInitialEmptyOutputBuffers(requireNonNull(partitioningHandle, "partitioningHandle is null")) - .withBuffers(partitions.build()) + .withBuffers(partitions.buildOrThrow()) .withNoMoreBufferIds(); } diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java index 7bfe47e3335c..d089c9e265b4 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java @@ -162,7 +162,7 @@ public static PipelinedStageExecution createPipelinedStageExecution( failureDetector, executor, bucketToPartition, - exchangeSources.build(), + exchangeSources.buildOrThrow(), attempt); execution.initialize(); return execution; diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java index 5e34931fca1f..1696cbc6096b 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java @@ -510,12 +510,12 @@ private static StageManager create( } StageManager stageManager = new StageManager( queryStateMachine, - stages.build(), + stages.buildOrThrow(), coordinatorStagesInTopologicalOrder.build(), distributedStagesInTopologicalOrder.build(), rootStageId, - children.build(), - parents.build()); + children.buildOrThrow(), + parents.buildOrThrow()); stageManager.initialize(); return stageManager; } @@ -804,7 +804,7 @@ private static Map createOutputBuffersForSt } } - return result.build(); + return result.buildOrThrow(); } private static OutputBufferManager createSingleStreamOutputBuffer(SqlStage stage) @@ -827,7 +827,7 @@ private static Map> createBucketToPartitionForSt } } - return result.build(); + return result.buildOrThrow(); } private CoordinatorStagesScheduler( @@ -1171,7 +1171,7 @@ public static PipelinedDistributedStagesScheduler create( schedulerStats, stageManager, executionPolicy.createExecutionSchedule(stageExecutions.values()), - stageSchedulers.build(), + stageSchedulers.buildOrThrow(), ImmutableMap.copyOf(stageExecutions), dynamicFilterService); distributedStagesScheduler.initialize(); @@ -1192,7 +1192,7 @@ private static Map> createBucketToPartitionMap( result.put(childStage.getFragment().getId(), bucketToPartition); } } - return result.build(); + return result.buildOrThrow(); } private static Optional getBucketToPartition( @@ -1251,7 +1251,7 @@ else if (partitioningHandle.equals(SCALED_WRITER_DISTRIBUTION)) { result.put(fragmentId, outputBufferManager); } } - return result.build(); + return result.buildOrThrow(); } private static StageScheduler createStageScheduler( diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/TopologyAwareNodeSelectorFactory.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/TopologyAwareNodeSelectorFactory.java index 7f26f329b552..673b5a39e842 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/TopologyAwareNodeSelectorFactory.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/TopologyAwareNodeSelectorFactory.java @@ -107,7 +107,7 @@ public TopologyAwareNodeSelectorFactory( } this.placementCounters = placementCounters.build(); - this.placementCountersByName = placementCountersByName.build(); + this.placementCountersByName = placementCountersByName.buildOrThrow(); } public Map getPlacementCountersByName() diff --git a/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java b/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java index cbc749a4bfac..1256a24c9fff 100644 --- a/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java +++ b/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java @@ -214,7 +214,7 @@ public Map getStats() for (MonitoringTask task : tasks.values()) { builder.put(task.getService(), task.getStats()); } - return builder.build(); + return builder.buildOrThrow(); } @VisibleForTesting @@ -515,7 +515,7 @@ public synchronized Map getRecentFailuresByType() for (Map.Entry, DecayCounter> entry : failureCountByType.entrySet()) { builder.put(entry.getKey().getName(), entry.getValue().getCount()); } - return builder.build(); + return builder.buildOrThrow(); } } } diff --git a/core/trino-main/src/main/java/io/trino/memory/ClusterMemoryManager.java b/core/trino-main/src/main/java/io/trino/memory/ClusterMemoryManager.java index b789bdfb8141..586c4a268982 100644 --- a/core/trino-main/src/main/java/io/trino/memory/ClusterMemoryManager.java +++ b/core/trino-main/src/main/java/io/trino/memory/ClusterMemoryManager.java @@ -186,7 +186,7 @@ private Map createClusterMemoryPools(boolean re log.error(e, "Error exporting memory pool %s", poolId); } } - return builder.build(); + return builder.buildOrThrow(); } @Override @@ -364,7 +364,7 @@ public synchronized Map getMemoryPoolInfo() { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); pools.forEach((poolId, memoryPool) -> builder.put(poolId, memoryPool.getInfo())); - return builder.build(); + return builder.buildOrThrow(); } private synchronized boolean isClusterOutOfMemory() diff --git a/core/trino-main/src/main/java/io/trino/memory/LocalMemoryManager.java b/core/trino-main/src/main/java/io/trino/memory/LocalMemoryManager.java index 766465ee1b34..584243bba255 100644 --- a/core/trino-main/src/main/java/io/trino/memory/LocalMemoryManager.java +++ b/core/trino-main/src/main/java/io/trino/memory/LocalMemoryManager.java @@ -74,7 +74,7 @@ private void configureMemoryPools(NodeMemoryConfig config, long availableMemory) } verify(generalPoolSize > 0, "general memory pool size is 0"); builder.put(GENERAL_POOL, new MemoryPool(GENERAL_POOL, DataSize.ofBytes(generalPoolSize))); - this.pools = builder.build(); + this.pools = builder.buildOrThrow(); } private void validateHeapHeadroom(NodeMemoryConfig config, long availableMemory) @@ -98,7 +98,7 @@ public MemoryInfo getInfo() for (Map.Entry entry : pools.entrySet()) { builder.put(entry.getKey(), entry.getValue().getInfo()); } - return new MemoryInfo(OPERATING_SYSTEM_MX_BEAN.getAvailableProcessors(), maxMemory, builder.build()); + return new MemoryInfo(OPERATING_SYSTEM_MX_BEAN.getAvailableProcessors(), maxMemory, builder.buildOrThrow()); } public List getPools() diff --git a/core/trino-main/src/main/java/io/trino/metadata/AbstractPropertyManager.java b/core/trino-main/src/main/java/io/trino/metadata/AbstractPropertyManager.java index 874ded5dab1f..faf9102c2530 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/AbstractPropertyManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/AbstractPropertyManager.java @@ -133,10 +133,10 @@ protected final Map doGetProperties( properties.put(property.getName(), value); } - Map userSpecifiedProperties = properties.build(); + Map userSpecifiedProperties = properties.buildOrThrow(); if (!setDefaultProperties) { - return properties.build(); + return properties.buildOrThrow(); } // Fill in the remaining properties with non-null defaults for (PropertyMetadata propertyMetadata : supportedProperties.values()) { @@ -147,7 +147,7 @@ protected final Map doGetProperties( } } } - return properties.build(); + return properties.buildOrThrow(); } protected final Map>> doGetAllProperties() diff --git a/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java b/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java index bf8c22d67ac9..dc8218116b17 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java +++ b/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java @@ -912,7 +912,7 @@ public FunctionMap(FunctionMap map, Collection functions) this.functions = ImmutableMap.builder() .putAll(map.functions) .putAll(Maps.uniqueIndex(functions, function -> function.getFunctionMetadata().getFunctionId())) - .build(); + .buildOrThrow(); ImmutableListMultimap.Builder functionsByName = ImmutableListMultimap.builder() .putAll(map.functionsByName); diff --git a/core/trino-main/src/main/java/io/trino/metadata/InternalTable.java b/core/trino-main/src/main/java/io/trino/metadata/InternalTable.java index 4b19ace8e7a3..85327791f069 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/InternalTable.java +++ b/core/trino-main/src/main/java/io/trino/metadata/InternalTable.java @@ -85,7 +85,7 @@ public Builder(List columnNames, List types) for (String columnName : columnNames) { columnIndexes.put(columnName, columnIndex++); } - this.columnIndexes = columnIndexes.build(); + this.columnIndexes = columnIndexes.buildOrThrow(); this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); checkArgument(columnNames.size() == types.size(), diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java index 2bc9c0c00f1e..d2c4ebd5bae6 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java @@ -245,6 +245,6 @@ public static Map> listTableColumns(Sessio .collect(toImmutableList())); }); - return result.build(); + return result.buildOrThrow(); } } 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 0b66a770cf5e..1162bfd1705b 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 @@ -532,7 +532,7 @@ public Map getColumnHandles(Session session, TableHandle t for (Entry mapEntry : handles.entrySet()) { map.put(mapEntry.getKey().toLowerCase(ENGLISH), mapEntry.getValue()); } - return map.build(); + return map.buildOrThrow(); } @Override diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataUtil.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataUtil.java index 5beb0310270d..d8f93f5f4c34 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataUtil.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataUtil.java @@ -283,7 +283,7 @@ public TableMetadataBuilder property(String name, Object value) public ConnectorTableMetadata build() { - return new ConnectorTableMetadata(tableName, columns.build(), properties.build(), comment); + return new ConnectorTableMetadata(tableName, columns.build(), properties.buildOrThrow(), comment); } } } diff --git a/core/trino-main/src/main/java/io/trino/operator/DynamicFilterSourceOperator.java b/core/trino-main/src/main/java/io/trino/operator/DynamicFilterSourceOperator.java index fd0dc5ed40aa..731cab4047dc 100644 --- a/core/trino-main/src/main/java/io/trino/operator/DynamicFilterSourceOperator.java +++ b/core/trino-main/src/main/java/io/trino/operator/DynamicFilterSourceOperator.java @@ -386,7 +386,7 @@ public void finish() } minValues = null; maxValues = null; - dynamicPredicateConsumer.accept(TupleDomain.withColumnDomains(domainsBuilder.build())); + dynamicPredicateConsumer.accept(TupleDomain.withColumnDomains(domainsBuilder.buildOrThrow())); return; } for (int channelIndex = 0; channelIndex < channels.size(); ++channelIndex) { @@ -396,7 +396,7 @@ public void finish() } valueSets = null; blockBuilders = null; - dynamicPredicateConsumer.accept(TupleDomain.withColumnDomains(domainsBuilder.build())); + dynamicPredicateConsumer.accept(TupleDomain.withColumnDomains(domainsBuilder.buildOrThrow())); } private Domain convertToDomain(Type type, Block block) diff --git a/core/trino-main/src/main/java/io/trino/operator/ParametricImplementationsGroup.java b/core/trino-main/src/main/java/io/trino/operator/ParametricImplementationsGroup.java index 3feacf67c64a..457006f3b12f 100644 --- a/core/trino-main/src/main/java/io/trino/operator/ParametricImplementationsGroup.java +++ b/core/trino-main/src/main/java/io/trino/operator/ParametricImplementationsGroup.java @@ -150,7 +150,7 @@ private Builder() {} public ParametricImplementationsGroup build() { - Map exactImplementations = this.exactImplementations.build(); + Map exactImplementations = this.exactImplementations.buildOrThrow(); List specializedImplementations = this.specializedImplementations.build(); List genericImplementations = this.genericImplementations.build(); return new ParametricImplementationsGroup<>( diff --git a/core/trino-main/src/main/java/io/trino/operator/WindowOperator.java b/core/trino-main/src/main/java/io/trino/operator/WindowOperator.java index 306435aad0a5..2f7f1fbb4da8 100644 --- a/core/trino-main/src/main/java/io/trino/operator/WindowOperator.java +++ b/core/trino-main/src/main/java/io/trino/operator/WindowOperator.java @@ -478,7 +478,7 @@ private static Map createFrameBoundComparat } } - return builder.build(); + return builder.buildOrThrow(); } public static class FrameBoundKey diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/ApproximateMostFrequentHistogram.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/ApproximateMostFrequentHistogram.java index 667dc647be35..a51564404dec 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/ApproximateMostFrequentHistogram.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/ApproximateMostFrequentHistogram.java @@ -148,7 +148,7 @@ public Map getBuckets() ImmutableMap.Builder buckets = new ImmutableMap.Builder<>(); forEachBucket(buckets::put); - return buckets.build(); + return buckets.buildOrThrow(); } public long estimatedInMemorySize() diff --git a/core/trino-main/src/main/java/io/trino/operator/scalar/WordStemFunction.java b/core/trino-main/src/main/java/io/trino/operator/scalar/WordStemFunction.java index f71dec06122b..e258d38f60ef 100644 --- a/core/trino-main/src/main/java/io/trino/operator/scalar/WordStemFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/scalar/WordStemFunction.java @@ -73,7 +73,7 @@ private WordStemFunction() {} .put(utf8Slice("ru"), RussianStemmer::new) .put(utf8Slice("sv"), SwedishStemmer::new) .put(utf8Slice("tr"), TurkishStemmer::new) - .build(); + .buildOrThrow(); @Description("Returns the stem of a word in the English language") @ScalarFunction diff --git a/core/trino-main/src/main/java/io/trino/server/DynamicFilterService.java b/core/trino-main/src/main/java/io/trino/server/DynamicFilterService.java index dad10dc056d5..26b4ff70bc25 100644 --- a/core/trino-main/src/main/java/io/trino/server/DynamicFilterService.java +++ b/core/trino-main/src/main/java/io/trino/server/DynamicFilterService.java @@ -755,7 +755,7 @@ void addDynamicFilterConsumer(Set dynamicFilterIds, Consumer collectedDomains = collectedDomainsBuilder.build(); + Map collectedDomains = collectedDomainsBuilder.buildOrThrow(); if (!collectedDomains.isEmpty()) { consumer.accept(collectedDomains); } diff --git a/core/trino-main/src/main/java/io/trino/server/HttpRequestSessionContextFactory.java b/core/trino-main/src/main/java/io/trino/server/HttpRequestSessionContextFactory.java index cffd39c98716..e492a2c7a449 100644 --- a/core/trino-main/src/main/java/io/trino/server/HttpRequestSessionContextFactory.java +++ b/core/trino-main/src/main/java/io/trino/server/HttpRequestSessionContextFactory.java @@ -173,7 +173,7 @@ else if (nameParts.size() == 2) { clientTags, clientCapabilities, resourceEstimates, - systemProperties.build(), + systemProperties.buildOrThrow(), catalogSessionProperties, preparedStatements, transactionId, @@ -297,7 +297,7 @@ private static Map parseConnectorRoleHeaders(ProtocolHeade } roles.put(key, toSelectedRole(protocolHeaders, value)); }); - return roles.build(); + return roles.buildOrThrow(); } private static SelectedRole toSelectedRole(ProtocolHeaders protocolHeaders, String value) @@ -402,7 +402,7 @@ private static Map parsePreparedStatementsHeaders(ProtocolHeader preparedStatements.put(statementName, sqlString); }); - return preparedStatements.build(); + return preparedStatements.buildOrThrow(); } private static Optional parseTransactionId(String transactionId) diff --git a/core/trino-main/src/main/java/io/trino/server/security/oauth2/ScribeJavaOAuth2Client.java b/core/trino-main/src/main/java/io/trino/server/security/oauth2/ScribeJavaOAuth2Client.java index 9fc0ad9b00d9..d832250a2cd8 100644 --- a/core/trino-main/src/main/java/io/trino/server/security/oauth2/ScribeJavaOAuth2Client.java +++ b/core/trino-main/src/main/java/io/trino/server/security/oauth2/ScribeJavaOAuth2Client.java @@ -55,7 +55,7 @@ public URI getAuthorizationUri(String state, URI callbackUri, Optional n parameters.put(REDIRECT_URI, callbackUri.toString()); parameters.put(STATE, state); nonceHash.ifPresent(n -> parameters.put(NONCE, n)); - return URI.create(service.getAuthorizationUrl(parameters.build())); + return URI.create(service.getAuthorizationUrl(parameters.buildOrThrow())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/server/testing/TestingTrinoServer.java b/core/trino-main/src/main/java/io/trino/server/testing/TestingTrinoServer.java index 581efd306991..8f5398b87e8a 100644 --- a/core/trino-main/src/main/java/io/trino/server/testing/TestingTrinoServer.java +++ b/core/trino-main/src/main/java/io/trino/server/testing/TestingTrinoServer.java @@ -284,7 +284,7 @@ private TestingTrinoServer( injector = app .doNotInitializeLogging() - .setRequiredConfigurationProperties(serverProperties.build()) + .setRequiredConfigurationProperties(serverProperties.buildOrThrow()) .setOptionalConfigurationProperties(optionalProperties) .quiet() .initialize(); diff --git a/core/trino-main/src/main/java/io/trino/sql/ParameterUtils.java b/core/trino-main/src/main/java/io/trino/sql/ParameterUtils.java index a696a930c91d..968733ee6bef 100644 --- a/core/trino-main/src/main/java/io/trino/sql/ParameterUtils.java +++ b/core/trino-main/src/main/java/io/trino/sql/ParameterUtils.java @@ -46,6 +46,6 @@ public static Map, Expression> parameterExtractor(Statement s for (Parameter parameter : parametersList) { builder.put(NodeRef.of(parameter), iterator.next()); } - return builder.build(); + return builder.buildOrThrow(); } } diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/ExpressionAnalyzer.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/ExpressionAnalyzer.java index 53eec241bf1c..c5ecb64dc1e8 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/ExpressionAnalyzer.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/ExpressionAnalyzer.java @@ -2386,7 +2386,7 @@ protected Type visitLambdaExpression(LambdaExpression node, StackableAstVisitorC fieldToLambdaArgumentDeclaration.put(FieldId.from(resolvedField), lambdaArgument); } - Type returnType = process(node.getBody(), new StackableAstVisitorContext<>(context.getContext().inLambda(lambdaScope, fieldToLambdaArgumentDeclaration.build()))); + Type returnType = process(node.getBody(), new StackableAstVisitorContext<>(context.getContext().inLambda(lambdaScope, fieldToLambdaArgumentDeclaration.buildOrThrow()))); FunctionType functionType = new FunctionType(types, returnType); return setExpressionType(node, functionType); } diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/PatternRecognitionAnalyzer.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/PatternRecognitionAnalyzer.java index 80c83afb41d5..51cf4750bfc9 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/PatternRecognitionAnalyzer.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/PatternRecognitionAnalyzer.java @@ -177,7 +177,7 @@ public static PatternRecognitionAnalysis analyze( throw semanticException(NESTED_ROW_PATTERN_RECOGNITION, nested, "nested row pattern recognition in row pattern recognition"); })); - return new PatternRecognitionAnalysis(allLabels, undefinedLabels, ranges.build()); + return new PatternRecognitionAnalysis(allLabels, undefinedLabels, ranges.buildOrThrow()); } public static void validateNoPatternSearchMode(Optional patternSearchMode) diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/RelationType.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/RelationType.java index d85de424c44f..ab67909c6bb8 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/RelationType.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/RelationType.java @@ -58,7 +58,7 @@ public RelationType(List fields) for (Field field : fields) { builder.put(field, index++); } - fieldIndexes = builder.build(); + fieldIndexes = builder.buildOrThrow(); } /** 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 6d6438a1eb73..d9172b9532be 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 @@ -1433,7 +1433,7 @@ else if (expressionType instanceof MapType) { ordinalityField.ifPresent(outputFields::add); - analysis.setUnnest(node, new UnnestAnalysis(mappings.build(), ordinalityField)); + analysis.setUnnest(node, new UnnestAnalysis(mappings.buildOrThrow(), ordinalityField)); return createAndAssignScope(node, scope, outputFields.build()); } @@ -1932,7 +1932,7 @@ protected Scope visitPatternRecognitionRelation(PatternRecognitionRelation relat analysis.recordSubqueries(relation, expressionAnalysis); measureTypesBuilder.put(NodeRef.of(expression), expressionAnalysis.getType(expression)); } - Map, Type> measureTypes = measureTypesBuilder.build(); + Map, Type> measureTypes = measureTypesBuilder.buildOrThrow(); // create output scope // ONE ROW PER MATCH: PARTITION BY columns, then MEASURES columns in order of declaration diff --git a/core/trino-main/src/main/java/io/trino/sql/gen/CursorProcessorCompiler.java b/core/trino-main/src/main/java/io/trino/sql/gen/CursorProcessorCompiler.java index aa0cbdebacf6..f0557434ad68 100644 --- a/core/trino-main/src/main/java/io/trino/sql/gen/CursorProcessorCompiler.java +++ b/core/trino-main/src/main/java/io/trino/sql/gen/CursorProcessorCompiler.java @@ -208,7 +208,7 @@ private Map generateMethodsForLambda lambdaExpression, methodName, containerClassDefinition, - compiledLambdaMap.build(), + compiledLambdaMap.buildOrThrow(), callSiteBinder, cachedInstanceBinder, metadata); @@ -216,7 +216,7 @@ private Map generateMethodsForLambda counter++; } - return compiledLambdaMap.build(); + return compiledLambdaMap.buildOrThrow(); } private void generateFilterMethod( diff --git a/core/trino-main/src/main/java/io/trino/sql/gen/IsolatedClass.java b/core/trino-main/src/main/java/io/trino/sql/gen/IsolatedClass.java index e152dbe02c2c..c52f20c594ba 100644 --- a/core/trino-main/src/main/java/io/trino/sql/gen/IsolatedClass.java +++ b/core/trino-main/src/main/java/io/trino/sql/gen/IsolatedClass.java @@ -42,7 +42,7 @@ public static Class isolateClass( } // load classes into a private class loader - Map> isolatedClasses = dynamicClassLoader.defineClasses(builder.build()); + Map> isolatedClasses = dynamicClassLoader.defineClasses(builder.buildOrThrow()); Class isolatedClass = isolatedClasses.get(implementationClass.getName()); // verify the isolated class diff --git a/core/trino-main/src/main/java/io/trino/sql/gen/JoinFilterFunctionCompiler.java b/core/trino-main/src/main/java/io/trino/sql/gen/JoinFilterFunctionCompiler.java index 76c76e794cc5..30d0f545bf08 100644 --- a/core/trino-main/src/main/java/io/trino/sql/gen/JoinFilterFunctionCompiler.java +++ b/core/trino-main/src/main/java/io/trino/sql/gen/JoinFilterFunctionCompiler.java @@ -225,7 +225,7 @@ private Map generateMethodsForLambda lambdaExpression, "lambda_" + counter, containerClassDefinition, - compiledLambdaMap.build(), + compiledLambdaMap.buildOrThrow(), callSiteBinder, cachedInstanceBinder, metadata); @@ -233,7 +233,7 @@ private Map generateMethodsForLambda counter++; } - return compiledLambdaMap.build(); + return compiledLambdaMap.buildOrThrow(); } private static void generateToString(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, String string) diff --git a/core/trino-main/src/main/java/io/trino/sql/gen/LambdaBytecodeGenerator.java b/core/trino-main/src/main/java/io/trino/sql/gen/LambdaBytecodeGenerator.java index d114054b7ab6..89448b680858 100644 --- a/core/trino-main/src/main/java/io/trino/sql/gen/LambdaBytecodeGenerator.java +++ b/core/trino-main/src/main/java/io/trino/sql/gen/LambdaBytecodeGenerator.java @@ -92,7 +92,7 @@ public static Map generateMethodsFor lambdaExpression, "lambda_" + counter, containerClassDefinition, - compiledLambdaMap.build(), + compiledLambdaMap.buildOrThrow(), callSiteBinder, cachedInstanceBinder, metadata); @@ -100,7 +100,7 @@ public static Map generateMethodsFor counter++; } - return compiledLambdaMap.build(); + return compiledLambdaMap.buildOrThrow(); } /** @@ -130,7 +130,7 @@ public static CompiledLambda preGenerateLambdaExpression( RowExpressionCompiler innerExpressionCompiler = new RowExpressionCompiler( callSiteBinder, cachedInstanceBinder, - variableReferenceCompiler(parameterMapBuilder.build()), + variableReferenceCompiler(parameterMapBuilder.buildOrThrow()), metadata, compiledLambdaMap); diff --git a/core/trino-main/src/main/java/io/trino/sql/gen/PageFunctionCompiler.java b/core/trino-main/src/main/java/io/trino/sql/gen/PageFunctionCompiler.java index 546190cbbefb..586dfa1c05d3 100644 --- a/core/trino-main/src/main/java/io/trino/sql/gen/PageFunctionCompiler.java +++ b/core/trino-main/src/main/java/io/trino/sql/gen/PageFunctionCompiler.java @@ -556,7 +556,7 @@ private Map generateMethodsForLambda lambdaExpression, "lambda_" + counter, containerClassDefinition, - compiledLambdaMap.build(), + compiledLambdaMap.buildOrThrow(), callSiteBinder, cachedInstanceBinder, metadata); @@ -564,7 +564,7 @@ private Map generateMethodsForLambda counter++; } - return compiledLambdaMap.build(); + return compiledLambdaMap.buildOrThrow(); } private static void generateConstructor( diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/EffectivePredicateExtractor.java b/core/trino-main/src/main/java/io/trino/sql/planner/EffectivePredicateExtractor.java index 9312b195b957..cf46c0aa9800 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/EffectivePredicateExtractor.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/EffectivePredicateExtractor.java @@ -471,7 +471,7 @@ else if (hasNaN[i]) { } // simplify to avoid a large expression if there are many rows in ValuesNode - return domainTranslator.toPredicate(session, TupleDomain.withColumnDomains(domains.build()).simplify()); + return domainTranslator.toPredicate(session, TupleDomain.withColumnDomains(domains.buildOrThrow()).simplify()); } private boolean hasNestedNulls(Type type, Object value) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/EqualityInference.java b/core/trino-main/src/main/java/io/trino/sql/planner/EqualityInference.java index bbc3084319bb..e10a408311e6 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/EqualityInference.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/EqualityInference.java @@ -248,7 +248,7 @@ public static EqualityInference newInstance(Metadata metadata, Collection, Type> coercions = ImmutableMap., Type>builder() .putAll(analyzer.getExpressionCoercions()) .put(NodeRef.of(expression), expectedType) - .build(); + .buildOrThrow(); return evaluateConstantExpression(expression, coercions, analyzer.getTypeOnlyCoercions(), plannerContext, session, accessControl, ImmutableSet.of(), parameters); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java index f5af2b834033..c52106aa56f1 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java @@ -967,7 +967,7 @@ public PhysicalOperation visitRowNumber(RowNumberNode node, LocalExecutionPlanCo 10_000, joinCompiler, blockTypeOperators); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, source); } @Override @@ -1150,7 +1150,7 @@ public PhysicalOperation visitWindow(WindowNode node, LocalExecutionPlanContext ImmutableList.of(), new RegularPartitionerSupplier()); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, source); } private WindowFunctionSupplier getWindowFunctionImplementation(ResolvedFunction resolvedFunction) @@ -1263,7 +1263,7 @@ public PhysicalOperation visitPatternRecognition(PatternRecognitionNode node, Lo labelNamesBuilder.add(label.getName()); mappingBuilder.put(label, i); } - Map mapping = mappingBuilder.build(); + Map mapping = mappingBuilder.buildOrThrow(); List labelNames = labelNamesBuilder.build(); // 2. rewrite pattern to program @@ -1408,7 +1408,7 @@ public PhysicalOperation visitPatternRecognition(PatternRecognitionNode node, Lo .collect(toImmutableList()), partitionerSupplier); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, source); } private Supplier prepareProjection(ExpressionAndValuePointers expressionAndValuePointers, LocalExecutionPlanContext context) @@ -1444,7 +1444,7 @@ else if (matchNumberSymbols.contains(inputSymbols.get(i))) { } // compile expression using input layout and input types - RowExpression rowExpression = toRowExpression(rewritten, typeAnalyzer.getTypes(session, TypeProvider.viewOf(inputTypes.build()), rewritten), inputLayout.build()); + RowExpression rowExpression = toRowExpression(rewritten, typeAnalyzer.getTypes(session, TypeProvider.viewOf(inputTypes.buildOrThrow()), rewritten), inputLayout.buildOrThrow()); return pageFunctionCompiler.compileProjection(rowExpression, Optional.empty()); } @@ -1603,7 +1603,7 @@ else if (inputSymbols.get(i).equals(matchNumberSymbol)) { } // compile expression using input layout and input types - RowExpression rowExpression = toRowExpression(argument, typeAnalyzer.getTypes(session, TypeProvider.viewOf(inputTypes.build()), argument), inputLayout.build()); + RowExpression rowExpression = toRowExpression(argument, typeAnalyzer.getTypes(session, TypeProvider.viewOf(inputTypes.buildOrThrow()), argument), inputLayout.buildOrThrow()); return pageFunctionCompiler.compileProjection(rowExpression, Optional.empty()); } @@ -1738,7 +1738,7 @@ public PhysicalOperation visitGroupId(GroupIdNode node, LocalExecutionPlanContex setMapping.put(newLayout.get(output), argumentMappings.get(output)); } - mappings.add(setMapping.build()); + mappings.add(setMapping.buildOrThrow()); } newLayout.put(node.getGroupIdSymbol(), outputChannel); @@ -1880,7 +1880,7 @@ else if (sourceNode instanceof SampleNode) { Symbol symbol = outputSymbols.get(i); outputMappingsBuilder.put(symbol, i); } - Map outputMappings = outputMappingsBuilder.build(); + Map outputMappings = outputMappingsBuilder.buildOrThrow(); Optional staticFilters = filterExpression.flatMap(this::getStaticFilter); DynamicFilter dynamicFilter = filterExpression @@ -2088,7 +2088,7 @@ public PhysicalOperation visitUnnest(UnnestNode node, LocalExecutionPlanContext unnestTypes.build(), ordinalityType.isPresent(), outer); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, source); } private ImmutableMap makeLayout(PlanNode node) @@ -2104,7 +2104,7 @@ private ImmutableMap makeLayoutFromOutputSymbols(List o outputMappings.put(symbol, channel); channel++; } - return outputMappings.build(); + return outputMappings.buildOrThrow(); } @Override @@ -2324,7 +2324,7 @@ public PhysicalOperation visitIndexJoin(IndexJoinNode node, LocalExecutionPlanCo default: throw new AssertionError("Unknown type: " + node.getType()); } - return new PhysicalOperation(lookupJoinOperatorFactory, outputMappings.build(), context, probeSource); + return new PhysicalOperation(lookupJoinOperatorFactory, outputMappings.buildOrThrow(), context, probeSource); } @Override @@ -2527,7 +2527,7 @@ private PhysicalOperation createNestedLoopJoin(JoinNode node, Set buildChannels = getChannelsForSymbols(node.getRightOutputSymbols(), buildSource.getLayout()); OperatorFactory operatorFactory = new NestedLoopJoinOperatorFactory(context.getNextOperatorId(), node.getId(), nestedLoopJoinBridgeManager, probeChannels, buildChannels); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, probeSource); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, probeSource); } private PhysicalOperation createSpatialLookupJoin( @@ -2563,7 +2563,7 @@ private PhysicalOperation createSpatialLookupJoin( outputMappings.put(symbol, i); } - return new PhysicalOperation(operator, outputMappings.build(), context, probeSource); + return new PhysicalOperation(operator, outputMappings.buildOrThrow(), context, probeSource); } private OperatorFactory createSpatialLookupJoin( @@ -2689,7 +2689,7 @@ private PhysicalOperation createLookupJoin( outputMappings.put(symbol, i); } - return new PhysicalOperation(operator, outputMappings.build(), context, probeSource); + return new PhysicalOperation(operator, outputMappings.buildOrThrow(), context, probeSource); } private JoinBridgeManager createLookupSourceFactory( @@ -2994,7 +2994,7 @@ private Map createJoinSourcesLayout(Map lookup for (Map.Entry probeLayoutEntry : probeSourceLayout.entrySet()) { joinSourcesLayout.put(probeLayoutEntry.getKey(), probeLayoutEntry.getValue() + lookupSourceLayout.size()); } - return joinSourcesLayout.build(); + return joinSourcesLayout.buildOrThrow(); } @Override @@ -3079,7 +3079,7 @@ public PhysicalOperation visitSemiJoin(SemiJoinNode node, LocalExecutionPlanCont Map outputMappings = ImmutableMap.builder() .putAll(probeSource.getLayout()) .put(node.getSemiJoinOutput(), probeSource.getLayout().size()) - .build(); + .buildOrThrow(); OperatorFactory operator = HashSemiJoinOperator.createOperatorFactory(context.getNextOperatorId(), node.getId(), setProvider, probeSource.getTypes(), probeChannel, probeHashChannel); return new PhysicalOperation(operator, outputMappings, context, probeSource); @@ -3173,7 +3173,7 @@ public PhysicalOperation visitTableWriter(TableWriterNode node, LocalExecutionPl statisticsAggregation, getSymbolTypes(node.getOutputSymbols(), context.getTypes())); - return new PhysicalOperation(operatorFactory, outputMapping.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMapping.buildOrThrow(), context, source); } @Override @@ -3234,7 +3234,7 @@ public PhysicalOperation visitTableFinish(TableFinishNode node, LocalExecutionPl true); }).orElse(new DevNullOperatorFactory(context.getNextOperatorId(), node.getId())); - Map aggregationOutput = outputMapping.build(); + Map aggregationOutput = outputMapping.buildOrThrow(); StatisticAggregationsDescriptor descriptor = node.getStatisticsAggregationDescriptor() .map(desc -> desc.map(aggregationOutput::get)) .orElse(StatisticAggregationsDescriptor.empty()); @@ -3263,7 +3263,7 @@ public PhysicalOperation visitDelete(DeleteNode node, LocalExecutionPlanContext Map layout = ImmutableMap.builder() .put(node.getOutputSymbols().get(0), 0) .put(node.getOutputSymbols().get(1), 1) - .build(); + .buildOrThrow(); return new PhysicalOperation(operatorFactory, layout, context, source); } @@ -3278,7 +3278,7 @@ public PhysicalOperation visitUpdate(UpdateNode node, LocalExecutionPlanContext Map layout = ImmutableMap.builder() .put(node.getOutputSymbols().get(0), 0) .put(node.getOutputSymbols().get(1), 1) - .build(); + .buildOrThrow(); return new PhysicalOperation(operatorFactory, layout, context, source); } @@ -3323,7 +3323,7 @@ public PhysicalOperation visitTableExecute(TableExecuteNode node, LocalExecution new DevNullOperatorFactory(context.getNextOperatorId(), node.getId()), // statistics are not calculated getSymbolTypes(node.getOutputSymbols(), context.getTypes())); - return new PhysicalOperation(operatorFactory, outputMapping.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMapping.buildOrThrow(), context, source); } @Override @@ -3659,7 +3659,7 @@ private List makeLambdaProviders(List lambdaEx .putAll(lambdaArgumentExpressionTypes) // expressions from lambda body .putAll(typeAnalyzer.getTypes(session, TypeProvider.copyOf(lambdaArgumentSymbolTypes), lambdaExpression.getBody())) - .build(); + .buildOrThrow(); LambdaDefinitionExpression lambda = (LambdaDefinitionExpression) toRowExpression(lambdaExpression, expressionTypes, ImmutableMap.of()); Class lambdaProviderClass = compileLambdaProvider(lambda, metadata, lambdaInterfaces.get(i)); @@ -3686,7 +3686,7 @@ private PhysicalOperation planGlobalAggregation(AggregationNode node, PhysicalOp source, context, node.getStep().isOutputPartial()); - return new PhysicalOperation(operatorFactory, outputMappings.build(), context, source); + return new PhysicalOperation(operatorFactory, outputMappings.buildOrThrow(), context, source); } private AggregationOperatorFactory createAggregationOperatorFactory( @@ -3738,7 +3738,7 @@ private PhysicalOperation planGroupByAggregation( 10_000, Optional.of(maxPartialAggregationMemorySize), node.getStep().isOutputPartial()); - return new PhysicalOperation(operatorFactory, mappings.build(), context, source); + return new PhysicalOperation(operatorFactory, mappings.buildOrThrow(), context, source); } private OperatorFactory createHashAggregationOperatorFactory( diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java index 901366c3df41..0bfe5a8b779a 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java @@ -339,7 +339,7 @@ private RelationPlan createAnalyzePlan(Analysis analysis, Analyze analyzeStateme targetTable.getCatalogName().getCatalogName(), tableMetadata.getMetadata()); - TableStatisticAggregation tableStatisticAggregation = statisticsAggregationPlanner.createStatisticsAggregation(tableStatisticsMetadata, columnNameToSymbol.build()); + TableStatisticAggregation tableStatisticAggregation = statisticsAggregationPlanner.createStatisticsAggregation(tableStatisticsMetadata, columnNameToSymbol.buildOrThrow()); StatisticAggregations statisticAggregations = tableStatisticAggregation.getAggregations(); List groupingSymbols = statisticAggregations.getGroupingSymbols(); @@ -347,7 +347,7 @@ private RelationPlan createAnalyzePlan(Analysis analysis, Analyze analyzeStateme idAllocator.getNextId(), new AggregationNode( idAllocator.getNextId(), - TableScanNode.newInstance(idAllocator.getNextId(), targetTable, tableScanOutputs.build(), symbolToColumnHandle.build(), false, Optional.empty()), + TableScanNode.newInstance(idAllocator.getNextId(), targetTable, tableScanOutputs.build(), symbolToColumnHandle.buildOrThrow(), false, Optional.empty()), statisticAggregations.getAggregations(), singleGroupingSet(groupingSymbols), ImmutableList.of(), diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/OptimizerStatsMBeanExporter.java b/core/trino-main/src/main/java/io/trino/sql/planner/OptimizerStatsMBeanExporter.java index 65601ad41282..7344ca1e32f4 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/OptimizerStatsMBeanExporter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/OptimizerStatsMBeanExporter.java @@ -66,7 +66,7 @@ public synchronized void export() mbeanExports.add(exporter.exportWithGeneratedName(entry.getValue(), PlanOptimizer.class, ImmutableMap.builder() .put("name", PlanOptimizer.class.getSimpleName()) .put("optimizer", entry.getKey().getSimpleName()) - .build())); + .buildOrThrow())); } catch (RuntimeException e) { throw new RuntimeException(format("Failed to export MBean with name '%s'", getName(entry.getKey())), e); @@ -79,7 +79,7 @@ public synchronized void export() mbeanExports.add(exporter.exportWithGeneratedName(entry.getValue(), IterativeOptimizer.class, ImmutableMap.builder() .put("name", IterativeOptimizer.class.getSimpleName()) .put("rule", entry.getKey().getSimpleName()) - .build())); + .buildOrThrow())); } catch (RuntimeException e) { throw new RuntimeException(format("Failed to export MBean with for rule '%s'", entry.getKey().getSimpleName()), e); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/RelationPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/RelationPlanner.java index c112292a9cc7..01702209cf77 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/RelationPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/RelationPlanner.java @@ -229,7 +229,7 @@ protected RelationPlan visitTable(Table node, Void context) List outputSymbols = outputSymbolsBuilder.build(); boolean updateTarget = analysis.isUpdateTarget(node); - PlanNode root = TableScanNode.newInstance(idAllocator.getNextId(), handle, outputSymbols, columns.build(), updateTarget, Optional.empty()); + PlanNode root = TableScanNode.newInstance(idAllocator.getNextId(), handle, outputSymbols, columns.buildOrThrow(), updateTarget, Optional.empty()); plan = new RelationPlan(root, scope, outputSymbols, outerContext); @@ -450,7 +450,7 @@ public PatternRecognitionComponents planPatternRecognitionComponents( Type type = analysis.getType(measureDefinition.getExpression()); Symbol symbol = symbolAllocator.newSymbol(measureDefinition.getName().getValue().toLowerCase(ENGLISH), type); Expression expression = expressionRewrite.apply(measureDefinition.getExpression()); - ExpressionAndValuePointers measure = LogicalIndexExtractor.rewrite(expression, rewrittenSubsets.build(), symbolAllocator, plannerContext.getMetadata()); + ExpressionAndValuePointers measure = LogicalIndexExtractor.rewrite(expression, rewrittenSubsets.buildOrThrow(), symbolAllocator, plannerContext.getMetadata()); rewrittenMeasures.put(symbol, new Measure(measure, type)); measureOutputs.add(symbol); } @@ -463,7 +463,7 @@ public PatternRecognitionComponents planPatternRecognitionComponents( for (VariableDefinition variableDefinition : variableDefinitions) { IrLabel label = irLabel(variableDefinition.getName()); Expression expression = expressionRewrite.apply(variableDefinition.getExpression()); - ExpressionAndValuePointers definition = LogicalIndexExtractor.rewrite(expression, rewrittenSubsets.build(), symbolAllocator, plannerContext.getMetadata()); + ExpressionAndValuePointers definition = LogicalIndexExtractor.rewrite(expression, rewrittenSubsets.buildOrThrow(), symbolAllocator, plannerContext.getMetadata()); rewrittenVariableDefinitions.put(label, definition); } // add `true` definition for undefined labels @@ -472,14 +472,14 @@ public PatternRecognitionComponents planPatternRecognitionComponents( } return new PatternRecognitionComponents( - rewrittenSubsets.build(), - rewrittenMeasures.build(), + rewrittenSubsets.buildOrThrow(), + rewrittenMeasures.buildOrThrow(), measureOutputs.build(), skipTo.flatMap(SkipTo::getIdentifier).map(RelationPlanner::irLabel), skipTo.map(SkipTo::getPosition).orElse(PAST_LAST), searchMode.map(mode -> mode.getMode() == INITIAL).orElse(TRUE), rewrittenPattern, - rewrittenVariableDefinitions.build()); + rewrittenVariableDefinitions.buildOrThrow()); } private static IrLabel irLabel(Identifier identifier) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/SplitSourceFactory.java b/core/trino-main/src/main/java/io/trino/sql/planner/SplitSourceFactory.java index 0bcfc53b1ed0..954f85608f83 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/SplitSourceFactory.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/SplitSourceFactory.java @@ -200,7 +200,7 @@ public Map visitJoin(JoinNode node, Void context) return ImmutableMap.builder() .putAll(leftSplits) .putAll(rightSplits) - .build(); + .buildOrThrow(); } @Override @@ -211,7 +211,7 @@ public Map visitSemiJoin(SemiJoinNode node, Void contex return ImmutableMap.builder() .putAll(sourceSplits) .putAll(filteringSourceSplits) - .build(); + .buildOrThrow(); } @Override @@ -222,7 +222,7 @@ public Map visitSpatialJoin(SpatialJoinNode node, Void return ImmutableMap.builder() .putAll(leftSplits) .putAll(rightSplits) - .build(); + .buildOrThrow(); } @Override @@ -441,7 +441,7 @@ private Map processSources(List sources, Void result.putAll(child.accept(this, context)); } - return result.build(); + return result.buildOrThrow(); } @Override diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/StatisticsAggregationPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/StatisticsAggregationPlanner.java index 7109557fdbd4..704f888de34d 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/StatisticsAggregationPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/StatisticsAggregationPlanner.java @@ -104,7 +104,7 @@ public TableStatisticAggregation createStatisticsAggregation(TableStatisticsMeta descriptor.addColumnStatistic(columnStatisticMetadata, symbol); } - StatisticAggregations aggregation = new StatisticAggregations(aggregations.build(), groupingSymbols); + StatisticAggregations aggregation = new StatisticAggregations(aggregations.buildOrThrow(), groupingSymbols); return new TableStatisticAggregation(aggregation, descriptor.build()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/AddIntermediateAggregations.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/AddIntermediateAggregations.java index bef0c756f643..dde4c8b4b90d 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/AddIntermediateAggregations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/AddIntermediateAggregations.java @@ -188,7 +188,7 @@ private static Map outputsAsInputs(Map inputsAsOutputs(Map rewriteWithMasks(Map Optional.of(masks.get(symbol)))); } - return rewritten.build(); + return rewritten.buildOrThrow(); } } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ApplyTableScanRedirection.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ApplyTableScanRedirection.java index ee77e7e8f466..e3dd9a45edf4 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ApplyTableScanRedirection.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ApplyTableScanRedirection.java @@ -146,11 +146,11 @@ public Result apply(TableScanNode scanNode, Captures captures, Context context) TupleDomain requiredFilter = tableScanRedirectApplicationResult.get().getFilter(); if (requiredFilter.isAll()) { - ImmutableMap newAssignments = newAssignmentsBuilder.build(); + ImmutableMap newAssignments = newAssignmentsBuilder.buildOrThrow(); return Result.ofPlanNode(applyProjection( context.getIdAllocator(), ImmutableSet.copyOf(scanNode.getOutputSymbols()), - casts.build(), + casts.buildOrThrow(), new TableScanNode( scanNode.getId(), destinationTableHandle.get(), @@ -207,7 +207,7 @@ public Result apply(TableScanNode scanNode, Captures captures, Context context) return symbol; }); - Map newAssignments = newAssignmentsBuilder.build(); + Map newAssignments = newAssignmentsBuilder.buildOrThrow(); TableScanNode newScanNode = new TableScanNode( scanNode.getId(), destinationTableHandle.get(), @@ -224,7 +224,7 @@ public Result apply(TableScanNode scanNode, Captures captures, Context context) applyProjection( context.getIdAllocator(), newAssignments.keySet(), - casts.build(), + casts.buildOrThrow(), newScanNode), domainTranslator.toPredicate(context.getSession(), transformedConstraint)); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DecorrelateInnerUnnestWithGlobalAggregation.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DecorrelateInnerUnnestWithGlobalAggregation.java index 74e41a89cae4..d0807c088d51 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DecorrelateInnerUnnestWithGlobalAggregation.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DecorrelateInnerUnnestWithGlobalAggregation.java @@ -340,7 +340,7 @@ private static AggregationNode withGroupingAndMask(AggregationNode aggregationNo return new AggregationNode( aggregationNode.getId(), source, - rewriteWithMasks(aggregationNode.getAggregations(), masks.build()), + rewriteWithMasks(aggregationNode.getAggregations(), masks.buildOrThrow()), singleGroupingSet(groupingSymbols), ImmutableList.of(), SINGLE, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExpressionRewriteRuleSet.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExpressionRewriteRuleSet.java index 169784a082a0..8684ba663e5f 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExpressionRewriteRuleSet.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExpressionRewriteRuleSet.java @@ -212,7 +212,7 @@ public Result apply(AggregationNode aggregationNode, Captures captures, Context return Result.ofPlanNode(new AggregationNode( aggregationNode.getId(), aggregationNode.getSource(), - aggregations.build(), + aggregations.buildOrThrow(), aggregationNode.getGroupingSets(), aggregationNode.getPreGroupedSymbols(), aggregationNode.getStep(), @@ -422,7 +422,7 @@ public Result apply(PatternRecognitionNode node, Captures captures, Context cont node.getPrePartitionedInputs(), node.getPreSortedOrderPrefix(), node.getWindowFunctions(), - rewrittenMeasures.build(), + rewrittenMeasures.buildOrThrow(), node.getCommonBaseFrame(), node.getRowsPerMatch(), node.getSkipToLabel(), @@ -430,7 +430,7 @@ public Result apply(PatternRecognitionNode node, Captures captures, Context cont node.isInitial(), node.getPattern(), node.getSubsets(), - rewrittenDefinitions.build())); + rewrittenDefinitions.buildOrThrow())); } return Result.empty(); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/GatherAndMergeWindows.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/GatherAndMergeWindows.java index 75b22e17f082..36e1ba5561a1 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/GatherAndMergeWindows.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/GatherAndMergeWindows.java @@ -193,7 +193,7 @@ protected Optional manipulateAdjacentWindowNodes(WindowNode parent, Wi parent.getId(), child.getSource(), parent.getSpecification(), - functionsBuilder.build(), + functionsBuilder.buildOrThrow(), parent.getHashSymbol(), parent.getPrePartitionedInputs(), parent.getPreSortedOrderPrefix()); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementFilteredAggregations.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementFilteredAggregations.java index 101fba6d81cb..f2e34133392b 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementFilteredAggregations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementFilteredAggregations.java @@ -149,7 +149,7 @@ else if (mask.isPresent()) { aggregationNode.getSource(), newAssignments.build()), predicate), - aggregations.build(), + aggregations.buildOrThrow(), aggregationNode.getGroupingSets(), ImmutableList.of(), aggregationNode.getStep(), diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/LambdaCaptureDesugaringRewriter.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/LambdaCaptureDesugaringRewriter.java index 8468c27bea07..f2b55f14dd91 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/LambdaCaptureDesugaringRewriter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/LambdaCaptureDesugaringRewriter.java @@ -87,7 +87,7 @@ public Expression rewriteLambdaExpression(LambdaExpression node, Context context } newLambdaArguments.addAll(node.getArguments()); - ImmutableMap symbolsMap = captureSymbolToExtraSymbol.build(); + ImmutableMap symbolsMap = captureSymbolToExtraSymbol.buildOrThrow(); Function symbolMapping = symbol -> symbolsMap.getOrDefault(symbol, symbol).toSymbolReference(); Expression rewrittenExpression = new LambdaExpression(newLambdaArguments.build(), inlineSymbols(symbolMapping, rewrittenBody)); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergePatternRecognitionNodes.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergePatternRecognitionNodes.java index 2e7822a9e1ee..df848f0a0aaa 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergePatternRecognitionNodes.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergePatternRecognitionNodes.java @@ -284,8 +284,8 @@ private static PatternRecognitionNode merge(PatternRecognitionNode parent, Patte parent.getHashSymbol(), parent.getPrePartitionedInputs(), parent.getPreSortedOrderPrefix(), - windowFunctions.build(), - measures.build(), + windowFunctions.buildOrThrow(), + measures.buildOrThrow(), parent.getCommonBaseFrame(), parent.getRowsPerMatch(), parent.getSkipToLabel(), diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergeProjectWithValues.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergeProjectWithValues.java index 5821e8f2c1f3..2607bdab6991 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergeProjectWithValues.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/MergeProjectWithValues.java @@ -179,6 +179,6 @@ private Map buildMappings(List symbols, Row for (int i = 0; i < row.getItems().size(); i++) { mappingBuilder.put(symbols.get(i).toSymbolReference(), row.getItems().get(i)); } - return mappingBuilder.build(); + return mappingBuilder.buildOrThrow(); } } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneOrderByInAggregation.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneOrderByInAggregation.java index 89ca910ea212..7efee09790fd 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneOrderByInAggregation.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneOrderByInAggregation.java @@ -81,7 +81,7 @@ else if (metadata.getAggregationFunctionMetadata(aggregation.getResolvedFunction return Result.ofPlanNode(new AggregationNode( node.getId(), node.getSource(), - aggregations.build(), + aggregations.buildOrThrow(), node.getGroupingSets(), node.getPreGroupedSymbols(), node.getStep(), diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneTableScanColumns.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneTableScanColumns.java index 8732f1e68232..f858507bf9dd 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneTableScanColumns.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PruneTableScanColumns.java @@ -101,7 +101,7 @@ public static Optional pruneColumns(Metadata metadata, TypeProvider ty builder.put(newOutputs.get(i), assignments.get(variable.getName())); } - newAssignments = builder.build(); + newAssignments = builder.buildOrThrow(); } else { newAssignments = newOutputs.stream() diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationThroughOuterJoin.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationThroughOuterJoin.java index 5ae1496f83a9..502aeea97d04 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationThroughOuterJoin.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationThroughOuterJoin.java @@ -298,7 +298,7 @@ private MappedAggregationInfo createAggregationOverNull(AggregationNode referenc // symbols in these new aggregations. ImmutableMap.Builder aggregationsSymbolMappingBuilder = ImmutableMap.builder(); ImmutableMap.Builder aggregationsOverNullBuilder = ImmutableMap.builder(); - SymbolMapper mapper = symbolMapper(sourcesSymbolMappingBuilder.build()); + SymbolMapper mapper = symbolMapper(sourcesSymbolMappingBuilder.buildOrThrow()); for (Map.Entry entry : referenceAggregation.getAggregations().entrySet()) { Symbol aggregationSymbol = entry.getKey(); Aggregation overNullAggregation = mapper.map(entry.getValue()); @@ -306,13 +306,13 @@ private MappedAggregationInfo createAggregationOverNull(AggregationNode referenc aggregationsOverNullBuilder.put(overNullSymbol, overNullAggregation); aggregationsSymbolMappingBuilder.put(aggregationSymbol, overNullSymbol); } - Map aggregationsSymbolMapping = aggregationsSymbolMappingBuilder.build(); + Map aggregationsSymbolMapping = aggregationsSymbolMappingBuilder.buildOrThrow(); // create an aggregation node whose source is the null row. AggregationNode aggregationOverNullRow = new AggregationNode( idAllocator.getNextId(), nullRow, - aggregationsOverNullBuilder.build(), + aggregationsOverNullBuilder.buildOrThrow(), globalAggregation(), ImmutableList.of(), AggregationNode.Step.SINGLE, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushJoinIntoTableScan.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushJoinIntoTableScan.java index 54634ed886b9..3c3973258b54 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushJoinIntoTableScan.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushJoinIntoTableScan.java @@ -171,7 +171,7 @@ public Result apply(JoinNode joinNode, Captures captures, Context context) assignmentsBuilder.putAll(right.getAssignments().entrySet().stream().collect(toImmutableMap( Map.Entry::getKey, entry -> rightColumnHandlesMapping.get(entry.getValue())))); - Map assignments = assignmentsBuilder.build(); + Map assignments = assignmentsBuilder.buildOrThrow(); // convert enforced constraint JoinNode.Type joinType = joinNode.getType(); @@ -183,7 +183,7 @@ public Result apply(JoinNode joinNode, Captures captures, Context context) // we are sure that domains map is present as we bailed out on isNone above .putAll(leftConstraint.getDomains().orElseThrow()) .putAll(rightConstraint.getDomains().orElseThrow()) - .build()); + .buildOrThrow()); return Result.ofPlanNode( new ProjectNode( diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushPredicateIntoTableScan.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushPredicateIntoTableScan.java index 63fb9eb8dda4..da28bd921c35 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushPredicateIntoTableScan.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushPredicateIntoTableScan.java @@ -335,7 +335,7 @@ public static TupleDomain computeEnforced(TupleDomain enforcedDomains = enforcedDomainsBuilder.build(); + Map enforcedDomains = enforcedDomainsBuilder.buildOrThrow(); checkArgument( enforcedDomains.size() + unenforcedDomains.size() == predicateDomains.size(), "Enforced tuple domain cannot be determined. Connector returned an unenforced TupleDomain that contains columns not in predicate."); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionIntoTableScan.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionIntoTableScan.java index 941b44c71701..80ccf484b8c3 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionIntoTableScan.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionIntoTableScan.java @@ -151,7 +151,7 @@ public Result apply(ProjectNode project, Captures captures, Context context) for (int i = 0; i < nodesForPartialProjections.size(); i++) { nodesToNewPartialProjectionsBuilder.put(nodesForPartialProjections.get(i), newPartialProjections.get(i)); } - Map, Expression> nodesToNewPartialProjections = nodesToNewPartialProjectionsBuilder.build(); + Map, Expression> nodesToNewPartialProjections = nodesToNewPartialProjectionsBuilder.buildOrThrow(); // Stitch partial translations to form new complete projections Assignments.Builder newProjectionAssignments = Assignments.builder(); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughExchange.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughExchange.java index d45d11cc4b20..26edf6900b8b 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughExchange.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughExchange.java @@ -198,6 +198,6 @@ private static Map mapExchangeOutputToInput(ExchangeNode exchang for (int i = 0; i < exchange.getOutputSymbols().size(); i++) { outputToInputMap.put(exchange.getOutputSymbols().get(i), exchange.getInputs().get(sourceIndex).get(i)); } - return outputToInputMap.build(); + return outputToInputMap.buildOrThrow(); } } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushTableWriteThroughUnion.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushTableWriteThroughUnion.java index 406a86d7d538..0117f2f7a614 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushTableWriteThroughUnion.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushTableWriteThroughUnion.java @@ -107,8 +107,8 @@ private static TableWriterNode rewriteSource( mappings.put(outputSymbol, newSymbol); } } - sourceMappings.add(outputMappings.build()); - SymbolMapper symbolMapper = symbolMapper(mappings.build()); + sourceMappings.add(outputMappings.buildOrThrow()); + SymbolMapper symbolMapper = symbolMapper(mappings.buildOrThrow()); return symbolMapper.map(writerNode, unionNode.getSources().get(source), context.getIdAllocator().getNextId()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RewriteSpatialPartitioningAggregation.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RewriteSpatialPartitioningAggregation.java index 3146152dd829..4d2b32afeb83 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RewriteSpatialPartitioningAggregation.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RewriteSpatialPartitioningAggregation.java @@ -131,9 +131,9 @@ public Result apply(AggregationNode node, Captures captures, Context context) Assignments.builder() .putIdentities(node.getSource().getOutputSymbols()) .put(partitionCountSymbol, new LongLiteral(Integer.toString(getHashPartitionCount(context.getSession())))) - .putAll(envelopeAssignments.build()) + .putAll(envelopeAssignments.buildOrThrow()) .build()), - aggregations.build(), + aggregations.buildOrThrow(), node.getGroupingSets(), node.getPreGroupedSymbols(), node.getStep(), diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/SetOperationNodeTranslator.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/SetOperationNodeTranslator.java index 90250ad949e9..64b9cef1fdfb 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/SetOperationNodeTranslator.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/SetOperationNodeTranslator.java @@ -182,7 +182,7 @@ private AggregationNode computeCounts(UnionNode sourceNode, List origina return new AggregationNode(idAllocator.getNextId(), sourceNode, - aggregations.build(), + aggregations.buildOrThrow(), singleGroupingSet(originalColumns), ImmutableList.of(), AggregationNode.Step.SINGLE, @@ -214,7 +214,7 @@ private WindowNode appendCounts(UnionNode sourceNode, List originalColum idAllocator.getNextId(), sourceNode, new Specification(originalColumns, Optional.empty()), - functions.build(), + functions.buildOrThrow(), Optional.empty(), ImmutableSet.of(), 0); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithProjection.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithProjection.java index 3dba0f49b471..297d1f92ca87 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithProjection.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithProjection.java @@ -257,7 +257,7 @@ public Result apply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Co globalAggregation = new AggregationNode( globalAggregation.getId(), root, - rewriteWithMasks(globalAggregation.getAggregations(), masks.build()), + rewriteWithMasks(globalAggregation.getAggregations(), masks.buildOrThrow()), singleGroupingSet(ImmutableList.builder() .addAll(join.getLeftOutputSymbols()) .addAll(globalAggregation.getGroupingKeys()) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithoutProjection.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithoutProjection.java index 96ba71f87b91..09295cd48303 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithoutProjection.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedGlobalAggregationWithoutProjection.java @@ -250,7 +250,7 @@ public Result apply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Co globalAggregation = new AggregationNode( globalAggregation.getId(), root, - rewriteWithMasks(globalAggregation.getAggregations(), masks.build()), + rewriteWithMasks(globalAggregation.getAggregations(), masks.buildOrThrow()), singleGroupingSet(ImmutableList.builder() .addAll(join.getLeftOutputSymbols()) .addAll(globalAggregation.getGroupingKeys()) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedInPredicateToJoin.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedInPredicateToJoin.java index 97e6b9e726ce..8da7a2ea2919 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedInPredicateToJoin.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/TransformCorrelatedInPredicateToJoin.java @@ -222,7 +222,7 @@ private PlanNode buildInPredicateEquivalent( ImmutableMap.builder() .put(countMatchesSymbol, countWithFilter(session, matchConditionSymbol)) .put(countNullMatchesSymbol, countWithFilter(session, nullMatchConditionSymbol)) - .build(), + .buildOrThrow(), singleGroupingSet(probeSide.getOutputSymbols()), ImmutableList.of(), AggregationNode.Step.SINGLE, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/MetadataQueryOptimizer.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/MetadataQueryOptimizer.java index d94532470289..ce64684bad76 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/MetadataQueryOptimizer.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/MetadataQueryOptimizer.java @@ -130,8 +130,8 @@ public PlanNode visitAggregation(AggregationNode node, RewriteContext cont columnBuilder.put(symbol, column); } - Map columns = columnBuilder.build(); - Map types = typesBuilder.build(); + Map columns = columnBuilder.buildOrThrow(); + Map types = typesBuilder.buildOrThrow(); // Materialize the list of partitions and replace the TableScan node // with a Values node diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/OptimizeMixedDistinctAggregations.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/OptimizeMixedDistinctAggregations.java index a124d899f26a..35a2a9ce67e4 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/OptimizeMixedDistinctAggregations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/OptimizeMixedDistinctAggregations.java @@ -189,12 +189,12 @@ public PlanNode visitAggregation(AggregationNode node, RewriteContext coalesceSymbols = coalesceSymbolsBuilder.build(); + Map coalesceSymbols = coalesceSymbolsBuilder.buildOrThrow(); AggregationNode aggregationNode = new AggregationNode( idAllocator.getNextId(), source, - aggregations.build(), + aggregations.buildOrThrow(), node.getGroupingSets(), ImmutableList.of(), node.getStep(), @@ -278,7 +278,7 @@ public PlanNode visitMarkDistinct(MarkDistinctNode node, RewriteContext aggregationOutputSymbolsMap = aggregationOutputSymbolsMapBuilder.build(); + Map aggregationOutputSymbolsMap = aggregationOutputSymbolsMapBuilder.buildOrThrow(); // 3. Add new project node that adds if expressions ProjectNode projectNode = createProjectNode( @@ -361,7 +361,7 @@ else if (aggregationOutputSymbolsMap.containsKey(symbol)) { // unused mask will be removed by PruneUnreferencedOutputs outputSymbols.put(aggregateInfo.getMask(), new NullLiteral()); - aggregateInfo.setNewNonDistinctAggregateSymbols(outputNonDistinctAggregateSymbols.build()); + aggregateInfo.setNewNonDistinctAggregateSymbols(outputNonDistinctAggregateSymbols.buildOrThrow()); return new ProjectNode(idAllocator.getNextId(), source, outputSymbols.build()); } @@ -455,7 +455,7 @@ private AggregationNode createNonDistinctAggregation( return new AggregationNode( idAllocator.getNextId(), groupIdNode, - aggregations.build(), + aggregations.buildOrThrow(), singleGroupingSet(ImmutableList.copyOf(groupByKeys)), ImmutableList.of(), SINGLE, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PlanNodeDecorrelator.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PlanNodeDecorrelator.java index 086da0a92733..1638a0436add 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PlanNodeDecorrelator.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PlanNodeDecorrelator.java @@ -391,7 +391,7 @@ private Optional decorrelateOrderingScheme(OrderingScheme orderi if (nonConstantOrderBy.build().isEmpty()) { return Optional.empty(); } - return Optional.of(new OrderingScheme(nonConstantOrderBy.build(), nonConstantOrderings.build())); + return Optional.of(new OrderingScheme(nonConstantOrderBy.build(), nonConstantOrderings.buildOrThrow())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java index 088e09f86aa0..47a2b2453650 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java @@ -577,7 +577,7 @@ public ActualProperties visitIndexJoin(IndexJoinNode node, Listbuilder() .putAll(probeProperties.getConstants()) .putAll(indexProperties.getConstants()) - .build()) + .buildOrThrow()) .build(); case SOURCE_OUTER: return ActualProperties.builderFrom(probeProperties) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/SymbolMapper.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/SymbolMapper.java index 901f54f63de4..2c438897e8f9 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/SymbolMapper.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/SymbolMapper.java @@ -149,7 +149,7 @@ public AggregationNode map(AggregationNode node, PlanNode source, PlanNodeId new return new AggregationNode( newNodeId, source, - aggregations.build(), + aggregations.buildOrThrow(), groupingSets( mapAndDistinct(node.getGroupingKeys()), node.getGroupingSetCount(), @@ -215,7 +215,7 @@ public WindowNode map(WindowNode node, PlanNode source) node.getId(), source, mapAndDistinct(node.getSpecification()), - newFunctions.build(), + newFunctions.buildOrThrow(), node.getHashSymbol().map(this::map), node.getPrePartitionedInputs().stream() .map(this::map) @@ -274,8 +274,8 @@ public PatternRecognitionNode map(PatternRecognitionNode node, PlanNode source) .map(this::map) .collect(toImmutableSet()), node.getPreSortedOrderPrefix(), - newFunctions.build(), - newMeasures.build(), + newFunctions.buildOrThrow(), + newMeasures.buildOrThrow(), node.getCommonBaseFrame().map(this::map), node.getRowsPerMatch(), node.getSkipToLabel(), @@ -283,7 +283,7 @@ public PatternRecognitionNode map(PatternRecognitionNode node, PlanNode source) node.isInitial(), node.getPattern(), node.getSubsets(), - newVariableDefinitions.build()); + newVariableDefinitions.buildOrThrow()); } private ExpressionAndValuePointers map(ExpressionAndValuePointers expressionAndValuePointers) @@ -362,7 +362,7 @@ public OrderingScheme map(OrderingScheme orderingScheme) newOrderings.put(canonical, orderingScheme.getOrdering(symbol)); } } - return new OrderingScheme(newSymbols.build(), newOrderings.build()); + return new OrderingScheme(newSymbols.build(), newOrderings.buildOrThrow()); } public DistinctLimitNode map(DistinctLimitNode node, PlanNode source) @@ -514,7 +514,7 @@ public void put(Symbol from, Symbol to) public SymbolMapper build() { - return SymbolMapper.symbolMapper(mappings.build()); + return SymbolMapper.symbolMapper(mappings.buildOrThrow()); } } } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/UnaliasSymbolReferences.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/UnaliasSymbolReferences.java index 0710270a7c83..e3069e83758e 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/UnaliasSymbolReferences.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/UnaliasSymbolReferences.java @@ -1034,7 +1034,7 @@ public PlanAndMappings visitJoin(JoinNode node, UnaliasContext context) dynamicFilterIdMap.put(entry.getKey(), canonicalDynamicFilterId); } } - Map newDynamicFilters = filtersBuilder.build(); + Map newDynamicFilters = filtersBuilder.buildOrThrow(); // derive new mappings from inner join equi criteria Map newMapping = new HashMap<>(); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/plan/SetOperationNode.java b/core/trino-main/src/main/java/io/trino/sql/planner/plan/SetOperationNode.java index 35beebc3a7ea..35e84a195201 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/plan/SetOperationNode.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/plan/SetOperationNode.java @@ -113,7 +113,7 @@ public Map sourceSymbolMap(int sourceIndex) builder.put(entry.getKey(), Iterables.get(entry.getValue(), sourceIndex).toSymbolReference()); } - return builder.build(); + return builder.buildOrThrow(); } /** diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregations.java b/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregations.java index 9ac0e86035d5..29c8a5be256e 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregations.java @@ -92,9 +92,9 @@ public Parts createPartialAggregations(SymbolAllocator symbolAllocator, PlannerC } groupingSymbols.forEach(symbol -> mappings.put(symbol, symbol)); return new Parts( - new StatisticAggregations(partialAggregation.build(), groupingSymbols), - new StatisticAggregations(finalAggregation.build(), groupingSymbols), - mappings.build()); + new StatisticAggregations(partialAggregation.buildOrThrow(), groupingSymbols), + new StatisticAggregations(finalAggregation.buildOrThrow(), groupingSymbols), + mappings.buildOrThrow()); } public static class Parts diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregationsDescriptor.java b/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregationsDescriptor.java index a317954c3eec..cb4cf430e64b 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregationsDescriptor.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/plan/StatisticAggregationsDescriptor.java @@ -155,7 +155,7 @@ public void addColumnStatistic(ColumnStatisticMetadata statisticMetadata, T key) public StatisticAggregationsDescriptor build() { - return new StatisticAggregationsDescriptor<>(grouping.build(), tableStatistics.build(), columnStatistics.build()); + return new StatisticAggregationsDescriptor<>(grouping.buildOrThrow(), tableStatistics.buildOrThrow(), columnStatistics.buildOrThrow()); } } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/GraphvizPrinter.java b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/GraphvizPrinter.java index 98d1ff2720ce..27dd1af7a5b5 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/GraphvizPrinter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/GraphvizPrinter.java @@ -125,7 +125,7 @@ private enum NodeType .put(NodeType.UNNEST, "crimson") .put(NodeType.SAMPLE, "goldenrod4") .put(NodeType.ANALYZE_FINISH, "plum") - .build()); + .buildOrThrow()); static { checkState(NODE_COLORS.size() == NodeType.values().length); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/rowpattern/ExpressionAndValuePointersEquivalence.java b/core/trino-main/src/main/java/io/trino/sql/planner/rowpattern/ExpressionAndValuePointersEquivalence.java index 050126361212..40e8dad670c6 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/rowpattern/ExpressionAndValuePointersEquivalence.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/rowpattern/ExpressionAndValuePointersEquivalence.java @@ -75,7 +75,7 @@ else if (leftPointer instanceof AggregationValuePointer) { mapping.put(left.getLayout().get(i), right.getLayout().get(i)); } - return treeEqual(left.getExpression(), right.getExpression(), mappingComparator(mapping.build())); + return treeEqual(left.getExpression(), right.getExpression(), mappingComparator(mapping.buildOrThrow())); } private static boolean equivalent( diff --git a/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java b/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java index 1eaf93c46144..a6cdfe2db3d4 100644 --- a/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java +++ b/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java @@ -781,7 +781,7 @@ protected Node visitShowFunctions(ShowFunctions node, Void context) .put("function_type", "Function Type") .put("deterministic", "Deterministic") .put("description", "Description") - .build(); + .buildOrThrow(); return simpleQuery( selectAll(columns.entrySet().stream() diff --git a/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java b/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java index 885e9a138019..5c1d46a3b29d 100644 --- a/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java +++ b/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java @@ -116,7 +116,7 @@ public Map getColumnHandles(ConnectorSession session, Conn builder.put(columnMetadata.getName(), new TestingColumnHandle(columnMetadata.getName(), index, columnMetadata.getType())); index++; } - return builder.build(); + return builder.buildOrThrow(); } @Override @@ -132,7 +132,7 @@ public Map> listTableColumns(ConnectorSess } tableColumns.put(tableName, columns.build()); } - return tableColumns.build(); + return tableColumns.buildOrThrow(); } @Override diff --git a/core/trino-main/src/test/java/io/trino/connector/MockConnector.java b/core/trino-main/src/test/java/io/trino/connector/MockConnector.java index 53c3545ddaa2..37922e09134a 100644 --- a/core/trino-main/src/test/java/io/trino/connector/MockConnector.java +++ b/core/trino-main/src/test/java/io/trino/connector/MockConnector.java @@ -695,7 +695,7 @@ private Map getColumnIndexes(SchemaTableName tableName) for (int index = 0; index < columnMetadata.size(); index++) { columnIndexes.put(columnMetadata.get(index).getName(), index); } - return columnIndexes.build(); + return columnIndexes.buildOrThrow(); } } diff --git a/core/trino-main/src/test/java/io/trino/cost/TestComparisonStatsCalculator.java b/core/trino-main/src/test/java/io/trino/cost/TestComparisonStatsCalculator.java index d9514577acef..833be89b7b3c 100644 --- a/core/trino-main/src/test/java/io/trino/cost/TestComparisonStatsCalculator.java +++ b/core/trino-main/src/test/java/io/trino/cost/TestComparisonStatsCalculator.java @@ -172,7 +172,7 @@ public void setUp() .put(new Symbol("unknownRange"), DoubleType.DOUBLE) .put(new Symbol("emptyRange"), DoubleType.DOUBLE) .put(new Symbol("varchar"), VarcharType.createVarcharType(10)) - .build()); + .buildOrThrow()); } private Consumer equalTo(SymbolStatsEstimate estimate) diff --git a/core/trino-main/src/test/java/io/trino/cost/TestCostCalculator.java b/core/trino-main/src/test/java/io/trino/cost/TestCostCalculator.java index 00da4d976d09..9d0191e62eb0 100644 --- a/core/trino-main/src/test/java/io/trino/cost/TestCostCalculator.java +++ b/core/trino-main/src/test/java/io/trino/cost/TestCostCalculator.java @@ -440,7 +440,7 @@ public void testRepartitionedJoinWithExchange() .put("le", statsEstimate(localExchange, 6000)) .put("ts1", statsEstimate(ts1, 6000)) .put("ts2", statsEstimate(ts2, 1000)) - .build(); + .buildOrThrow(); Map types = ImmutableMap.of( "orderkey", BIGINT, "orderkey_0", BIGINT); @@ -469,7 +469,7 @@ public void testReplicatedJoinWithExchange() .put("le", statsEstimate(localExchange, 6000)) .put("ts1", statsEstimate(ts1, 6000)) .put("ts2", statsEstimate(ts2, 1000)) - .build(); + .buildOrThrow(); Map types = ImmutableMap.of( "orderkey", BIGINT, "orderkey_0", BIGINT); @@ -795,7 +795,7 @@ private TableScanNode tableScan(String id, String... symbols) new PlanNodeId(id), new TableHandle(new CatalogName("tpch"), tableHandle, INSTANCE), symbolsList, - assignments.build(), + assignments.buildOrThrow(), TupleDomain.all(), Optional.empty(), false, diff --git a/core/trino-main/src/test/java/io/trino/cost/TestFilterStatsCalculator.java b/core/trino-main/src/test/java/io/trino/cost/TestFilterStatsCalculator.java index 029a9eea2213..7e2c0c9aab2e 100644 --- a/core/trino-main/src/test/java/io/trino/cost/TestFilterStatsCalculator.java +++ b/core/trino-main/src/test/java/io/trino/cost/TestFilterStatsCalculator.java @@ -147,7 +147,7 @@ public void setUp() .put(new Symbol("unknownRange"), DoubleType.DOUBLE) .put(new Symbol("emptyRange"), DoubleType.DOUBLE) .put(new Symbol("mediumVarchar"), MEDIUM_VARCHAR_TYPE) - .build()); + .buildOrThrow()); session = testSessionBuilder().build(); statsCalculator = new FilterStatsCalculator(PLANNER_CONTEXT, new ScalarStatsCalculator(PLANNER_CONTEXT, createTestingTypeAnalyzer(PLANNER_CONTEXT)), new StatsNormalizer()); diff --git a/core/trino-main/src/test/java/io/trino/cost/TestJoinStatsRule.java b/core/trino-main/src/test/java/io/trino/cost/TestJoinStatsRule.java index 5727582133c1..fb707244118b 100644 --- a/core/trino-main/src/test/java/io/trino/cost/TestJoinStatsRule.java +++ b/core/trino-main/src/test/java/io/trino/cost/TestJoinStatsRule.java @@ -96,7 +96,7 @@ public class TestJoinStatsRule .put(new Symbol(RIGHT_JOIN_COLUMN_2), DOUBLE) .put(new Symbol(LEFT_OTHER_COLUMN), DOUBLE) .put(new Symbol(RIGHT_OTHER_COLUMN), BIGINT) - .build()); + .buildOrThrow()); @Test public void testStatsForInnerJoin() diff --git a/core/trino-main/src/test/java/io/trino/event/TestQueryMonitorConfig.java b/core/trino-main/src/test/java/io/trino/event/TestQueryMonitorConfig.java index 0365b8cc7650..9ec33598898e 100644 --- a/core/trino-main/src/test/java/io/trino/event/TestQueryMonitorConfig.java +++ b/core/trino-main/src/test/java/io/trino/event/TestQueryMonitorConfig.java @@ -38,7 +38,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("event.max-output-stage-size", "512kB") - .build(); + .buildOrThrow(); QueryMonitorConfig expected = new QueryMonitorConfig() .setMaxOutputStageJsonSize(DataSize.of(512, Unit.KILOBYTE)); diff --git a/core/trino-main/src/test/java/io/trino/eventlistener/TestEventListenerConfig.java b/core/trino-main/src/test/java/io/trino/eventlistener/TestEventListenerConfig.java index c1d9e6d9e8f1..233c17b3b3e3 100644 --- a/core/trino-main/src/test/java/io/trino/eventlistener/TestEventListenerConfig.java +++ b/core/trino-main/src/test/java/io/trino/eventlistener/TestEventListenerConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("event-listener.config-files", config1.toString() + "," + config2.toString()) - .build(); + .buildOrThrow(); EventListenerConfig expected = new EventListenerConfig() .setEventListenerFiles(ImmutableList.of(config1.toFile(), config2.toFile())); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestDynamicFilterConfig.java b/core/trino-main/src/test/java/io/trino/execution/TestDynamicFilterConfig.java index 46920b34b53d..4e0853de46f1 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestDynamicFilterConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestDynamicFilterConfig.java @@ -68,7 +68,7 @@ public void testExplicitPropertyMappings() .put("dynamic-filtering.large-partitioned.max-distinct-values-per-driver", "256") .put("dynamic-filtering.large-partitioned.max-size-per-driver", "64kB") .put("dynamic-filtering.large-partitioned.range-row-limit-per-driver", "100000") - .build(); + .buildOrThrow(); DynamicFilterConfig expected = new DynamicFilterConfig() .setEnableDynamicFiltering(false) diff --git a/core/trino-main/src/test/java/io/trino/execution/TestFailureInjectionConfig.java b/core/trino-main/src/test/java/io/trino/execution/TestFailureInjectionConfig.java index eb89e03e3d4c..c05514af3942 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestFailureInjectionConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestFailureInjectionConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("failure-injection.request-timeout", "12m") .put("failure-injection.expiration-period", "7m") - .build(); + .buildOrThrow(); FailureInjectionConfig expected = new FailureInjectionConfig() .setRequestTimeout(new Duration(12, MINUTES)) diff --git a/core/trino-main/src/test/java/io/trino/execution/TestNodeSchedulerConfig.java b/core/trino-main/src/test/java/io/trino/execution/TestNodeSchedulerConfig.java index 257bb2cec485..d46aedf93489 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestNodeSchedulerConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestNodeSchedulerConfig.java @@ -50,7 +50,7 @@ public void testExplicitPropertyMappings() .put("node-scheduler.max-splits-per-node", "101") .put("node-scheduler.max-unacknowledged-splits-per-task", "501") .put("node-scheduler.optimized-local-scheduling", "false") - .build(); + .buildOrThrow(); NodeSchedulerConfig expected = new NodeSchedulerConfig() .setNodeSchedulerPolicy("topology") diff --git a/core/trino-main/src/test/java/io/trino/execution/TestQueryManagerConfig.java b/core/trino-main/src/test/java/io/trino/execution/TestQueryManagerConfig.java index 6749cc7efe8e..01a8bdd34ca9 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestQueryManagerConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestQueryManagerConfig.java @@ -96,7 +96,7 @@ public void testExplicitPropertyMappings() .put("retry-attempts", "0") .put("retry-initial-delay", "1m") .put("retry-max-delay", "1h") - .build(); + .buildOrThrow(); QueryManagerConfig expected = new QueryManagerConfig() .setMinQueryExpireAge(new Duration(30, SECONDS)) diff --git a/core/trino-main/src/test/java/io/trino/execution/TestQueryStateMachine.java b/core/trino-main/src/test/java/io/trino/execution/TestQueryStateMachine.java index 886473eb393f..bfe08aede196 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestQueryStateMachine.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestQueryStateMachine.java @@ -98,7 +98,7 @@ public class TestQueryStateMachine private static final Map SET_SESSION_PROPERTIES = ImmutableMap.builder() .put("fruit", "apple") .put("drink", "coffee") - .build(); + .buildOrThrow(); private static final List RESET_SESSION_PROPERTIES = ImmutableList.of("candy"); private static final Optional QUERY_TYPE = Optional.of(QueryType.SELECT); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestSqlStage.java b/core/trino-main/src/test/java/io/trino/execution/TestSqlStage.java index e27c012548ad..eee50e51c9a6 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestSqlStage.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestSqlStage.java @@ -179,7 +179,7 @@ private static PlanFragment createExchangePlanFragment() return new PlanFragment( new PlanFragmentId("exchange_fragment_id"), planNode, - types.build(), + types.buildOrThrow(), SOURCE_DISTRIBUTION, ImmutableList.of(planNode.getId()), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), planNode.getOutputSymbols()), diff --git a/core/trino-main/src/test/java/io/trino/execution/TestTaskManagerConfig.java b/core/trino-main/src/test/java/io/trino/execution/TestTaskManagerConfig.java index cd54f510a3ff..2061d6d7600b 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestTaskManagerConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestTaskManagerConfig.java @@ -101,7 +101,7 @@ public void testExplicitPropertyMappings() .put("task.task-yield-threads", "8") .put("task.level-time-multiplier", "2.1") .put("task.statistics-cpu-timer-enabled", "false") - .build(); + .buildOrThrow(); TaskManagerConfig expected = new TaskManagerConfig() .setInitialSplitsPerNode(1) diff --git a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSourcePartitionedScheduler.java b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSourcePartitionedScheduler.java index ea9fdd20526b..8444555c1880 100644 --- a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSourcePartitionedScheduler.java +++ b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSourcePartitionedScheduler.java @@ -670,7 +670,7 @@ private StageExecution createStageExecution(PlanFragment fragment, NodeTaskMap n .forEach(fragmentId -> outputBuffers.put(fragmentId, new PartitionedOutputBufferManager(FIXED_HASH_DISTRIBUTION, 10))); return createPipelinedStageExecution( stage, - outputBuffers.build(), + outputBuffers.buildOrThrow(), TaskLifecycleListener.NO_OP, new NoOpFailureDetector(), queryExecutor, diff --git a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSubnetTopologyConfig.java b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSubnetTopologyConfig.java index 89477c5b84a5..86e532271d5a 100644 --- a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSubnetTopologyConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestSubnetTopologyConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("node-scheduler.network-topology.subnet.cidr-prefix-lengths", "24,26") .put("node-scheduler.network-topology.subnet.ip-address-protocol", "IPv6") - .build(); + .buildOrThrow(); SubnetTopologyConfig expected = new SubnetTopologyConfig() .setCidrPrefixLengths("24,26") diff --git a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyAwareNodeSelectorConfig.java b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyAwareNodeSelectorConfig.java index b487d8dcfd68..dfcd0d224fc8 100644 --- a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyAwareNodeSelectorConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyAwareNodeSelectorConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("node-scheduler.network-topology.type", "FILE") .put("node-scheduler.network-topology.segments", "rack,machine") - .build(); + .buildOrThrow(); TopologyAwareNodeSelectorConfig expected = new TopologyAwareNodeSelectorConfig() .setType(TopologyType.FILE) diff --git a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyFileConfig.java b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyFileConfig.java index 1c194c655546..5a561eb8647f 100644 --- a/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyFileConfig.java +++ b/core/trino-main/src/test/java/io/trino/execution/scheduler/TestTopologyFileConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("node-scheduler.network-topology.file", networkTopologyFile.toString()) .put("node-scheduler.network-topology.refresh-period", "27m") - .build(); + .buildOrThrow(); TopologyFileConfig expected = new TopologyFileConfig() .setNetworkTopologyFile(networkTopologyFile.toFile()) diff --git a/core/trino-main/src/test/java/io/trino/execution/scheduler/policy/PlanUtils.java b/core/trino-main/src/test/java/io/trino/execution/scheduler/policy/PlanUtils.java index 748beb51d4b1..ce33f622fd3e 100644 --- a/core/trino-main/src/test/java/io/trino/execution/scheduler/policy/PlanUtils.java +++ b/core/trino-main/src/test/java/io/trino/execution/scheduler/policy/PlanUtils.java @@ -226,7 +226,7 @@ private static PlanFragment createFragment(PlanNode planNode) return new PlanFragment( new PlanFragmentId(planNode.getId() + "_fragment_id"), planNode, - types.build(), + types.buildOrThrow(), SOURCE_DISTRIBUTION, ImmutableList.of(planNode.getId()), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), planNode.getOutputSymbols()), diff --git a/core/trino-main/src/test/java/io/trino/memory/LowMemoryKillerTestingUtils.java b/core/trino-main/src/test/java/io/trino/memory/LowMemoryKillerTestingUtils.java index 1024de36b0d5..4ce99c04431a 100644 --- a/core/trino-main/src/test/java/io/trino/memory/LowMemoryKillerTestingUtils.java +++ b/core/trino-main/src/test/java/io/trino/memory/LowMemoryKillerTestingUtils.java @@ -84,7 +84,7 @@ static List toNodeMemoryInfoList(long maxReservedPoolBytes, long max ImmutableMap.of(), ImmutableMap.of())); } - result.add(new MemoryInfo(7, DataSize.ofBytes(maxReservedPoolBytes + maxGeneralPoolBytes), pools.build())); + result.add(new MemoryInfo(7, DataSize.ofBytes(maxReservedPoolBytes + maxGeneralPoolBytes), pools.buildOrThrow())); } return result.build(); } diff --git a/core/trino-main/src/test/java/io/trino/memory/TestMemoryManagerConfig.java b/core/trino-main/src/test/java/io/trino/memory/TestMemoryManagerConfig.java index 3ea46ac4346c..393eae7d042b 100644 --- a/core/trino-main/src/test/java/io/trino/memory/TestMemoryManagerConfig.java +++ b/core/trino-main/src/test/java/io/trino/memory/TestMemoryManagerConfig.java @@ -49,7 +49,7 @@ public void testExplicitPropertyMappings() .put("query.low-memory-killer.delay", "20s") .put("query.max-memory", "2GB") .put("query.max-total-memory", "3GB") - .build(); + .buildOrThrow(); MemoryManagerConfig expected = new MemoryManagerConfig() .setLowMemoryKillerPolicy(NONE) diff --git a/core/trino-main/src/test/java/io/trino/memory/TestNodeMemoryConfig.java b/core/trino-main/src/test/java/io/trino/memory/TestNodeMemoryConfig.java index 999fb8b88c34..2e881e3ee709 100644 --- a/core/trino-main/src/test/java/io/trino/memory/TestNodeMemoryConfig.java +++ b/core/trino-main/src/test/java/io/trino/memory/TestNodeMemoryConfig.java @@ -48,7 +48,7 @@ public void testExplicitPropertyMappings() .put("query.max-total-memory-per-task", "200MB") .put("memory.heap-headroom-per-node", "1GB") .put("experimental.reserved-pool-disabled", "false") - .build(); + .buildOrThrow(); NodeMemoryConfig expected = new NodeMemoryConfig() .setMaxQueryMemoryPerNode(DataSize.of(1, GIGABYTE)) diff --git a/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationLowMemoryKiller.java b/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationLowMemoryKiller.java index 6f1ed455ef09..06dc15de5df7 100644 --- a/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationLowMemoryKiller.java +++ b/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationLowMemoryKiller.java @@ -37,7 +37,7 @@ public void testGeneralPoolHasNoReservation() Map> queries = ImmutableMap.>builder() .put("q_1", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 0L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) - .build(); + .buildOrThrow(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), @@ -57,7 +57,7 @@ public void testSkewedQuery() .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L)) .put("q_3", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 9L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) - .build(); + .buildOrThrow(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), diff --git a/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationOnBlockedNodesLowMemoryKiller.java b/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationOnBlockedNodesLowMemoryKiller.java index ac8ccbb6145e..f3d08164edfd 100644 --- a/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationOnBlockedNodesLowMemoryKiller.java +++ b/core/trino-main/src/test/java/io/trino/memory/TestTotalReservationOnBlockedNodesLowMemoryKiller.java @@ -37,7 +37,7 @@ public void testGeneralPoolHasNoReservation() Map> queries = ImmutableMap.>builder() .put("q_1", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 0L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) - .build(); + .buildOrThrow(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), @@ -54,7 +54,7 @@ public void testGeneralPoolNotBlocked() .put("q_1", ImmutableMap.of("n1", 0L, "n2", 6L, "n3", 0L, "n4", 0L, "n5", 0L)) .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) - .build(); + .buildOrThrow(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), @@ -74,7 +74,7 @@ public void testSkewedQuery() .put("q_2", ImmutableMap.of("n1", 3L, "n2", 5L, "n3", 2L, "n4", 4L, "n5", 0L)) .put("q_3", ImmutableMap.of("n1", 0L, "n2", 0L, "n3", 9L, "n4", 0L, "n5", 0L)) .put("q_r", ImmutableMap.of("n1", 6L, "n2", 6L, "n3", 6L, "n4", 6L, "n5", 6L)) - .build(); + .buildOrThrow(); assertEquals( lowMemoryKiller.chooseQueryToKill( toQueryMemoryInfoList("q_r", queries), diff --git a/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaMetadata.java b/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaMetadata.java index 031dd515e144..d9b90d17ffc2 100644 --- a/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaMetadata.java +++ b/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaMetadata.java @@ -114,7 +114,7 @@ public void testInformationSchemaPredicatePushdown() ImmutableMap.Builder domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema"))); domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view"))); - Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); + Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.buildOrThrow())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); @@ -153,7 +153,7 @@ public void testInformationSchemaPredicatePushdownWithoutSchemaPredicate() // predicate without schema predicates should cause schemas to be enumerated when table predicates are present ImmutableMap.Builder domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view"))); - Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); + Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.buildOrThrow())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); @@ -174,7 +174,7 @@ public void testInformationSchemaPredicatePushdownWithoutTablePredicate() // predicate without table name predicates should not cause table level prefixes to be evaluated ImmutableMap.Builder domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema"))); - Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); + Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.buildOrThrow())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); diff --git a/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaTableHandle.java b/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaTableHandle.java index 83e6490a474a..c6ec3f667b47 100644 --- a/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaTableHandle.java +++ b/core/trino-main/src/test/java/io/trino/metadata/TestInformationSchemaTableHandle.java @@ -46,7 +46,7 @@ public class TestInformationSchemaTableHandle .put("prefixes", ImmutableList.of(ImmutableMap.of("catalogName", "abc", "schemaName", INFORMATION_SCHEMA))) .put("roles", ImmutableList.of("role")) .put("grantees", ImmutableList.of("grantee")) - .build(); + .buildOrThrow(); private ObjectMapper objectMapper; diff --git a/core/trino-main/src/test/java/io/trino/metadata/TestStaticCatalogStoreConfig.java b/core/trino-main/src/test/java/io/trino/metadata/TestStaticCatalogStoreConfig.java index f534ed038ceb..c21106edf842 100644 --- a/core/trino-main/src/test/java/io/trino/metadata/TestStaticCatalogStoreConfig.java +++ b/core/trino-main/src/test/java/io/trino/metadata/TestStaticCatalogStoreConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("catalog.config-dir", "/foo") .put("catalog.disabled-catalogs", "abc,xyz") - .build(); + .buildOrThrow(); StaticCatalogStoreConfig expected = new StaticCatalogStoreConfig() .setCatalogConfigurationDir(new File("/foo")) diff --git a/core/trino-main/src/test/java/io/trino/operator/TestExchangeClientConfig.java b/core/trino-main/src/test/java/io/trino/operator/TestExchangeClientConfig.java index 07f2f0ac63b6..2da5a663d88d 100644 --- a/core/trino-main/src/test/java/io/trino/operator/TestExchangeClientConfig.java +++ b/core/trino-main/src/test/java/io/trino/operator/TestExchangeClientConfig.java @@ -55,7 +55,7 @@ public void testExplicitPropertyMappings() .put("exchange.client-threads", "2") .put("exchange.page-buffer-client.max-callback-threads", "16") .put("exchange.acknowledge-pages", "false") - .build(); + .buildOrThrow(); ExchangeClientConfig expected = new ExchangeClientConfig() .setMaxBufferSize(DataSize.of(1, Unit.GIGABYTE)) diff --git a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestHistogram.java b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestHistogram.java index 573c5052c538..2b11a8f071a7 100644 --- a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestHistogram.java +++ b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestHistogram.java @@ -384,7 +384,7 @@ private static void testSharedGroupByWithOverlappingValuesRunner(TestingAggregat .put("d4", 2L) .put("a3", 1L) .put("b3", 1L) - .build()); + .buildOrThrow()); AggregationTestInput test1 = testInputBuilder1.build(); test1.runPagesOnAggregatorWithAssertion(0L, aggregationFunction.getFinalType(), test1.createGroupedAggregator(), aggregationTestOutput1); diff --git a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestNumericHistogram.java b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestNumericHistogram.java index d121d5f99467..e666d00b7945 100644 --- a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestNumericHistogram.java +++ b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestNumericHistogram.java @@ -59,7 +59,7 @@ public void testBasic() .put(3.568571428571429, 35.0) .put(3.0023809523809515, 84.0) .put(4.233333333333333, 3.0) - .build(); + .buildOrThrow(); assertEquals(histogram.getBuckets(), expected); } @@ -77,7 +77,7 @@ public void testSameValues() Map expected = ImmutableMap.builder() .put(1.0, 300.0) .put(2.0, 500.0) - .build(); + .buildOrThrow(); assertEquals(histogram.getBuckets(), expected); } diff --git a/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java b/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java index 6252d5d17879..1074b9fee49d 100644 --- a/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java +++ b/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java @@ -192,7 +192,7 @@ public final class FunctionAssertions .put(new Symbol("bound_row"), TEST_ROW_TYPE) .put(new Symbol("bound_short_decimal"), SHORT_DECIMAL_TYPE) .put(new Symbol("bound_long_decimal"), LONG_DECIMAL_TYPE) - .build()); + .buildOrThrow()); private static final Map INPUT_MAPPING = ImmutableMap.builder() .put(new Symbol("bound_long"), 0) @@ -208,7 +208,7 @@ public final class FunctionAssertions .put(new Symbol("bound_row"), 10) .put(new Symbol("bound_short_decimal"), 11) .put(new Symbol("bound_long_decimal"), 12) - .build(); + .buildOrThrow(); private static final PageSourceProvider PAGE_SOURCE_PROVIDER = new TestPageSourceProvider(); private static final PlanNodeId SOURCE_ID = new PlanNodeId("scan"); diff --git a/core/trino-main/src/test/java/io/trino/security/TestAccessControlConfig.java b/core/trino-main/src/test/java/io/trino/security/TestAccessControlConfig.java index 7556e3d859ef..d6f8b366b1bc 100644 --- a/core/trino-main/src/test/java/io/trino/security/TestAccessControlConfig.java +++ b/core/trino-main/src/test/java/io/trino/security/TestAccessControlConfig.java @@ -41,7 +41,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("access-control.config-files", config1.toString() + "," + config2.toString()) - .build(); + .buildOrThrow(); AccessControlConfig expected = new AccessControlConfig() .setAccessControlFiles(ImmutableList.of(config1.toFile(), config2.toFile())); diff --git a/core/trino-main/src/test/java/io/trino/server/TestEmbeddedDiscoveryConfig.java b/core/trino-main/src/test/java/io/trino/server/TestEmbeddedDiscoveryConfig.java index 2f6ac4be165a..7ad7b2e39709 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestEmbeddedDiscoveryConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestEmbeddedDiscoveryConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("discovery-server.enabled", "false") - .build(); + .buildOrThrow(); EmbeddedDiscoveryConfig expected = new EmbeddedDiscoveryConfig() .setEnabled(false); diff --git a/core/trino-main/src/test/java/io/trino/server/TestFailureDetectorConfig.java b/core/trino-main/src/test/java/io/trino/server/TestFailureDetectorConfig.java index 9c12154f4a8f..cb11eaabd45b 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestFailureDetectorConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestFailureDetectorConfig.java @@ -47,7 +47,7 @@ public void testExplicitPropertyMappings() .put("failure-detector.heartbeat-interval", "10s") .put("failure-detector.threshold", "0.5") .put("failure-detector.enabled", "false") - .build(); + .buildOrThrow(); FailureDetectorConfig expected = new FailureDetectorConfig() .setExpirationGraceInterval(new Duration(5, TimeUnit.MINUTES)) diff --git a/core/trino-main/src/test/java/io/trino/server/TestInternalCommunicationConfig.java b/core/trino-main/src/test/java/io/trino/server/TestInternalCommunicationConfig.java index 0cab8b2ef417..d9c529cd6eff 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestInternalCommunicationConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestInternalCommunicationConfig.java @@ -57,7 +57,7 @@ public void testExplicitPropertyMappings() .put("internal-communication.https.truststore.path", truststoreFile.toString()) .put("internal-communication.https.truststore.key", "trust-key") .put("http-server.https.enabled", "true") - .build(); + .buildOrThrow(); InternalCommunicationConfig expected = new InternalCommunicationConfig() .setSharedSecret("secret") diff --git a/core/trino-main/src/test/java/io/trino/server/TestJmxNamingConfig.java b/core/trino-main/src/test/java/io/trino/server/TestJmxNamingConfig.java index 21f8812c4178..751ec4f9fc32 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestJmxNamingConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestJmxNamingConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("jmx.base-name", "my.stuff") - .build(); + .buildOrThrow(); JmxNamingConfig expected = new JmxNamingConfig() .setDomainBase("my.stuff"); diff --git a/core/trino-main/src/test/java/io/trino/server/TestProtocolConfig.java b/core/trino-main/src/test/java/io/trino/server/TestProtocolConfig.java index 299d66e8dd9c..498271861a46 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestProtocolConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestProtocolConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("protocol.v1.alternate-header-name", "taco") - .build(); + .buildOrThrow(); ProtocolConfig expected = new ProtocolConfig() .setAlternateHeaderName("taco"); diff --git a/core/trino-main/src/test/java/io/trino/server/TestQuerySessionSupplier.java b/core/trino-main/src/test/java/io/trino/server/TestQuerySessionSupplier.java index 0af7013935cf..66a6df8fbe90 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestQuerySessionSupplier.java +++ b/core/trino-main/src/test/java/io/trino/server/TestQuerySessionSupplier.java @@ -91,11 +91,11 @@ public void testCreateSession() .put(QUERY_MAX_MEMORY, "1GB") .put(JOIN_DISTRIBUTION_TYPE, "partitioned") .put(HASH_PARTITION_COUNT, "43") - .build()); + .buildOrThrow()); assertEquals(session.getPreparedStatements(), ImmutableMap.builder() .put("query1", "select * from foo") .put("query2", "select * from bar") - .build()); + .buildOrThrow()); } @Test diff --git a/core/trino-main/src/test/java/io/trino/server/TestServerConfig.java b/core/trino-main/src/test/java/io/trino/server/TestServerConfig.java index 9fc561afad06..fd0e6862e678 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestServerConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestServerConfig.java @@ -48,7 +48,7 @@ public void testExplicitPropertyMappings() .put("shutdown.grace-period", "5m") .put("query-results.compression-enabled", "false") .put("query.info-url-template", "https://example.com/query/${QUERY_ID}") - .build(); + .buildOrThrow(); ServerConfig expected = new ServerConfig() .setCoordinator(false) diff --git a/core/trino-main/src/test/java/io/trino/server/TestServerPluginsProviderConfig.java b/core/trino-main/src/test/java/io/trino/server/TestServerPluginsProviderConfig.java index 380d1e8162df..71138a35d9cd 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestServerPluginsProviderConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/TestServerPluginsProviderConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("plugin.dir", "plugins-dir") - .build(); + .buildOrThrow(); ServerPluginsProviderConfig expected = new ServerPluginsProviderConfig() .setInstalledPluginsDir(new File("plugins-dir")); diff --git a/core/trino-main/src/test/java/io/trino/server/TestSessionPropertyDefaults.java b/core/trino-main/src/test/java/io/trino/server/TestSessionPropertyDefaults.java index ff22e358a21c..157e3ababc55 100644 --- a/core/trino-main/src/test/java/io/trino/server/TestSessionPropertyDefaults.java +++ b/core/trino-main/src/test/java/io/trino/server/TestSessionPropertyDefaults.java @@ -55,13 +55,13 @@ public void testApplyDefaultProperties() ImmutableMap.builder() .put(QUERY_MAX_MEMORY, "2GB") //Will be overridden .put(QUERY_MAX_TOTAL_MEMORY, "2GB") //Will remain default - .build(), + .buildOrThrow(), ImmutableMap.of( "testCatalog", ImmutableMap.builder() .put("explicit_set", "override") // Will be overridden .put("catalog_default", "catalog_default") // Will remain default - .build())); + .buildOrThrow())); sessionPropertyDefaults.addConfigurationManagerFactory(factory); sessionPropertyDefaults.setConfigurationManager(factory.getName(), ImmutableMap.of()); @@ -78,14 +78,14 @@ public void testApplyDefaultProperties() .put(QUERY_MAX_MEMORY, "1GB") .put(JOIN_DISTRIBUTION_TYPE, "partitioned") .put(HASH_PARTITION_COUNT, "43") - .build()); + .buildOrThrow()); assertEquals( session.getUnprocessedCatalogProperties(), ImmutableMap.of( "testCatalog", ImmutableMap.builder() .put("explicit_set", "explicit_set") - .build())); + .buildOrThrow())); session = sessionPropertyDefaults.newSessionWithDefaultProperties(session, Optional.empty(), TEST_RESOURCE_GROUP_ID); @@ -94,7 +94,7 @@ public void testApplyDefaultProperties() .put(JOIN_DISTRIBUTION_TYPE, "partitioned") // User provided value is used .put(HASH_PARTITION_COUNT, "43") // User provided value is used .put(QUERY_MAX_TOTAL_MEMORY, "2GB") // Default value is used - .build()); + .buildOrThrow()); assertEquals( session.getUnprocessedCatalogProperties(), ImmutableMap.of( @@ -102,6 +102,6 @@ public void testApplyDefaultProperties() ImmutableMap.builder() .put("explicit_set", "explicit_set") // User provided value overrides default value .put("catalog_default", "catalog_default") // Default value is used - .build())); + .buildOrThrow())); } } diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestCertificateConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestCertificateConfig.java index 9baa0b8bdc83..11cea1640eb8 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestCertificateConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestCertificateConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("http-server.authentication.certificate.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.certificate.user-mapping.file", userMappingFile.toString()) - .build(); + .buildOrThrow(); CertificateConfig expected = new CertificateConfig() .setUserMappingPattern("(.*)@something") diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestHeaderAuthenticatorConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestHeaderAuthenticatorConfig.java index 41b61c23f877..44f41646f87c 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestHeaderAuthenticatorConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestHeaderAuthenticatorConfig.java @@ -49,7 +49,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.header.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.header.user-mapping.file", userMappingFile.toString()) .put("header-authenticator.config-files", config1.toString() + "," + config2.toString()) - .build(); + .buildOrThrow(); HeaderAuthenticatorConfig expected = new HeaderAuthenticatorConfig() .setHeaderAuthenticatorFiles(ImmutableList.of(config1.toAbsolutePath().toString(), config2.toAbsolutePath().toString())) diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestInsecureAuthenticatorConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestInsecureAuthenticatorConfig.java index 5d55e3988d78..a41cb3ef4edb 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestInsecureAuthenticatorConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestInsecureAuthenticatorConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("http-server.authentication.insecure.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.insecure.user-mapping.file", userMappingFile.toString()) - .build(); + .buildOrThrow(); InsecureAuthenticatorConfig expected = new InsecureAuthenticatorConfig() .setUserMappingPattern("(.*)@something") diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestKerberosConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestKerberosConfig.java index 768df661f827..4fda0beb3247 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestKerberosConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestKerberosConfig.java @@ -58,7 +58,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.krb5.name-type", "USER_NAME") .put("http-server.authentication.krb5.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.krb5.user-mapping.file", userMappingFile.toString()) - .build(); + .buildOrThrow(); KerberosConfig expected = new KerberosConfig() .setKerberosConfig(krbConfigFile.toFile()) diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestPasswordAuthenticatorConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestPasswordAuthenticatorConfig.java index 77bfd715212f..f3feb0f17352 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestPasswordAuthenticatorConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestPasswordAuthenticatorConfig.java @@ -48,7 +48,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.password.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.password.user-mapping.file", userMappingFile.toString()) .put("password-authenticator.config-files", config1.toString() + "," + config2.toString()) - .build(); + .buildOrThrow(); PasswordAuthenticatorConfig expected = new PasswordAuthenticatorConfig() .setUserMappingPattern("(.*)@something") diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java b/core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java index db8accbbe627..55ce3f382052 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java @@ -117,7 +117,7 @@ public class TestResourceSecurity .put("http-server.https.keystore.key", "") .put("http-server.process-forwarded", "true") .put("http-server.authentication.insecure.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build(); + .buildOrThrow(); private static final String TEST_USER = "test-user"; private static final String TEST_USER_LOGIN = TEST_USER + "@allowed"; private static final String TEST_PASSWORD = "test-password"; @@ -168,7 +168,7 @@ public void testInsecureAuthenticatorHttp() try (TestingTrinoServer server = TestingTrinoServer.builder() .setProperties(ImmutableMap.builder() .put("http-server.authentication.insecure.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -198,7 +198,7 @@ public void testInsecureAuthenticatorHttpsOnly() .setProperties(ImmutableMap.builder() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.allow-insecure-over-http", "false") - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -217,7 +217,7 @@ public void testPasswordAuthenticator() .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.type", "password") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -237,7 +237,7 @@ public void testMultiplePasswordAuthenticators() .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.type", "password") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate, TestResourceSecurity::authenticate2); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -257,7 +257,7 @@ public void testMultiplePasswordAuthenticatorsMessages() .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.type", "password") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate, TestResourceSecurity::authenticate2); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -282,7 +282,7 @@ public void testPasswordAuthenticatorUserMapping() .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.type", "password") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); @@ -337,7 +337,7 @@ public void testPasswordAuthenticatorWithInsecureHttp() .put("http-server.authentication.type", "password") .put("http-server.authentication.allow-insecure-over-http", "true") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -359,7 +359,7 @@ public void testFixedManagerAuthenticatorHttpInsecureEnabledOnly() .put("http-server.authentication.allow-insecure-over-http", "true") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) .put("management.user", MANAGEMENT_USER) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -382,7 +382,7 @@ public void testFixedManagerAuthenticatorHttpInsecureDisabledOnly() .put("http-server.authentication.allow-insecure-over-http", "false") .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) .put("management.user", MANAGEMENT_USER) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -409,7 +409,7 @@ public void testFixedManagerAuthenticatorHttps() .put("http-server.authentication.allow-insecure-over-http", "true") .put("management.user", MANAGEMENT_USER) .put("management.user.https-enabled", "true") - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestResourceSecurity::authenticate); server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION); @@ -430,7 +430,7 @@ public void testCertAuthenticator() .put("http-server.authentication.type", "certificate") .put("http-server.https.truststore.path", LOCALHOST_KEYSTORE) .put("http-server.https.truststore.key", "") - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.NO_IMPERSONATION); HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -468,7 +468,7 @@ private void verifyJwtAuthenticator(Optional principalField) .put("http-server.authentication.type", "jwt") .put("http-server.authentication.jwt.key-file", HMAC_KEY) .put("http-server.authentication.jwt.principal-field", principalField.orElse("sub")) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.NO_IMPERSONATION); HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -507,7 +507,7 @@ public void testJwtWithJwkAuthenticator() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.type", "jwt") .put("http-server.authentication.jwt.key-file", jwkServer.getBaseUrl().toString()) - .build()) + .buildOrThrow()) .build()) { server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.NO_IMPERSONATION); HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -591,7 +591,7 @@ private void verifyOAuth2Authenticator(boolean webUiEnabled, Optional pr .put("http-server.authentication.oauth2.client-id", clientId) .put("http-server.authentication.oauth2.client-secret", "client-secret") .put("http-server.authentication.oauth2.principal-field", principalField.orElse("sub")) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> newOptionalBinder(binder, OAuth2Client.class) .setBinding() .toInstance(new OAuth2Client() diff --git a/core/trino-main/src/test/java/io/trino/server/security/TestSecurityConfig.java b/core/trino-main/src/test/java/io/trino/server/security/TestSecurityConfig.java index b9b30ddc4042..181a956d7984 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/TestSecurityConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/TestSecurityConfig.java @@ -43,7 +43,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.allow-insecure-over-http", "false") .put("management.user", "management-user") .put("management.user.https-enabled", "true") - .build(); + .buildOrThrow(); SecurityConfig expected = new SecurityConfig() .setAuthenticationTypes(ImmutableList.of("KERBEROS", "PASSWORD")) diff --git a/core/trino-main/src/test/java/io/trino/server/security/jwt/TestJwtAuthenticatorConfig.java b/core/trino-main/src/test/java/io/trino/server/security/jwt/TestJwtAuthenticatorConfig.java index 5aa43d937c54..e58e288e1976 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/jwt/TestJwtAuthenticatorConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/security/jwt/TestJwtAuthenticatorConfig.java @@ -53,7 +53,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.jwt.principal-field", "some-field") .put("http-server.authentication.jwt.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.jwt.user-mapping.file", userMappingFile.toString()) - .build(); + .buildOrThrow(); JwtAuthenticatorConfig expected = new JwtAuthenticatorConfig() .setKeyFile(jwtKeyFile.toString()) diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/BaseOAuth2WebUiAuthenticationFilterTest.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/BaseOAuth2WebUiAuthenticationFilterTest.java index b19b0384da31..cb1dfb4c8c7b 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/BaseOAuth2WebUiAuthenticationFilterTest.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/BaseOAuth2WebUiAuthenticationFilterTest.java @@ -188,7 +188,7 @@ public void testUnsignedToken() .put("nbf", now) .put("scp", ImmutableList.of("openid")) .put("sub", "foo@bar.com") - .build())) + .buildOrThrow())) .signWith(keyGenerator.generateKeyPair().getPrivate()) .compact(); try (Response response = httpClientWithOAuth2Cookie(token, false) diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2Config.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2Config.java index 158645c68d5e..5f230415ccd3 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2Config.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2Config.java @@ -74,7 +74,7 @@ public void testExplicitPropertyMappings() .put("http-server.authentication.oauth2.challenge-timeout", "90s") .put("http-server.authentication.oauth2.user-mapping.pattern", "(.*)@something") .put("http-server.authentication.oauth2.user-mapping.file", userMappingFile.toString()) - .build(); + .buildOrThrow(); OAuth2Config expected = new OAuth2Config() .setStateKey("key-secret") diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithJwt.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithJwt.java index 576831684d28..d21c932e66c0 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithJwt.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithJwt.java @@ -48,7 +48,7 @@ protected ImmutableMap getOAuth2Config(String idpUrl) .put("http-server.authentication.oauth2.additional-audiences", TRUSTED_CLIENT_ID) .put("http-server.authentication.oauth2.user-mapping.pattern", "(.*)(@.*)?") .put("oauth2-jwk.http-client.trust-store-path", Resources.getResource("cert/localhost.pem").getPath()) - .build(); + .buildOrThrow(); } @Override diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithOpaque.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithOpaque.java index e61db0b57f38..6ecd58a4d24a 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithOpaque.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithOpaque.java @@ -51,7 +51,7 @@ protected ImmutableMap getOAuth2Config(String idpUrl) .put("http-server.authentication.oauth2.additional-audiences", TRUSTED_CLIENT_ID) .put("http-server.authentication.oauth2.user-mapping.pattern", "(.*)(@.*)?") .put("oauth2-jwk.http-client.trust-store-path", Resources.getResource("cert/localhost.pem").getPath()) - .build(); + .buildOrThrow(); } @Override diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestingHydraIdentityProvider.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestingHydraIdentityProvider.java index dca8ae445fd9..a6d6ded7d3c5 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestingHydraIdentityProvider.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestingHydraIdentityProvider.java @@ -364,7 +364,7 @@ private static void runTestServer(boolean useJwt) try (TestingTrinoServer ignored = TestingTrinoServer.builder() .setCoordinator(true) .setAdditionalModule(new WebUiModule()) - .setProperties(config.build()) + .setProperties(config.buildOrThrow()) .build()) { Thread.sleep(Long.MAX_VALUE); } diff --git a/core/trino-main/src/test/java/io/trino/server/ui/TestFixedUserWebUiConfig.java b/core/trino-main/src/test/java/io/trino/server/ui/TestFixedUserWebUiConfig.java index a98bae8e9996..a4a7bc605dac 100644 --- a/core/trino-main/src/test/java/io/trino/server/ui/TestFixedUserWebUiConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/ui/TestFixedUserWebUiConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("web-ui.user", "some-user") - .build(); + .buildOrThrow(); FixedUserWebUiConfig expected = new FixedUserWebUiConfig() .setUsername("some-user"); diff --git a/core/trino-main/src/test/java/io/trino/server/ui/TestFormWebUiConfig.java b/core/trino-main/src/test/java/io/trino/server/ui/TestFormWebUiConfig.java index 77a71d8c933f..ecc9a8e4d9fb 100644 --- a/core/trino-main/src/test/java/io/trino/server/ui/TestFormWebUiConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/ui/TestFormWebUiConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("web-ui.session-timeout", "33s") .put("web-ui.shared-secret", "test-secret") - .build(); + .buildOrThrow(); FormWebUiConfig expected = new FormWebUiConfig() .setSessionTimeout(new Duration(33, TimeUnit.SECONDS)) diff --git a/core/trino-main/src/test/java/io/trino/server/ui/TestWebUi.java b/core/trino-main/src/test/java/io/trino/server/ui/TestWebUi.java index 90df34ad1a23..7a3e670d14a3 100644 --- a/core/trino-main/src/test/java/io/trino/server/ui/TestWebUi.java +++ b/core/trino-main/src/test/java/io/trino/server/ui/TestWebUi.java @@ -117,7 +117,7 @@ public class TestWebUi .put("http-server.https.keystore.key", "") .put("http-server.process-forwarded", "true") .put("http-server.authentication.allow-insecure-over-http", "true") - .build(); + .buildOrThrow(); private static final String STATE_KEY = "test-state-key"; public static final String TOKEN_ISSUER = "http://example.com/"; public static final String OAUTH_CLIENT_ID = "client"; @@ -130,7 +130,7 @@ public class TestWebUi .put("http-server.authentication.oauth2.token-url", "http://example.com/") .put("http-server.authentication.oauth2.client-id", OAUTH_CLIENT_ID) .put("http-server.authentication.oauth2.client-secret", "client-secret") - .build(); + .buildOrThrow(); private static final String TEST_USER = "test-user"; private static final String AUTHENTICATED_USER = TEST_USER + "@allowed"; private static final String FORM_LOGIN_USER = "form-login-user"; @@ -179,7 +179,7 @@ public void testInsecureAuthenticator() .setProperties(ImmutableMap.builder() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.insecure.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); @@ -198,7 +198,7 @@ public void testPasswordAuthenticator() .put("http-server.authentication.type", "password") .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestWebUi::authenticate); @@ -217,7 +217,7 @@ public void testMultiplePasswordAuthenticators() .put("http-server.authentication.type", "password") .put("password-authenticator.config-files", passwordConfigDummy.toString()) .put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)) .build()) { server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestWebUi::authenticate, TestWebUi::authenticate2); @@ -432,7 +432,7 @@ public void testDisabled() .setProperties(ImmutableMap.builder() .putAll(SECURE_PROPERTIES) .put("web-ui.enabled", "false") - .build()) + .buildOrThrow()) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); testDisabled(httpServerInfo.getHttpUri()); @@ -467,7 +467,7 @@ public void testNoPasswordAuthenticator() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.type", "password") .put("password-authenticator.config-files", passwordConfigDummy.toString()) - .build()) + .buildOrThrow()) .build()) { // a password manager is required, so a secure request will fail // a real server will fail to start, but verify that we get an exception here to be safe @@ -489,7 +489,7 @@ public void testFixedAuthenticator() .putAll(SECURE_PROPERTIES) .put("web-ui.authentication.type", "fixed") .put("web-ui.user", "test-user") - .build()) + .buildOrThrow()) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); String nodeId = server.getInstance(Key.get(NodeInfo.class)).getNodeId(); @@ -524,7 +524,7 @@ public void testCertAuthenticator() .put("http-server.authentication.type", "certificate") .put("http-server.https.truststore.path", LOCALHOST_KEYSTORE) .put("http-server.https.truststore.key", "") - .build()) + .buildOrThrow()) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); String nodeId = server.getInstance(Key.get(NodeInfo.class)).getNodeId(); @@ -556,7 +556,7 @@ public void testJwtAuthenticator() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.type", "jwt") .put("http-server.authentication.jwt.key-file", HMAC_KEY) - .build()) + .buildOrThrow()) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); String nodeId = server.getInstance(Key.get(NodeInfo.class)).getNodeId(); @@ -592,7 +592,7 @@ public void testJwtWithJwkAuthenticator() .putAll(SECURE_PROPERTIES) .put("http-server.authentication.type", "jwt") .put("http-server.authentication.jwt.key-file", jwkServer.getBaseUrl().toString()) - .build()) + .buildOrThrow()) .build()) { HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class)); String nodeId = server.getInstance(Key.get(NodeInfo.class)).getNodeId(); @@ -631,7 +631,7 @@ public void testOAuth2Authenticator() .setProperties(ImmutableMap.builder() .putAll(OAUTH2_PROPERTIES) .put("http-server.authentication.oauth2.jwks-url", jwkServer.getBaseUrl().toString()) - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> newOptionalBinder(binder, OAuth2Client.class) .setBinding() .toInstance(new OAuth2ClientStub(accessToken))) @@ -656,7 +656,7 @@ public void testOAuth2AuthenticatorWithoutOpenIdScope() .putAll(OAUTH2_PROPERTIES) .put("http-server.authentication.oauth2.jwks-url", jwkServer.getBaseUrl().toString()) .put("http-server.authentication.oauth2.scopes", "") - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> newOptionalBinder(binder, OAuth2Client.class) .setBinding() .toInstance(new OAuth2ClientStub(accessToken))) @@ -685,7 +685,7 @@ public void testCustomPrincipalField() .put("http-server.authentication.oauth2.jwks-url", jwkServer.getBaseUrl().toString()) .put("http-server.authentication.oauth2.principal-field", "preferred_username") .put("http-server.authentication.oauth2.user-mapping.pattern", "(.*)@.*") - .build()) + .buildOrThrow()) .setAdditionalModule(binder -> { newOptionalBinder(binder, OAuth2Client.class) .setBinding() diff --git a/core/trino-main/src/test/java/io/trino/server/ui/TestWebUiConfig.java b/core/trino-main/src/test/java/io/trino/server/ui/TestWebUiConfig.java index 028a48b6a6f4..4d60b2c4d35b 100644 --- a/core/trino-main/src/test/java/io/trino/server/ui/TestWebUiConfig.java +++ b/core/trino-main/src/test/java/io/trino/server/ui/TestWebUiConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("web-ui.enabled", "false") - .build(); + .buildOrThrow(); WebUiConfig expected = new WebUiConfig() .setEnabled(false); diff --git a/core/trino-main/src/test/java/io/trino/spiller/TestNodeSpillConfig.java b/core/trino-main/src/test/java/io/trino/spiller/TestNodeSpillConfig.java index 42574b12a098..bc7b921cd761 100644 --- a/core/trino-main/src/test/java/io/trino/spiller/TestNodeSpillConfig.java +++ b/core/trino-main/src/test/java/io/trino/spiller/TestNodeSpillConfig.java @@ -45,7 +45,7 @@ public void testExplicitPropertyMappings() .put("query-max-spill-per-node", "15 MB") .put("spill-compression-enabled", "true") .put("spill-encryption-enabled", "true") - .build(); + .buildOrThrow(); NodeSpillConfig expected = new NodeSpillConfig() .setMaxSpillPerNode(DataSize.of(10, MEGABYTE)) diff --git a/core/trino-main/src/test/java/io/trino/sql/TestExpressionInterpreter.java b/core/trino-main/src/test/java/io/trino/sql/TestExpressionInterpreter.java index ec079a58ba78..9e766646e332 100644 --- a/core/trino-main/src/test/java/io/trino/sql/TestExpressionInterpreter.java +++ b/core/trino-main/src/test/java/io/trino/sql/TestExpressionInterpreter.java @@ -116,7 +116,7 @@ public class TestExpressionInterpreter .put(new Symbol("unbound_interval"), INTERVAL_DAY_TIME) .put(new Symbol("unbound_pattern"), VARCHAR) .put(new Symbol("unbound_null_string"), VARCHAR) - .build()); + .buildOrThrow()); private static final SymbolResolver INPUTS = symbol -> { switch (symbol.getName().toLowerCase(ENGLISH)) { diff --git a/core/trino-main/src/test/java/io/trino/sql/TestSqlEnvironmentConfig.java b/core/trino-main/src/test/java/io/trino/sql/TestSqlEnvironmentConfig.java index db94d8df26cb..6f6f9e3cac9d 100644 --- a/core/trino-main/src/test/java/io/trino/sql/TestSqlEnvironmentConfig.java +++ b/core/trino-main/src/test/java/io/trino/sql/TestSqlEnvironmentConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("sql.default-catalog", "some-catalog") .put("sql.default-schema", "some-schema") .put("sql.forced-session-time-zone", "UTC") - .build(); + .buildOrThrow(); SqlEnvironmentConfig expected = new SqlEnvironmentConfig() .setPath("a.b, c.d") diff --git a/core/trino-main/src/test/java/io/trino/sql/TestSqlToRowExpressionTranslator.java b/core/trino-main/src/test/java/io/trino/sql/TestSqlToRowExpressionTranslator.java index 4224fa04531a..503ea25e3d9b 100644 --- a/core/trino-main/src/test/java/io/trino/sql/TestSqlToRowExpressionTranslator.java +++ b/core/trino-main/src/test/java/io/trino/sql/TestSqlToRowExpressionTranslator.java @@ -58,7 +58,7 @@ public void testPossibleExponentialOptimizationTime() expression = new CoalesceExpression(expression, new LongLiteral("2")); types.put(NodeRef.of(expression), BIGINT); } - translateAndOptimize(expression, types.build()); + translateAndOptimize(expression, types.buildOrThrow()); } @Test diff --git a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestFeaturesConfig.java b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestFeaturesConfig.java index 1dc196bff85b..4f01f1f6583a 100644 --- a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestFeaturesConfig.java +++ b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestFeaturesConfig.java @@ -195,7 +195,7 @@ public void testExplicitPropertyMappings() .put("incremental-hash-array-load-factor.enabled", "false") .put("hide-inaccessible-columns", "true") .put("legacy.allow-set-view-authorization", "true") - .build(); + .buildOrThrow(); FeaturesConfig expected = new FeaturesConfig() .setCpuCostWeight(0.4) diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestCompilerConfig.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestCompilerConfig.java index 7f8803c1bfb6..b7b227c6442e 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestCompilerConfig.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestCompilerConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("compiler.expression-cache-size", "52") - .build(); + .buildOrThrow(); CompilerConfig expected = new CompilerConfig() .setExpressionCacheSize(52); diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestConnectorExpressionTranslator.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestConnectorExpressionTranslator.java index d22278f508ce..34b360e2030f 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestConnectorExpressionTranslator.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestConnectorExpressionTranslator.java @@ -50,7 +50,7 @@ public class TestConnectorExpressionTranslator private static final Map symbols = ImmutableMap.builder() .put(new Symbol("double_symbol_1"), DOUBLE) .put(new Symbol("row_symbol_1"), ROW_TYPE) - .build(); + .buildOrThrow(); private static final TypeProvider TYPE_PROVIDER = TypeProvider.copyOf(symbols); private static final Map variableMappings = symbols.entrySet().stream() diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestDomainTranslator.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestDomainTranslator.java index c1b20d0b8ec7..5fce15968c26 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestDomainTranslator.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestDomainTranslator.java @@ -165,7 +165,7 @@ public class TestDomainTranslator .put(C_TINYINT, TINYINT) .put(C_REAL, REAL) .put(C_REAL_1, REAL) - .build()); + .buildOrThrow()); private static final long TIMESTAMP_VALUE = new DateTime(2013, 3, 30, 1, 5, 0, 0, DateTimeZone.UTC).getMillis(); private static final long DATE_VALUE = TimeUnit.MILLISECONDS.toDays(new DateTime(2001, 1, 22, 0, 0, 0, 0, DateTimeZone.UTC).getMillis()); @@ -225,7 +225,7 @@ public void testRoundTrip() .put(C_DATE, Domain.singleValue(DATE, DATE_VALUE)) .put(C_COLOR, Domain.singleValue(COLOR, COLOR_VALUE_1)) .put(C_HYPER_LOG_LOG, Domain.notNull(HYPER_LOG_LOG)) - .build()); + .buildOrThrow()); assertPredicateTranslates(toPredicate(tupleDomain), tupleDomain); } @@ -291,7 +291,7 @@ public void testToPredicateNone() .put(C_DOUBLE, Domain.onlyNull(DOUBLE)) .put(C_VARCHAR, Domain.notNull(VARCHAR)) .put(C_BOOLEAN, Domain.none(BOOLEAN)) - .build()); + .buildOrThrow()); assertEquals(toPredicate(tupleDomain), FALSE_LITERAL); } @@ -304,7 +304,7 @@ public void testToPredicateAllIgnored() .put(C_DOUBLE, Domain.onlyNull(DOUBLE)) .put(C_VARCHAR, Domain.notNull(VARCHAR)) .put(C_BOOLEAN, Domain.all(BOOLEAN)) - .build()); + .buildOrThrow()); ExtractionResult result = fromPredicate(toPredicate(tupleDomain)); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); @@ -312,7 +312,7 @@ public void testToPredicateAllIgnored() .put(C_BIGINT, Domain.singleValue(BIGINT, 1L)) .put(C_DOUBLE, Domain.onlyNull(DOUBLE)) .put(C_VARCHAR, Domain.notNull(VARCHAR)) - .build())); + .buildOrThrow())); } @Test diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java index 7e3758724f0c..e66dcec2a449 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java @@ -200,7 +200,7 @@ public void setUp() .put(E, new TestingColumnHandle("e")) .put(F, new TestingColumnHandle("f")) .put(R, new TestingColumnHandle("r")) - .build(); + .buildOrThrow(); Map assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D, E, F))); baseTableScan = TableScanNode.newInstance( @@ -578,7 +578,7 @@ public void testValues() .put(B, BIGINT) .put(D, DOUBLE) .put(R, RowType.anonymous(ImmutableList.of(BIGINT, BIGINT))) - .build()); + .buildOrThrow()); // one column assertEquals( diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestPartialTranslator.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestPartialTranslator.java index 65a7c02b0904..103a18ba7fe5 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestPartialTranslator.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestPartialTranslator.java @@ -59,7 +59,7 @@ public class TestPartialTranslator .put(new Symbol("double_symbol_2"), DOUBLE) .put(new Symbol("bigint_symbol_1"), BIGINT) .put(new Symbol("row_symbol_1"), rowType(field("int_symbol_1", INTEGER), field("varchar_symbol_1", createVarcharType(5)))) - .build()); + .buildOrThrow()); @Test public void testPartialTranslator() diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestSortExpressionExtractor.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestSortExpressionExtractor.java index fcb32e7f0c5e..ec6b30a74652 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestSortExpressionExtractor.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestSortExpressionExtractor.java @@ -42,7 +42,7 @@ public class TestSortExpressionExtractor .put(new Symbol("b2"), DOUBLE) .put(new Symbol("p1"), BIGINT) .put(new Symbol("p2"), DOUBLE) - .build()); + .buildOrThrow()); private static final Set BUILD_SYMBOLS = ImmutableSet.of(new Symbol("b1"), new Symbol("b2")); @Test diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestTypeValidator.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestTypeValidator.java index 5bf5d58e36ec..0236be628794 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestTypeValidator.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestTypeValidator.java @@ -92,7 +92,7 @@ public void setUp() .put(columnC, new TestingColumnHandle("c")) .put(columnD, new TestingColumnHandle("d")) .put(columnE, new TestingColumnHandle("e")) - .build(); + .buildOrThrow(); baseTableScan = new TableScanNode( newId(), diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/PatternRecognitionMatcher.java b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/PatternRecognitionMatcher.java index ff297aa4edfd..39360db53377 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/PatternRecognitionMatcher.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/PatternRecognitionMatcher.java @@ -287,7 +287,7 @@ public PlanMatchPattern build() initial, pattern, subsets, - variableDefinitions.build())); + variableDefinitions.buildOrThrow())); windowFunctionMatchers.forEach(result::with); measures.entrySet().stream() .map(entry -> { diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/SymbolAliases.java b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/SymbolAliases.java index fe67807bb20c..bac70254ffe1 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/SymbolAliases.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/SymbolAliases.java @@ -104,7 +104,7 @@ else if (assignment.getKey().toSymbolReference().equals(existingAlias.getValue() } } } - return mapUpdate.build(); + return mapUpdate.buildOrThrow(); } /* diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestCanonicalizeExpressionRewriter.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestCanonicalizeExpressionRewriter.java index 7090947fe6f9..e8c0eec61cfd 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestCanonicalizeExpressionRewriter.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestCanonicalizeExpressionRewriter.java @@ -135,7 +135,7 @@ private static void assertRewritten(String from, String to) .put(new Symbol("ts"), createTimestampType(3)) .put(new Symbol("tstz"), createTimestampWithTimeZoneType(3)) .put(new Symbol("v"), createVarcharType(100)) - .build())); + .buildOrThrow())); }), PlanBuilder.expression(to), SymbolAliases.builder() diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestInlineProjections.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestInlineProjections.java index 4fef8b707819..3c01adbd2eca 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestInlineProjections.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestInlineProjections.java @@ -74,7 +74,7 @@ public void test() .put("out8", PlanMatchPattern.expression("z + 1")) .put("out9", PlanMatchPattern.expression("try(2 * x)")) .put("out10", PlanMatchPattern.expression("x + x")) - .build(), + .buildOrThrow(), project( ImmutableMap.of( "x", PlanMatchPattern.expression("x"), @@ -100,7 +100,7 @@ public void testEliminatesIdentityProjection() project( ImmutableMap.builder() .put("out1", PlanMatchPattern.expression("x - 1 + 2")) - .build(), + .buildOrThrow(), values(ImmutableMap.of("x", 0)))); } diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestMergePatternRecognitionNodes.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestMergePatternRecognitionNodes.java index 546b1ffa19ae..2f0653745f38 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestMergePatternRecognitionNodes.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestMergePatternRecognitionNodes.java @@ -429,7 +429,7 @@ public void testMergeWithParentDependingOnProject() .put("child_measure", PlanMatchPattern.expression("child_measure")) .put("expression_1", PlanMatchPattern.expression("expression_1")) .put("expression_2", PlanMatchPattern.expression("a + b")) - .build(), + .buildOrThrow(), patternRecognition(builder -> builder .addMeasure("parent_measure", "LAST(X.expression_1)", BIGINT) .addMeasure("child_measure", "FIRST(X.b)", BIGINT) diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java index 2e380b50c373..78d03f1f4cac 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java @@ -157,7 +157,7 @@ public void testPushDownDereferenceThroughJoin() .put("left_x", PlanMatchPattern.expression("x")) .put("right_y", PlanMatchPattern.expression("y")) .put("z", PlanMatchPattern.expression("z")) - .build(), + .buildOrThrow(), join(INNER, ImmutableList.of(), strictProject( ImmutableMap.of( @@ -170,7 +170,7 @@ public void testPushDownDereferenceThroughJoin() .put("y", PlanMatchPattern.expression("msg2[2]")) .put("z", PlanMatchPattern.expression("z")) .put("msg2", PlanMatchPattern.expression("msg2")) - .build(), + .buildOrThrow(), values("msg2", "z"))))); // Verify pushdown for filters @@ -221,7 +221,7 @@ public void testPushdownDereferencesThroughSemiJoin() ImmutableMap.builder() .put("msg1_x", PlanMatchPattern.expression("expr")) .put("msg2_x", PlanMatchPattern.expression("msg2[1]")) // Not pushed down because msg2 is sourceJoinSymbol - .build(), + .buildOrThrow(), semiJoin( "msg2", "filtering_msg", @@ -376,7 +376,7 @@ public void testPushDownDereferenceThroughLimit() .put("msg1_x", PlanMatchPattern.expression("x")) .put("msg2_y", PlanMatchPattern.expression("msg2[2]")) .put("z", PlanMatchPattern.expression("z")) - .build(), + .buildOrThrow(), limit( 10, ImmutableList.of(sort("msg2", ASCENDING, FIRST)), @@ -386,7 +386,7 @@ public void testPushDownDereferenceThroughLimit() .put("z", PlanMatchPattern.expression("z")) .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) - .build(), + .buildOrThrow(), values("msg1", "msg2", "z"))))); } @@ -411,7 +411,7 @@ public void testPushDownDereferenceThroughLimitWithPreSortedInputs() .put("msg1_x", PlanMatchPattern.expression("x")) .put("msg2_y", PlanMatchPattern.expression("msg2[2]")) .put("z", PlanMatchPattern.expression("z")) - .build(), + .buildOrThrow(), limit( 10, ImmutableList.of(), @@ -423,7 +423,7 @@ public void testPushDownDereferenceThroughLimitWithPreSortedInputs() .put("z", PlanMatchPattern.expression("z")) .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) - .build(), + .buildOrThrow(), values("msg1", "msg2", "z"))))); } @@ -459,14 +459,14 @@ public void testPushDownDereferenceThroughSort() ImmutableMap.builder() .put("msg_x", PlanMatchPattern.expression("x")) .put("z", PlanMatchPattern.expression("z")) - .build(), + .buildOrThrow(), sort(ImmutableList.of(sort("z", ASCENDING, SortItem.NullOrdering.FIRST)), strictProject( ImmutableMap.builder() .put("x", PlanMatchPattern.expression("msg[1]")) .put("z", PlanMatchPattern.expression("z")) .put("msg", PlanMatchPattern.expression("msg")) - .build(), + .buildOrThrow(), values("msg", "z"))))); } @@ -490,7 +490,7 @@ public void testPushdownDereferenceThroughRowNumber() ImmutableMap.builder() .put("msg1_x", PlanMatchPattern.expression("msg1[1]")) .put("msg2_x", PlanMatchPattern.expression("expr")) - .build(), + .buildOrThrow(), rowNumber( pattern -> pattern .partitionBy(ImmutableList.of("msg1")), @@ -499,7 +499,7 @@ public void testPushdownDereferenceThroughRowNumber() .put("expr", PlanMatchPattern.expression("msg2[1]")) .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) - .build(), + .buildOrThrow(), values("msg1", "msg2"))))); } @@ -531,7 +531,7 @@ public void testPushdownDereferenceThroughTopNRanking() .put("msg1_x", PlanMatchPattern.expression("msg1[1]")) .put("msg2_x", PlanMatchPattern.expression("msg2[1]")) .put("msg3_x", PlanMatchPattern.expression("expr")) - .build(), + .buildOrThrow(), topNRanking( pattern -> pattern.specification(singletonList("msg1"), singletonList("msg2"), ImmutableMap.of("msg2", ASC_NULLS_FIRST)), strictProject( @@ -540,7 +540,7 @@ public void testPushdownDereferenceThroughTopNRanking() .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) .put("msg3", PlanMatchPattern.expression("msg3")) - .build(), + .buildOrThrow(), values("msg1", "msg2", "msg3"))))); } @@ -561,14 +561,14 @@ public void testPushdownDereferenceThroughTopN() ImmutableMap.builder() .put("msg1_x", PlanMatchPattern.expression("msg1[1]")) .put("msg2_x", PlanMatchPattern.expression("expr")) - .build(), + .buildOrThrow(), topN(5, ImmutableList.of(sort("msg1", ASCENDING, FIRST)), strictProject( ImmutableMap.builder() .put("expr", PlanMatchPattern.expression("msg2[1]")) .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) - .build(), + .buildOrThrow(), values("msg1", "msg2"))))); } @@ -622,7 +622,7 @@ public void testPushdownDereferenceThroughWindow() .put("msg3_x", PlanMatchPattern.expression("msg3[1]")) // not pushed down because the whole column is used in windowNode function .put("msg4_x", PlanMatchPattern.expression("expr")) // pushed down because msg4[1] is being used in the function .put("msg5_x", PlanMatchPattern.expression("expr2")) // pushed down because not referenced in windowNode - .build(), + .buildOrThrow(), window( windowMatcherBuilder -> windowMatcherBuilder .specification(singletonList("msg1"), singletonList("msg2"), ImmutableMap.of("msg2", SortOrder.ASC_NULLS_FIRST)) @@ -636,7 +636,7 @@ public void testPushdownDereferenceThroughWindow() .put("msg5", PlanMatchPattern.expression("msg5")) .put("expr", PlanMatchPattern.expression("msg4[1]")) .put("expr2", PlanMatchPattern.expression("msg5[1]")) - .build(), + .buildOrThrow(), values("msg1", "msg2", "msg3", "msg4", "msg5"))))); } @@ -661,7 +661,7 @@ public void testPushdownDereferenceThroughAssignUniqueId() ImmutableMap.builder() .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg1_x", PlanMatchPattern.expression("msg1[1]")) - .build(), + .buildOrThrow(), values("msg1"))))); } @@ -692,7 +692,7 @@ public void testPushdownDereferenceThroughMarkDistinct() .put("msg1", PlanMatchPattern.expression("msg1")) .put("msg2", PlanMatchPattern.expression("msg2")) .put("expr", PlanMatchPattern.expression("msg1[1]")) - .build(), + .buildOrThrow(), values("msg1", "msg2"))))); } diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushPredicateIntoTableScan.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushPredicateIntoTableScan.java index 55416e83f4ac..b7c2ec5ffc13 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushPredicateIntoTableScan.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushPredicateIntoTableScan.java @@ -189,7 +189,7 @@ public void consumesDeterministicPredicateIfNewDomainIsNarrower() ColumnHandle columnHandle = new TpchColumnHandle("orderstatus", orderStatusType); Map filterConstraint = ImmutableMap.builder() .put("orderstatus", singleValue(orderStatusType, utf8Slice("O"))) - .build(); + .buildOrThrow(); tester().assertThat(pushPredicateIntoTableScan) .on(p -> p.filter(expression("orderstatus = 'O' OR orderstatus = 'F'"), p.tableScan( @@ -299,7 +299,7 @@ public void ruleAddedTableLayoutToFilterTableScan() { Map filterConstraint = ImmutableMap.builder() .put("orderstatus", singleValue(createVarcharType(1), utf8Slice("F"))) - .build(); + .buildOrThrow(); tester().assertThat(pushPredicateIntoTableScan) .on(p -> p.filter(expression("orderstatus = 'F'"), p.tableScan( diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestSingleDistinctAggregationToGroupBy.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestSingleDistinctAggregationToGroupBy.java index cdca8ff5d703..2258ae636ea5 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestSingleDistinctAggregationToGroupBy.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestSingleDistinctAggregationToGroupBy.java @@ -141,7 +141,7 @@ public void testMultipleAggregations() ImmutableMap., ExpectedValueProvider>builder() .put(Optional.of("output1"), functionCall("count", ImmutableList.of("input"))) .put(Optional.of("output2"), functionCall("sum", ImmutableList.of("input"))) - .build(), + .buildOrThrow(), Optional.empty(), SINGLE, aggregation( @@ -168,7 +168,7 @@ public void testMultipleInputs() ImmutableMap., ExpectedValueProvider>builder() .put(Optional.of("output1"), functionCall("corr", ImmutableList.of("x", "y"))) .put(Optional.of("output2"), functionCall("corr", ImmutableList.of("y", "x"))) - .build(), + .buildOrThrow(), Optional.empty(), SINGLE, aggregation( diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestUnwrapSingleColumnRowInApply.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestUnwrapSingleColumnRowInApply.java index 54e5677c35ff..d1edef9586f2 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestUnwrapSingleColumnRowInApply.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestUnwrapSingleColumnRowInApply.java @@ -77,18 +77,18 @@ public void testUnwrapInPredicate() ImmutableMap.builder() .put("unwrapped", expression("unwrappedValue IN (unwrappedElement)")) .put("notUnwrapped", expression("nonRowValue IN (nonRowElement)")) - .build(), + .buildOrThrow(), project( ImmutableMap.builder() .put("unwrappedValue", expression("rowValue[1]")) .put("nonRowValue", expression("nonRowValue")) - .build(), + .buildOrThrow(), values("rowValue", "nonRowValue")), project( ImmutableMap.builder() .put("unwrappedElement", expression("rowElement[1]")) .put("nonRowElement", expression("nonRowElement")) - .build(), + .buildOrThrow(), values("rowElement", "nonRowElement"))))); } @@ -115,18 +115,18 @@ public void testUnwrapQuantifiedComparison() ImmutableMap.builder() .put("unwrapped", expression(new QuantifiedComparisonExpression(EQUAL, ALL, new SymbolReference("unwrappedValue"), new SymbolReference("unwrappedElement")))) .put("notUnwrapped", expression(new QuantifiedComparisonExpression(EQUAL, ALL, new SymbolReference("nonRowValue"), new SymbolReference("nonRowElement")))) - .build(), + .buildOrThrow(), project( ImmutableMap.builder() .put("unwrappedValue", expression("rowValue[1]")) .put("nonRowValue", expression("nonRowValue")) - .build(), + .buildOrThrow(), values("rowValue", "nonRowValue")), project( ImmutableMap.builder() .put("unwrappedElement", expression("rowElement[1]")) .put("nonRowElement", expression("nonRowElement")) - .build(), + .buildOrThrow(), values("rowElement", "nonRowElement"))))); } } diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PatternRecognitionBuilder.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PatternRecognitionBuilder.java index e1726585a64c..4138f426e1e7 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PatternRecognitionBuilder.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PatternRecognitionBuilder.java @@ -170,7 +170,7 @@ public PatternRecognitionNode build(PlanNodeIdAllocator idAllocator) initial, pattern, subsets, - variableDefinitions.build()); + variableDefinitions.buildOrThrow()); } private Measure measure(Map.Entry entry) diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestExpressionEquivalence.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestExpressionEquivalence.java index 4e2506086b78..8791ab1bd9d9 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestExpressionEquivalence.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestExpressionEquivalence.java @@ -64,7 +64,7 @@ public class TestExpressionEquivalence .put(new Symbol("c_bigint"), BIGINT) .put(new Symbol("d_bigint"), BIGINT) .put(new Symbol("b_double"), DOUBLE) - .build()); + .buildOrThrow()); @Test public void testEquivalent() diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestMergeWindows.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestMergeWindows.java index 6385125ca28b..faf57d3657d2 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestMergeWindows.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestMergeWindows.java @@ -455,7 +455,7 @@ public void testNotMergeAcrossJoinBranches() leftTableScanBuilder.put(QUANTITY_ALIAS, "quantity"); leftTableScanBuilder.put(SHIPDATE_ALIAS, "shipdate"); - PlanMatchPattern leftTableScan = tableScan("lineitem", leftTableScanBuilder.build()); + PlanMatchPattern leftTableScan = tableScan("lineitem", leftTableScanBuilder.buildOrThrow()); PlanMatchPattern rightTableScan = tableScan( "lineitem", diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestReorderWindows.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestReorderWindows.java index 6dd5ba718b2d..558388e2a0a1 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestReorderWindows.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestReorderWindows.java @@ -79,7 +79,7 @@ public class TestReorderWindows columns.put(SHIPDATE_ALIAS, "shipdate"); columns.put(SUPPKEY_ALIAS, "suppkey"); columns.put(TAX_ALIAS, "tax"); - LINEITEM_TABLESCAN_DOQPRSST = tableScan("lineitem", columns.build()); + LINEITEM_TABLESCAN_DOQPRSST = tableScan("lineitem", columns.buildOrThrow()); columns = ImmutableMap.builder(); columns.put(DISCOUNT_ALIAS, "discount"); @@ -88,7 +88,7 @@ public class TestReorderWindows columns.put(RECEIPTDATE_ALIAS, "receiptdate"); columns.put(SUPPKEY_ALIAS, "suppkey"); columns.put(TAX_ALIAS, "tax"); - LINEITEM_TABLESCAN_DOQRST = tableScan("lineitem", columns.build()); + LINEITEM_TABLESCAN_DOQRST = tableScan("lineitem", columns.buildOrThrow()); commonFrame = Optional.empty(); diff --git a/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java b/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java index 3fcf6c28fa68..ed34d35d9425 100644 --- a/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java +++ b/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java @@ -86,7 +86,7 @@ public void init() MockConnectorFactory mock = MockConnectorFactory.builder() .withGetViews((s, prefix) -> ImmutableMap.builder() .put(new SchemaTableName("default", "nation_view"), view) - .build()) + .buildOrThrow()) .withGetColumns(schemaTableName -> { if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) { return TPCH_NATION_SCHEMA; diff --git a/core/trino-main/src/test/java/io/trino/transaction/TestTransactionManagerConfig.java b/core/trino-main/src/test/java/io/trino/transaction/TestTransactionManagerConfig.java index 24a1bd044dd4..e0836a5885b0 100644 --- a/core/trino-main/src/test/java/io/trino/transaction/TestTransactionManagerConfig.java +++ b/core/trino-main/src/test/java/io/trino/transaction/TestTransactionManagerConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() .put("transaction.idle-check-interval", "1s") .put("transaction.idle-timeout", "10s") .put("transaction.max-finishing-concurrency", "100") - .build(); + .buildOrThrow(); TransactionManagerConfig expected = new TransactionManagerConfig() .setIdleCheckInterval(new Duration(1, TimeUnit.SECONDS)) diff --git a/core/trino-main/src/test/java/io/trino/type/TestMapOperators.java b/core/trino-main/src/test/java/io/trino/type/TestMapOperators.java index 47fe57a07a5f..bb2b6b4e22a4 100644 --- a/core/trino-main/src/test/java/io/trino/type/TestMapOperators.java +++ b/core/trino-main/src/test/java/io/trino/type/TestMapOperators.java @@ -387,7 +387,7 @@ public void testJsonToMap() .put("k6", "null") .put("k7", "\"null\"") .put("k8", "[null]") - .build()); + .buildOrThrow()); // These two tests verifies that partial json cast preserves input order // The second test should never happen in real life because valid json in Trino requires natural key ordering. diff --git a/core/trino-spi/src/test/java/io/trino/spi/predicate/TestTupleDomain.java b/core/trino-spi/src/test/java/io/trino/spi/predicate/TestTupleDomain.java index 16a9c11c20c9..238f83929f46 100644 --- a/core/trino-spi/src/test/java/io/trino/spi/predicate/TestTupleDomain.java +++ b/core/trino-spi/src/test/java/io/trino/spi/predicate/TestTupleDomain.java @@ -92,7 +92,7 @@ public void testIntersection() .put(B, Domain.notNull(DOUBLE)) .put(C, Domain.singleValue(BIGINT, 1L)) .put(D, Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(DOUBLE, 0.0)), true)) - .build()); + .buildOrThrow()); TupleDomain tupleDomain2 = TupleDomain.withColumnDomains( ImmutableMap.builder() @@ -100,7 +100,7 @@ public void testIntersection() .put(B, Domain.singleValue(DOUBLE, 0.0)) .put(C, Domain.singleValue(BIGINT, 1L)) .put(D, Domain.create(ValueSet.ofRanges(Range.lessThan(DOUBLE, 10.0)), false)) - .build()); + .buildOrThrow()); TupleDomain expectedTupleDomain = TupleDomain.withColumnDomains( ImmutableMap.builder() @@ -108,7 +108,7 @@ public void testIntersection() .put(B, Domain.singleValue(DOUBLE, 0.0)) .put(C, Domain.singleValue(BIGINT, 1L)) .put(D, Domain.create(ValueSet.ofRanges(Range.range(DOUBLE, 0.0, true, 10.0, false)), false)) - .build()); + .buildOrThrow()); assertEquals(tupleDomain1.intersect(tupleDomain2), expectedTupleDomain); assertEquals(tupleDomain2.intersect(tupleDomain1), expectedTupleDomain); @@ -157,7 +157,7 @@ public void testColumnWiseUnion() .put(C, Domain.onlyNull(BIGINT)) .put(D, Domain.singleValue(BIGINT, 1L)) .put(E, Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(DOUBLE, 0.0)), true)) - .build()); + .buildOrThrow()); TupleDomain tupleDomain2 = TupleDomain.withColumnDomains( ImmutableMap.builder() @@ -166,7 +166,7 @@ public void testColumnWiseUnion() .put(C, Domain.notNull(BIGINT)) .put(D, Domain.singleValue(BIGINT, 1L)) .put(E, Domain.create(ValueSet.ofRanges(Range.lessThan(DOUBLE, 10.0)), false)) - .build()); + .buildOrThrow()); TupleDomain expectedTupleDomain = TupleDomain.withColumnDomains( ImmutableMap.builder() @@ -175,7 +175,7 @@ public void testColumnWiseUnion() .put(C, Domain.all(BIGINT)) .put(D, Domain.singleValue(BIGINT, 1L)) .put(E, Domain.all(DOUBLE)) - .build()); + .buildOrThrow()); assertEquals(columnWiseUnion(tupleDomain1, tupleDomain2), expectedTupleDomain); } @@ -586,7 +586,7 @@ public void testExtractFixedValues() .put(B, Domain.singleValue(VARCHAR, utf8Slice("value"))) .put(C, Domain.onlyNull(BIGINT)) .put(D, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L)), true)) - .build())).get(), + .buildOrThrow())).get(), ImmutableMap.of( B, NullableValue.of(VARCHAR, utf8Slice("value")), C, NullableValue.asNull(BIGINT))); @@ -614,13 +614,13 @@ public void testSingleValuesMapToDomain() .put(B, NullableValue.of(VARCHAR, utf8Slice("value"))) .put(C, NullableValue.of(DOUBLE, 0.01)) .put(D, NullableValue.asNull(BOOLEAN)) - .build()), + .buildOrThrow()), TupleDomain.withColumnDomains(ImmutableMap.builder() .put(A, Domain.singleValue(BIGINT, 1L)) .put(B, Domain.singleValue(VARCHAR, utf8Slice("value"))) .put(C, Domain.singleValue(DOUBLE, 0.01)) .put(D, Domain.onlyNull(BOOLEAN)) - .build())); + .buildOrThrow())); } @Test @@ -668,7 +668,7 @@ public void testTransformKeys() .put(1, Domain.singleValue(BIGINT, 1L)) .put(2, Domain.singleValue(BIGINT, 2L)) .put(3, Domain.singleValue(BIGINT, 3L)) - .build(); + .buildOrThrow(); TupleDomain domain = TupleDomain.withColumnDomains(domains); TupleDomain transformed = domain.transformKeys(Object::toString); @@ -677,7 +677,7 @@ public void testTransformKeys() .put("1", Domain.singleValue(BIGINT, 1L)) .put("2", Domain.singleValue(BIGINT, 2L)) .put("3", Domain.singleValue(BIGINT, 3L)) - .build(); + .buildOrThrow(); assertEquals(transformed.getDomains().get(), expected); } @@ -689,7 +689,7 @@ public void testTransformKeysFailsWithNonUniqueMapping() .put(1, Domain.singleValue(BIGINT, 1L)) .put(2, Domain.singleValue(BIGINT, 2L)) .put(3, Domain.singleValue(BIGINT, 3L)) - .build(); + .buildOrThrow(); TupleDomain domain = TupleDomain.withColumnDomains(domains); @@ -714,7 +714,7 @@ public void testTransformKeysRejectsNull() .put(1, Domain.singleValue(BIGINT, 1L)) .put(2, Domain.singleValue(BIGINT, 2L)) .put(3, Domain.singleValue(BIGINT, 3L)) - .build(); + .buildOrThrow(); TupleDomain domain = TupleDomain.withColumnDomains(domains); diff --git a/lib/trino-geospatial-toolkit/src/main/java/io/trino/geospatial/KdbTree.java b/lib/trino-geospatial-toolkit/src/main/java/io/trino/geospatial/KdbTree.java index 2fbf2717f327..ba29024981db 100644 --- a/lib/trino-geospatial-toolkit/src/main/java/io/trino/geospatial/KdbTree.java +++ b/lib/trino-geospatial-toolkit/src/main/java/io/trino/geospatial/KdbTree.java @@ -167,14 +167,14 @@ public Map getLeaves() { ImmutableMap.Builder leaves = ImmutableMap.builder(); addLeaves(root, leaves, node -> true); - return leaves.build(); + return leaves.buildOrThrow(); } public Map findIntersectingLeaves(Rectangle envelope) { ImmutableMap.Builder leaves = ImmutableMap.builder(); addLeaves(root, leaves, node -> node.extent.intersects(envelope)); - return leaves.build(); + return leaves.buildOrThrow(); } private static void addLeaves(Node node, ImmutableMap.Builder leaves, Predicate predicate) diff --git a/lib/trino-orc/src/main/java/io/trino/orc/AbstractOrcDataSource.java b/lib/trino-orc/src/main/java/io/trino/orc/AbstractOrcDataSource.java index 5b2ad06a3d6d..19fb5ed24696 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/AbstractOrcDataSource.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/AbstractOrcDataSource.java @@ -150,15 +150,15 @@ public final Map readFully(Map diskRanges) largeRangesBuilder.put(entry); } } - Map smallRanges = smallRangesBuilder.build(); - Map largeRanges = largeRangesBuilder.build(); + Map smallRanges = smallRangesBuilder.buildOrThrow(); + Map largeRanges = largeRangesBuilder.buildOrThrow(); // read ranges ImmutableMap.Builder slices = ImmutableMap.builder(); slices.putAll(readSmallDiskRanges(smallRanges)); slices.putAll(readLargeDiskRanges(largeRanges)); - return slices.build(); + return slices.buildOrThrow(); } private Map readSmallDiskRanges(Map diskRanges) @@ -195,7 +195,7 @@ private Map readSmallDiskRanges(Map diskRang } } - Map sliceStreams = slices.build(); + Map sliceStreams = slices.buildOrThrow(); verify(sliceStreams.keySet().equals(diskRanges.keySet())); return sliceStreams; } @@ -211,7 +211,7 @@ private Map readLargeDiskRanges(Map diskRang DiskRange diskRange = entry.getValue(); slices.put(entry.getKey(), new DiskOrcDataReader(diskRange)); } - return slices.build(); + return slices.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/CachingOrcDataSource.java b/lib/trino-orc/src/main/java/io/trino/orc/CachingOrcDataSource.java index 8c2f37722f78..97cda0bc3889 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/CachingOrcDataSource.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/CachingOrcDataSource.java @@ -123,7 +123,7 @@ public Map readFully(Map diskRanges) Slice buffer = readFully(diskRange.getOffset(), diskRange.getLength()); builder.put(entry.getKey(), new MemoryOrcDataReader(dataSource.getId(), buffer, buffer.length())); } - return builder.build(); + return builder.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/MemoryOrcDataSource.java b/lib/trino-orc/src/main/java/io/trino/orc/MemoryOrcDataSource.java index 4bac836d32e7..a7128eea0c83 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/MemoryOrcDataSource.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/MemoryOrcDataSource.java @@ -97,7 +97,7 @@ public final Map readFully(Map diskRanges) slices.put(entry.getKey(), new MemoryOrcDataReader(id, slice, 0)); } - return slices.build(); + return slices.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/OrcReader.java b/lib/trino-orc/src/main/java/io/trino/orc/OrcReader.java index 63bc27db0cee..d8a592e055dd 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/OrcReader.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/OrcReader.java @@ -485,7 +485,7 @@ public static ProjectedLayout createProjectedLayout(OrcColumn root, List diskRanges = diskRangesBuilder.build(); + ImmutableMap diskRanges = diskRangesBuilder.buildOrThrow(); // read the file regions Map streamsData = readDiskRanges(stripe.getOffset(), diskRanges, systemMemoryUsage); @@ -229,7 +229,7 @@ public Stripe readStripe(StripeInformation stripe, AggregatedMemoryContext syste for (Entry> entry : valueStreams.entrySet()) { builder.put(entry.getKey(), new ValueInputStreamSource<>(entry.getValue())); } - RowGroup rowGroup = new RowGroup(0, 0, stripe.getNumberOfRows(), minAverageRowBytes, new InputStreamSources(builder.build())); + RowGroup rowGroup = new RowGroup(0, 0, stripe.getNumberOfRows(), minAverageRowBytes, new InputStreamSources(builder.buildOrThrow())); return new Stripe(stripe.getNumberOfRows(), fileTimeZone, columnEncodings, ImmutableList.of(rowGroup), dictionaryStreamSources); } @@ -271,7 +271,7 @@ private Map readDiskRanges(long stripeOffset, Map streamsData = orcDataSource.readFully(diskRanges); @@ -281,7 +281,7 @@ private Map readDiskRanges(long stripeOffset, Map entry : streamsData.entrySet()) { dataBuilder.put(entry.getKey(), OrcChunkLoader.create(entry.getValue(), decompressor, systemMemoryUsage)); } - return dataBuilder.build(); + return dataBuilder.buildOrThrow(); } private Map> createValueStreams(Map streams, Map streamsData, ColumnMetadata columnEncodings) @@ -302,7 +302,7 @@ private Map> createValueStreams(Map streams, Map> valueStreams, ColumnMetadata columnEncodings) @@ -331,7 +331,7 @@ private InputStreamSources createDictionaryStreamSources(Map s InputStreamSource streamSource = createCheckpointStreamSource(valueStream, streamCheckpoint); dictionaryStreamBuilder.put(streamId, streamSource); } - return new InputStreamSources(dictionaryStreamBuilder.build()); + return new InputStreamSources(dictionaryStreamBuilder.buildOrThrow()); } private List createRowGroups( @@ -379,7 +379,7 @@ private static RowGroup createRowGroup(int groupId, int rowOffset, int rowCount, builder.put(streamId, createCheckpointStreamSource(valueStream, checkpoint)); } - InputStreamSources rowGroupStreams = new InputStreamSources(builder.build()); + InputStreamSources rowGroupStreams = new InputStreamSources(builder.buildOrThrow()); return new RowGroup(groupId, rowOffset, rowCount, minAverageRowBytes, rowGroupStreams); } @@ -445,7 +445,7 @@ private Map> readColumnIndexes(Map selectRowGroups(StripeInformation stripe, Map> columnIndexes) @@ -506,7 +506,7 @@ private static Map getDiskRanges(List streams) } stripeOffset += streamLength; } - return streamDiskRanges.build(); + return streamDiskRanges.buildOrThrow(); } private static Set getIncludeColumns(Set includedColumns) diff --git a/lib/trino-orc/src/main/java/io/trino/orc/checkpoint/Checkpoints.java b/lib/trino-orc/src/main/java/io/trino/orc/checkpoint/Checkpoints.java index 88c13b66fae1..c7f932eb94e9 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/checkpoint/Checkpoints.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/checkpoint/Checkpoints.java @@ -122,7 +122,7 @@ public static Map getStreamCheckpoints( throw new IllegalArgumentException("Unsupported column type " + columnType); } } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } public static StreamCheckpoint getDictionaryStreamCheckpoint(StreamId streamId, OrcTypeKind columnType, ColumnEncodingKind columnEncoding) @@ -167,7 +167,7 @@ private static Map getBooleanColumnCheckpoints( checkpoints.put(new StreamId(columnId, DATA), new BooleanStreamCheckpoint(compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getByteColumnCheckpoints( @@ -186,7 +186,7 @@ private static Map getByteColumnCheckpoints( checkpoints.put(new StreamId(columnId, DATA), new ByteStreamCheckpoint(compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getLongColumnCheckpoints( @@ -206,7 +206,7 @@ private static Map getLongColumnCheckpoints( checkpoints.put(new StreamId(columnId, DATA), createLongStreamCheckpoint(encoding, compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getFloatColumnCheckpoints( @@ -225,7 +225,7 @@ private static Map getFloatColumnCheckpoints( checkpoints.put(new StreamId(columnId, DATA), new FloatStreamCheckpoint(compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getDoubleColumnCheckpoints( @@ -244,7 +244,7 @@ private static Map getDoubleColumnCheckpoints( checkpoints.put(new StreamId(columnId, DATA), new DoubleStreamCheckpoint(compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getTimestampColumnCheckpoints( @@ -268,7 +268,7 @@ private static Map getTimestampColumnCheckpoints( checkpoints.put(new StreamId(columnId, SECONDARY), createLongStreamCheckpoint(encoding, compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getSliceColumnCheckpoints( @@ -302,7 +302,7 @@ else if (encoding == DICTIONARY || encoding == DICTIONARY_V2) { throw new IllegalArgumentException("Unsupported encoding for slice column: " + encoding); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getListOrMapColumnCheckpoints( @@ -322,7 +322,7 @@ private static Map getListOrMapColumnCheckpoints( checkpoints.put(new StreamId(columnId, LENGTH), createLongStreamCheckpoint(encoding, compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getStructColumnCheckpoints( @@ -337,7 +337,7 @@ private static Map getStructColumnCheckpoints( checkpoints.put(new StreamId(columnId, PRESENT), new BooleanStreamCheckpoint(compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static Map getDecimalColumnCheckpoints( @@ -361,7 +361,7 @@ private static Map getDecimalColumnCheckpoints( checkpoints.put(new StreamId(columnId, SECONDARY), createLongStreamCheckpoint(encoding, compressed, positionsList)); } - return checkpoints.build(); + return checkpoints.buildOrThrow(); } private static StreamCheckpoint createLongStreamCheckpoint(ColumnEncodingKind encoding, boolean compressed, ColumnPositionsList positionsList) diff --git a/lib/trino-orc/src/main/java/io/trino/orc/metadata/OrcMetadataReader.java b/lib/trino-orc/src/main/java/io/trino/orc/metadata/OrcMetadataReader.java index 9b410a3be27d..46fd6b0215b3 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/metadata/OrcMetadataReader.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/metadata/OrcMetadataReader.java @@ -327,7 +327,7 @@ private static Map toUserMetadata(List for (OrcProto.UserMetadataItem item : metadataList) { mapBuilder.put(item.getName(), byteStringToSlice(item.getValue())); } - return mapBuilder.build(); + return mapBuilder.buildOrThrow(); } private static BooleanStatistics toBooleanStatistics(OrcProto.BucketStatistics bucketStatistics) @@ -593,7 +593,7 @@ private static Map toMap(List attributes) } } } - return results.build(); + return results.buildOrThrow(); } private static StreamKind toStreamKind(OrcProto.Stream.Kind streamKind) diff --git a/lib/trino-orc/src/main/java/io/trino/orc/reader/StructColumnReader.java b/lib/trino-orc/src/main/java/io/trino/orc/reader/StructColumnReader.java index a560cc4a7e5a..106dcb00eebe 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/reader/StructColumnReader.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/reader/StructColumnReader.java @@ -119,7 +119,7 @@ public class StructColumnReader } } this.fieldNames = fieldNames.build(); - this.structFields = structFields.build(); + this.structFields = structFields.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/writer/ListColumnWriter.java b/lib/trino-orc/src/main/java/io/trino/orc/writer/ListColumnWriter.java index 24e9e57c2ec2..30e3674a2f02 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/writer/ListColumnWriter.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/writer/ListColumnWriter.java @@ -89,7 +89,7 @@ public Map getColumnEncodings() ImmutableMap.Builder encodings = ImmutableMap.builder(); encodings.put(columnId, columnEncoding); encodings.putAll(elementWriter.getColumnEncodings()); - return encodings.build(); + return encodings.buildOrThrow(); } @Override @@ -142,7 +142,7 @@ public Map finishRowGroup() ImmutableMap.Builder columnStatistics = ImmutableMap.builder(); columnStatistics.put(columnId, statistics); columnStatistics.putAll(elementWriter.finishRowGroup()); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override @@ -161,7 +161,7 @@ public Map getColumnStripeStatistics() ImmutableMap.Builder columnStatistics = ImmutableMap.builder(); columnStatistics.put(columnId, ColumnStatistics.mergeColumnStatistics(rowGroupColumnStatistics)); columnStatistics.putAll(elementWriter.getColumnStripeStatistics()); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/writer/MapColumnWriter.java b/lib/trino-orc/src/main/java/io/trino/orc/writer/MapColumnWriter.java index 6a09cce5f304..e9aab3ce0017 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/writer/MapColumnWriter.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/writer/MapColumnWriter.java @@ -94,7 +94,7 @@ public Map getColumnEncodings() encodings.put(columnId, columnEncoding); encodings.putAll(keyWriter.getColumnEncodings()); encodings.putAll(valueWriter.getColumnEncodings()); - return encodings.build(); + return encodings.buildOrThrow(); } @Override @@ -150,7 +150,7 @@ public Map finishRowGroup() columnStatistics.put(columnId, statistics); columnStatistics.putAll(keyWriter.finishRowGroup()); columnStatistics.putAll(valueWriter.finishRowGroup()); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override @@ -171,7 +171,7 @@ public Map getColumnStripeStatistics() columnStatistics.put(columnId, ColumnStatistics.mergeColumnStatistics(rowGroupColumnStatistics)); columnStatistics.putAll(keyWriter.getColumnStripeStatistics()); columnStatistics.putAll(valueWriter.getColumnStripeStatistics()); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/main/java/io/trino/orc/writer/StructColumnWriter.java b/lib/trino-orc/src/main/java/io/trino/orc/writer/StructColumnWriter.java index ad2a6e63ef91..9ccb323499f2 100644 --- a/lib/trino-orc/src/main/java/io/trino/orc/writer/StructColumnWriter.java +++ b/lib/trino-orc/src/main/java/io/trino/orc/writer/StructColumnWriter.java @@ -89,7 +89,7 @@ public Map getColumnEncodings() structFields.stream() .map(ColumnWriter::getColumnEncodings) .forEach(encodings::putAll); - return encodings.build(); + return encodings.buildOrThrow(); } @Override @@ -144,7 +144,7 @@ public Map finishRowGroup() structFields.stream() .map(ColumnWriter::finishRowGroup) .forEach(columnStatistics::putAll); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override @@ -164,7 +164,7 @@ public Map getColumnStripeStatistics() structFields.stream() .map(ColumnWriter::getColumnStripeStatistics) .forEach(columnStatistics::putAll); - return columnStatistics.build(); + return columnStatistics.buildOrThrow(); } @Override diff --git a/lib/trino-orc/src/test/java/io/trino/orc/AbstractTestOrcReader.java b/lib/trino-orc/src/test/java/io/trino/orc/AbstractTestOrcReader.java index 184c0ad5c376..3fac1e7ef68a 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/AbstractTestOrcReader.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/AbstractTestOrcReader.java @@ -308,7 +308,7 @@ public void testTimestampMillis() .put("1970-01-14 00:04:16.789", SqlTimestamp.fromMillis(3, 1123456789L)) .put("2001-09-10 12:04:16.789", SqlTimestamp.fromMillis(3, 1000123456789L)) .put("2019-12-05 13:41:39.564", SqlTimestamp.fromMillis(3, 1575553299564L)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_MILLIS, newArrayList(limit(cycle(map.values()), 30_000))); } @@ -325,7 +325,7 @@ public void testTimestampMicros() .put("1970-01-14 00:04:16.789123", SqlTimestamp.newInstance(6, 1123456789123L, 0)) .put("2001-09-10 12:04:16.789123", SqlTimestamp.newInstance(6, 1000123456789123L, 0)) .put("2019-12-05 13:41:39.564321", SqlTimestamp.newInstance(6, 1575553299564321L, 0)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_MICROS, newArrayList(limit(cycle(map.values()), 30_000))); } @@ -342,7 +342,7 @@ public void testTimestampNanos() .put("1970-01-14 00:04:16.789123456", SqlTimestamp.newInstance(9, 1123456789123L, 456_000)) .put("2001-09-10 12:04:16.789123456", SqlTimestamp.newInstance(9, 1000123456789123L, 456_000)) .put("2019-12-05 13:41:39.564321789", SqlTimestamp.newInstance(9, 1575553299564321L, 789_000)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_NANOS, newArrayList(limit(cycle(map.values()), 30_000))); } @@ -359,7 +359,7 @@ public void testInstantMillis() .put("1970-01-14 00:04:16.789 UTC", SqlTimestampWithTimeZone.newInstance(3, 1123456789L, 0, UTC_KEY)) .put("2001-09-10 12:04:16.789 UTC", SqlTimestampWithTimeZone.newInstance(3, 1000123456789L, 0, UTC_KEY)) .put("2019-12-05 13:41:39.564 UTC", SqlTimestampWithTimeZone.newInstance(3, 1575553299564L, 0, UTC_KEY)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_TZ_MILLIS, newArrayList(limit(cycle(map.values()), 30_000))); } @@ -376,7 +376,7 @@ public void testInstantMicros() .put("1970-01-14 00:04:16.789123 UTC", SqlTimestampWithTimeZone.newInstance(6, 1123456789L, 123_000_000, UTC_KEY)) .put("2001-09-10 12:04:16.789123 UTC", SqlTimestampWithTimeZone.newInstance(6, 1000123456789L, 123_000_000, UTC_KEY)) .put("2019-12-05 13:41:39.564321 UTC", SqlTimestampWithTimeZone.newInstance(6, 1575553299564L, 321_000_000, UTC_KEY)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_TZ_MICROS, newArrayList(limit(cycle(map.values()), 30_000))); } @@ -393,7 +393,7 @@ public void testInstantNanos() .put("1970-01-14 00:04:16.789123456 UTC", SqlTimestampWithTimeZone.newInstance(9, 1123456789L, 123_456_000, UTC_KEY)) .put("2001-09-10 12:04:16.789123456 UTC", SqlTimestampWithTimeZone.newInstance(9, 1000123456789L, 123_456_000, UTC_KEY)) .put("2019-12-05 13:41:39.564321789 UTC", SqlTimestampWithTimeZone.newInstance(9, 1575553299564L, 321_789_000, UTC_KEY)) - .build(); + .buildOrThrow(); map.forEach((expected, value) -> assertEquals(value.toString(), expected)); tester.testRoundTrip(TIMESTAMP_TZ_NANOS, newArrayList(limit(cycle(map.values()), 30_000))); } diff --git a/lib/trino-orc/src/test/java/io/trino/orc/TestOrcBloomFilters.java b/lib/trino-orc/src/test/java/io/trino/orc/TestOrcBloomFilters.java index b6dc072e4b88..45df00c938a2 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/TestOrcBloomFilters.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/TestOrcBloomFilters.java @@ -81,7 +81,7 @@ public class TestOrcBloomFilters .put(987654L, TIMESTAMP_MILLIS) .put(234.567, DOUBLE) .put((long) floatToIntBits(987.654f), REAL) - .build(); + .buildOrThrow(); @Test public void testHiveBloomFilterSerde() diff --git a/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/PredicateUtils.java b/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/PredicateUtils.java index 26c131b5ffa8..973c449a7b94 100644 --- a/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/PredicateUtils.java +++ b/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/PredicateUtils.java @@ -156,7 +156,7 @@ private static Map> getStatistics(BlockMetaData } } } - return statistics.build(); + return statistics.buildOrThrow(); } private static boolean dictionaryPredicatesMatch(Predicate parquetPredicate, BlockMetaData blockMetadata, ParquetDataSource dataSource, Map, RichColumnDescriptor> descriptorsByPath, TupleDomain parquetTupleDomain) diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/authentication/KerberosAuthentication.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/authentication/KerberosAuthentication.java index ff5721ddffed..75e5dd71c47f 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/authentication/KerberosAuthentication.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/authentication/KerberosAuthentication.java @@ -97,7 +97,7 @@ private static Configuration createConfiguration(String principal, String keytab optionsBuilder.put("debug", "true"); } - Map options = optionsBuilder.build(); + Map options = optionsBuilder.buildOrThrow(); return new Configuration() { diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/jmx/ConnectorObjectNameGeneratorModule.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/jmx/ConnectorObjectNameGeneratorModule.java index f38564cad5fc..f98e61946c8b 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/jmx/ConnectorObjectNameGeneratorModule.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/jmx/ConnectorObjectNameGeneratorModule.java @@ -74,7 +74,7 @@ public String generatedNameOf(Class type) .withProperties(ImmutableMap.builder() .put("type", type.getSimpleName()) .put("name", catalogName) - .build()) + .buildOrThrow()) .build(); } @@ -85,7 +85,7 @@ public String generatedNameOf(Class type, Map properties) .withProperties(ImmutableMap.builder() .putAll(properties) .put("catalog", catalogName) - .build()) + .buildOrThrow()) .build(); } diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/LoggingInvocationHandler.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/LoggingInvocationHandler.java index f5e96f3fe9fa..9a767cea8c88 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/LoggingInvocationHandler.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/util/LoggingInvocationHandler.java @@ -131,7 +131,7 @@ public AirliftParameterNamesProvider(Class interfaceClass, C .map(ImmutableList::copyOf) .ifPresent(names -> parameterNames.put(interfaceMethod, names)); } - this.parameterNames = parameterNames.build(); + this.parameterNames = parameterNames.buildOrThrow(); } private static Optional> tryGetParameterNamesForMethod(Method interfaceMethod, Class implementationClass) diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControlConfig.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControlConfig.java index 972b9d0808ab..418fac2a7453 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControlConfig.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControlConfig.java @@ -51,7 +51,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put(SECURITY_CONFIG_FILE, securityConfigFile.toString()) .put(SECURITY_REFRESH_PERIOD, "1s") - .build(); + .buildOrThrow(); FileBasedAccessControlConfig expected = new FileBasedAccessControlConfig() .setConfigFile(securityConfigFile.toString()) diff --git a/lib/trino-rcfile/src/main/java/io/trino/rcfile/RcFileReader.java b/lib/trino-rcfile/src/main/java/io/trino/rcfile/RcFileReader.java index 43733760e6f5..65ad85861341 100644 --- a/lib/trino-rcfile/src/main/java/io/trino/rcfile/RcFileReader.java +++ b/lib/trino-rcfile/src/main/java/io/trino/rcfile/RcFileReader.java @@ -195,7 +195,7 @@ else if (SEQUENCE_FILE_MAGIC.equals(magic)) { for (int i = 0; i < metadataEntries; i++) { metadataBuilder.put(readLengthPrefixedString(input).toStringUtf8(), readLengthPrefixedString(input).toStringUtf8()); } - metadata = metadataBuilder.build(); + metadata = metadataBuilder.buildOrThrow(); validateWrite(validation -> validation.getMetadata().equals(metadata), "Unexpected metadata"); // get column count from metadata @@ -523,7 +523,7 @@ static void validateFile( try (RcFileReader rcFileReader = new RcFileReader( input, encoding, - readTypes.build(), + readTypes.buildOrThrow(), codecFactory, 0, input.getSize(), diff --git a/lib/trino-rcfile/src/test/java/io/trino/rcfile/RcFileTester.java b/lib/trino-rcfile/src/test/java/io/trino/rcfile/RcFileTester.java index 8c510d43aa11..0883ccb085cc 100644 --- a/lib/trino-rcfile/src/test/java/io/trino/rcfile/RcFileTester.java +++ b/lib/trino-rcfile/src/test/java/io/trino/rcfile/RcFileTester.java @@ -418,7 +418,7 @@ private void assertRoundTrip(Type type, Iterable writeValues, Set ski Map expectedMetadata = ImmutableMap.builder() .putAll(metadata) .put(PRESTO_RCFILE_WRITER_VERSION_METADATA_KEY, PRESTO_RCFILE_WRITER_VERSION) - .build(); + .buildOrThrow(); assertFileContentsNew(type, tempFile, format, finalValues, false, expectedMetadata); @@ -444,7 +444,7 @@ private static void assertFileContentsNew( assertEquals(recordReader.getMetadata(), ImmutableMap.builder() .putAll(metadata) .put("hive.io.rcfile.column.number", "1") - .build()); + .buildOrThrow()); Iterator iterator = expectedValues.iterator(); int totalCount = 0; diff --git a/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java b/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java index 27b2ef116fa2..914fad9a87d0 100644 --- a/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java +++ b/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java @@ -773,7 +773,7 @@ public void testMapOfMaps() Map> data = ImmutableMap.>builder() .put("k1", buildMapFromKeysAndValues(ImmutableList.of("key1", "key2", "key3"), ImmutableList.of(1.3F, 2.3F, -.5F))) .put("k2", buildMapFromKeysAndValues(ImmutableList.of("key10", "key20", "key30"), ImmutableList.of(11.3F, 12.3F, -1.5F))) - .build(); + .buildOrThrow(); DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", MAP_OF_REAL_MAP_TYPE, "map_field", null, null, false, false, false); Map decodedRow = buildAndDecodeColumn(row, "map_field", schema.toString(), data); checkMapValue(decodedRow, row, data); @@ -1036,7 +1036,7 @@ public void testRow() .set("sf1", 4.5D) .set("sf2", false) .build()) - .build()) + .buildOrThrow()) .set("f12", new GenericRecordBuilder(schema.getField("f12").schema()) .set("sf1", 3) .set("sf2", new GenericData.EnumSymbol(schema.getField("f12").schema().getField("sf2").schema(), "running")) @@ -1112,7 +1112,7 @@ public void testRowWithNulls() .set("f10", array) .set("f11", ImmutableMap.builder() .put("key1", new GenericRecordBuilder(schema.getField("f11").schema().getTypes().get(1).getValueType().getTypes().get(1)).build()) - .build()) + .buildOrThrow()) .set("f12", new GenericRecordBuilder(schema.getField("f12").schema().getTypes().get(1)).build()) .build(); decodedRow = buildAndDecodeColumn(row, "record_field", schema.toString(), data); diff --git a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloClient.java b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloClient.java index 5de8d5aa7410..5e4bc730d72e 100644 --- a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloClient.java +++ b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloClient.java @@ -363,7 +363,7 @@ private void setLocalityGroups(Map tableProperties, AccumuloTabl localityGroupsBuilder.put(g.getKey(), familyBuilder.build()); } - Map> localityGroups = localityGroupsBuilder.build(); + Map> localityGroups = localityGroupsBuilder.buildOrThrow(); LOG.debug("Setting locality groups: %s", localityGroups); tableManager.setLocalityGroups(table.getFullTableName(), localityGroups); } diff --git a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloMetadata.java b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloMetadata.java index 9974f0cdd942..22c8c2ab08be 100644 --- a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloMetadata.java +++ b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/AccumuloMetadata.java @@ -275,7 +275,7 @@ public Map getColumnHandles(ConnectorSession session, Conn for (AccumuloColumnHandle column : table.getColumns()) { columnHandles.put(column.getName(), column); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -330,7 +330,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/conf/AccumuloTableProperties.java b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/conf/AccumuloTableProperties.java index ecf1f6ac0a32..92a28f559f45 100644 --- a/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/conf/AccumuloTableProperties.java +++ b/plugin/trino-accumulo/src/main/java/io/trino/plugin/accumulo/conf/AccumuloTableProperties.java @@ -149,7 +149,7 @@ public static Optional>> getColumnMapping( mapping.put(tokens[0], Pair.of(tokens[1], tokens[2])); } - return Optional.of(mapping.build()); + return Optional.of(mapping.buildOrThrow()); } public static Optional> getIndexColumns(Map tableProperties) @@ -203,7 +203,7 @@ public static Optional>> getLocalityGroups(Map getRowId(Map tableProperties) diff --git a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/AccumuloQueryRunner.java b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/AccumuloQueryRunner.java index 5876a3f94646..fc69975717da 100644 --- a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/AccumuloQueryRunner.java +++ b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/AccumuloQueryRunner.java @@ -64,7 +64,7 @@ public static synchronized DistributedQueryRunner createAccumuloQueryRunner(Map< .put(AccumuloConfig.USERNAME, server.getUser()) .put(AccumuloConfig.PASSWORD, server.getPassword()) .put(AccumuloConfig.ZOOKEEPER_METADATA_ROOT, "/presto-accumulo-test") - .build(); + .buildOrThrow(); queryRunner.createCatalog("accumulo", "accumulo", accumuloProperties); diff --git a/plugin/trino-atop/src/main/java/io/trino/plugin/atop/AtopMetadata.java b/plugin/trino-atop/src/main/java/io/trino/plugin/atop/AtopMetadata.java index f118c26065ec..c29736dbcd62 100644 --- a/plugin/trino-atop/src/main/java/io/trino/plugin/atop/AtopMetadata.java +++ b/plugin/trino-atop/src/main/java/io/trino/plugin/atop/AtopMetadata.java @@ -119,7 +119,7 @@ public Map getColumnHandles(ConnectorSession session, Conn for (AtopColumn column : atopTableHandle.getTable().getColumns()) { columnHandles.put(column.getName(), new AtopColumnHandle(column.getName())); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -130,7 +130,7 @@ public Map> listTableColumns(ConnectorSess ConnectorTableMetadata tableMetadata = getTableMetadata(session, getTableHandle(session, tableName)); columns.put(tableName, tableMetadata.getColumns()); } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-atop/src/test/java/io/trino/plugin/atop/LocalAtopQueryRunner.java b/plugin/trino-atop/src/test/java/io/trino/plugin/atop/LocalAtopQueryRunner.java index feaa19a9112c..eda0a0f63d53 100644 --- a/plugin/trino-atop/src/test/java/io/trino/plugin/atop/LocalAtopQueryRunner.java +++ b/plugin/trino-atop/src/test/java/io/trino/plugin/atop/LocalAtopQueryRunner.java @@ -49,7 +49,7 @@ public static LocalQueryRunner createQueryRunner(Map catalogProp .putAll(catalogProperties) .put("atop.max-history-days", "1"); - queryRunner.createCatalog("atop", connectorFactory, properties.build()); + queryRunner.createCatalog("atop", connectorFactory, properties.buildOrThrow()); return queryRunner; } diff --git a/plugin/trino-atop/src/test/java/io/trino/plugin/atop/TestAtopConnectorConfig.java b/plugin/trino-atop/src/test/java/io/trino/plugin/atop/TestAtopConnectorConfig.java index 9fa890ad5b25..74fb29182b7a 100644 --- a/plugin/trino-atop/src/test/java/io/trino/plugin/atop/TestAtopConnectorConfig.java +++ b/plugin/trino-atop/src/test/java/io/trino/plugin/atop/TestAtopConnectorConfig.java @@ -56,7 +56,7 @@ public void testExplicitPropertyMappings() .put("atop.security", "file") .put("atop.max-history-days", "10") .put("atop.time-zone", "PST") - .build(); + .buildOrThrow(); AtopConnectorConfig expected = new AtopConnectorConfig() .setExecutablePath(atopExecutable.toString()) diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java index ef6eb94180c3..d8cd7b525d16 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java @@ -319,7 +319,7 @@ public Optional> applyAggrega handle, Optional.of(groupingSetsAsJdbcColumnHandles), newColumnsList, - expressions.build()); + expressions.buildOrThrow()); handle = new JdbcTableHandle( new JdbcQueryRelationHandle(preparedQuery), TupleDomain.all(), @@ -358,7 +358,7 @@ public Optional> applyJoin( .build()); nextSyntheticColumnId++; } - Map newLeftColumns = newLeftColumnsBuilder.build(); + Map newLeftColumns = newLeftColumnsBuilder.buildOrThrow(); ImmutableMap.Builder newRightColumnsBuilder = ImmutableMap.builder(); for (JdbcColumnHandle column : jdbcClient.getColumns(session, rightHandle)) { @@ -367,7 +367,7 @@ public Optional> applyJoin( .build()); nextSyntheticColumnId++; } - Map newRightColumns = newRightColumnsBuilder.build(); + Map newRightColumns = newRightColumnsBuilder.buildOrThrow(); ImmutableList.Builder jdbcJoinConditions = ImmutableList.builder(); for (JoinCondition joinCondition : joinConditions) { @@ -595,7 +595,7 @@ public Map> listTableColumns(ConnectorSess // these exceptions are ignored because listTableColumns is used for metadata queries (SELECT FROM information_schema) } } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/credential/DefaultCredentialPropertiesProvider.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/credential/DefaultCredentialPropertiesProvider.java index 670193470151..649b36b161e1 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/credential/DefaultCredentialPropertiesProvider.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/credential/DefaultCredentialPropertiesProvider.java @@ -37,6 +37,6 @@ public Map getCredentialProperties(ConnectorIdentity identity) ImmutableMap.Builder properties = ImmutableMap.builder(); provider.getConnectionUser(Optional.of(identity)).ifPresent(user -> properties.put("user", user)); provider.getConnectionPassword(Optional.of(identity)).ifPresent(password -> properties.put("password", password)); - return properties.build(); + return properties.buildOrThrow(); } } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestBaseJdbcConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestBaseJdbcConfig.java index be3352d31be1..309c43849af5 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestBaseJdbcConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestBaseJdbcConfig.java @@ -53,7 +53,7 @@ public void testExplicitPropertyMappings() .put("metadata.cache-ttl", "1s") .put("metadata.cache-missing", "true") .put("metadata.cache-maximum-size", "5000") - .build(); + .buildOrThrow(); BaseJdbcConfig expected = new BaseJdbcConfig() .setConnectionUrl("jdbc:h2:mem:config") diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestCredentialProviderTypeConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestCredentialProviderTypeConfig.java index d7ff15d137a3..6576b182be05 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestCredentialProviderTypeConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestCredentialProviderTypeConfig.java @@ -39,7 +39,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("credential-provider.type", "FILE") - .build(); + .buildOrThrow(); CredentialProviderTypeConfig expected = new CredentialProviderTypeConfig() .setCredentialProviderType(FILE); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestDecimalConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestDecimalConfig.java index e6a1d6ba339f..89032b7f5f2c 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestDecimalConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestDecimalConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("decimal-mapping", "allow_overflow") .put("decimal-default-scale", "16") .put("decimal-rounding-mode", "HALF_UP") - .build(); + .buildOrThrow(); DecimalConfig expected = new DecimalConfig() .setDecimalMapping(ALLOW_OVERFLOW) diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcCachingConnectorSmokeTest.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcCachingConnectorSmokeTest.java index 486184e10801..d8bef803b288 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcCachingConnectorSmokeTest.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcCachingConnectorSmokeTest.java @@ -40,7 +40,7 @@ protected QueryRunner createQueryRunner() .put("metadata.cache-missing", "true") .put("case-insensitive-name-matching", "true") .put("allow-drop-table", "true") - .build(); + .buildOrThrow(); this.h2SqlExecutor = new JdbcSqlExecutor(properties.get("connection-url"), new Properties()); return createH2QueryRunner(REQUIRED_TPCH_TABLES, properties); } 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 6fdd94d87bec..1c95b66c08f3 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 @@ -44,7 +44,7 @@ protected QueryRunner createQueryRunner() properties = ImmutableMap.builder() .putAll(TestingH2JdbcModule.createProperties()) .put("allow-drop-table", "true") - .build(); + .buildOrThrow(); return createH2QueryRunner(REQUIRED_TPCH_TABLES, properties); } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcMetadataConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcMetadataConfig.java index 693136be110d..a2c9140648d9 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcMetadataConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcMetadataConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("aggregation-pushdown.enabled", "false") .put("domain-compaction-threshold", "42") .put("topn-pushdown.enabled", "false") - .build(); + .buildOrThrow(); JdbcMetadataConfig expected = new JdbcMetadataConfig() .setAllowDropTable(true) diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcPlugin.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcPlugin.java index 6932d2fbb469..687315a3dd08 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcPlugin.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcPlugin.java @@ -42,7 +42,7 @@ public void testRuleBasedIdentifierCanBeUsedTogetherWithCacheBased() .putAll(TestingH2JdbcModule.createProperties()) .put(CASE_INSENSITIVE_NAME_MATCHING, "true") .put(CASE_INSENSITIVE_NAME_MATCHING + ".config-file", createRuleBasedIdentifierMappingFile().toFile().getAbsolutePath()) - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcQueryBuilder.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcQueryBuilder.java index 33a88bae2e71..86e51afa9ec9 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcQueryBuilder.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcQueryBuilder.java @@ -220,7 +220,7 @@ public void testNormalBuildSql() .put(columns.get(2), Domain.create(SortedRangeSet.copyOf(BOOLEAN, ImmutableList.of(Range.equal(BOOLEAN, true))), false)) - .build()); + .buildOrThrow()); Connection connection = database.getConnection(); QueryBuilder queryBuilder = new QueryBuilder(jdbcClient); @@ -262,7 +262,7 @@ public void testBuildSqlWithDomainComplement() .put(columns.get(1), Domain.create(ValueSet.of(DOUBLE, 200011.0, 200014.0, 200017.0), true).complement()) // this is here only to limit the list of results being read .put(columns.get(9), Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(INTEGER, 880L)), false)) - .build()); + .buildOrThrow()); Connection connection = database.getConnection(); QueryBuilder queryBuilder = new QueryBuilder(jdbcClient); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSet.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSet.java index 9ae03708e69b..9154b8cabe46 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSet.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSet.java @@ -121,7 +121,7 @@ public void testCursorSimple() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } } @@ -151,7 +151,7 @@ public void testCursorMixedOrder() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSetProvider.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSetProvider.java index 8f0bddd5d312..930e1821cfd0 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSetProvider.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSetProvider.java @@ -116,7 +116,7 @@ public void testGetRecordSet() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } @Test diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcWriteConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcWriteConfig.java index f8ba41336be0..1eb9b7e2df35 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcWriteConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcWriteConfig.java @@ -41,7 +41,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("write.batch-size", "24") .put("insert.non-transactional-insert.enabled", "true") - .build(); + .buildOrThrow(); JdbcWriteConfig expected = new JdbcWriteConfig() .setWriteBatchSize(24) diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRemoteQueryCancellationConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRemoteQueryCancellationConfig.java index 7964ecf1a8fb..4cad37e13d62 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRemoteQueryCancellationConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestRemoteQueryCancellationConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("remote-query-async-cancellation.enabled", "false") - .build(); + .buildOrThrow(); RemoteQueryCancellationConfig expected = new RemoteQueryCancellationConfig() .setRemoteQueryCancellationEnabled(false); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestTypeHandlingJdbcConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestTypeHandlingJdbcConfig.java index d158da635c96..2b3d1d890c97 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestTypeHandlingJdbcConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestTypeHandlingJdbcConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("unsupported-type-handling", "CONVERT_TO_VARCHAR") - .build(); + .buildOrThrow(); TypeHandlingJdbcConfig expected = new TypeHandlingJdbcConfig() .setUnsupportedTypeHandling(UnsupportedTypeHandling.CONVERT_TO_VARCHAR); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingH2JdbcModule.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingH2JdbcModule.java index 500288d6d67a..ec99a4989f8c 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingH2JdbcModule.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingH2JdbcModule.java @@ -66,7 +66,7 @@ public static Map createProperties() { return ImmutableMap.builder() .put("connection-url", format("jdbc:h2:mem:test%s;DB_CLOSE_DELAY=-1", System.nanoTime() + ThreadLocalRandom.current().nextLong())) - .build(); + .buildOrThrow(); } public interface TestingH2JdbcClientFactory diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestCredentialProvider.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestCredentialProvider.java index 2671de10fea9..bedef3519d10 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestCredentialProvider.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestCredentialProvider.java @@ -67,7 +67,7 @@ public void testKeyStoreBasedCredentialProvider() .put("keystore-user-credential-password", "keystore_password_for_user_name") .put("keystore-password-credential-name", "password") .put("keystore-password-credential-password", "keystore_password_for_password") - .build(); + .buildOrThrow(); CredentialProvider credentialProvider = getCredentialProvider(properties); assertEquals(credentialProvider.getConnectionUser(Optional.empty()).get(), "user_from_keystore"); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestExtraCredentialConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestExtraCredentialConfig.java index cef475b24d27..08059ae8b916 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestExtraCredentialConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/TestExtraCredentialConfig.java @@ -38,7 +38,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("user-credential-name", "foo") .put("password-credential-name", "bar") - .build(); + .buildOrThrow(); ExtraCredentialConfig expected = new ExtraCredentialConfig() .setUserCredentialName("foo") diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/file/TestConfigFileBasedCredentialProviderConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/file/TestConfigFileBasedCredentialProviderConfig.java index 9f21323de0d2..2d2c88c4a4a1 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/file/TestConfigFileBasedCredentialProviderConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/file/TestConfigFileBasedCredentialProviderConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("connection-credential-file", credentialFile.toString()) - .build(); + .buildOrThrow(); ConfigFileBasedCredentialProviderConfig expected = new ConfigFileBasedCredentialProviderConfig() .setCredentialFile(credentialFile.toString()); diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/keystore/TestKeyStoreBasedCredentialProviderConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/keystore/TestKeyStoreBasedCredentialProviderConfig.java index e81791d324ba..28cb030d3ca4 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/keystore/TestKeyStoreBasedCredentialProviderConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/credential/keystore/TestKeyStoreBasedCredentialProviderConfig.java @@ -54,7 +54,7 @@ public void testExplicitPropertyMappings() .put("keystore-user-credential-password", "keystore_password_for_user_name") .put("keystore-password-credential-name", "password") .put("keystore-password-credential-password", "keystore_password_for_password") - .build(); + .buildOrThrow(); KeyStoreBasedCredentialProviderConfig expected = new KeyStoreBasedCredentialProviderConfig() .setKeyStoreFilePath(keystoreFile.toString()) diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/mapping/TestMappingConfig.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/mapping/TestMappingConfig.java index aff9df297590..6c6f614cecaf 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/mapping/TestMappingConfig.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/mapping/TestMappingConfig.java @@ -48,7 +48,7 @@ public void testExplicitPropertyMappings() .put("case-insensitive-name-matching.cache-ttl", "1s") .put("case-insensitive-name-matching.config-file", configFile) .put("case-insensitive-name-matching.config-file.refresh-period", "1s") - .build(); + .buildOrThrow(); MappingConfig expected = new MappingConfig() .setCaseInsensitiveNameMatching(true) diff --git a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java index 580ee3ffa18a..a6beea84dfad 100644 --- a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java +++ b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java @@ -321,7 +321,7 @@ public Map> listTableColumns(ConnectorSess // table disappeared during listing operation } } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConfig.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConfig.java index b8811eb6e831..3177f4056823 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConfig.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConfig.java @@ -60,7 +60,7 @@ public void testExplicitPropertyMappingsWithCredentialsKey() .put("bigquery.case-insensitive-name-matching.cache-ttl", "1s") .put("bigquery.views-cache-ttl", "1m") .put("bigquery.service-cache-ttl", "10d") - .build(); + .buildOrThrow(); BigQueryConfig expected = new BigQueryConfig() .setProjectId("pid") diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestStaticCredentialsConfig.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestStaticCredentialsConfig.java index 09a1c79f229e..ebf4f0577db1 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestStaticCredentialsConfig.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestStaticCredentialsConfig.java @@ -45,7 +45,7 @@ public void testExplicitPropertyMappingsWithCredentialsKey() { Map properties = new ImmutableMap.Builder() .put("bigquery.credentials-key", "key") - .build(); + .buildOrThrow(); ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); StaticCredentialsConfig config = configurationFactory.build(StaticCredentialsConfig.class); @@ -62,7 +62,7 @@ public void testExplicitPropertyMappingsWithCredentialsFile() Map properties = new ImmutableMap.Builder() .put("bigquery.credentials-file", file.toString()) - .build(); + .buildOrThrow(); ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); StaticCredentialsConfig config = configurationFactory.build(StaticCredentialsConfig.class); @@ -81,7 +81,7 @@ public void testExplicitPropertyMappingsValidation() Map properties = new ImmutableMap.Builder() .put("bigquery.credentials-key", "key") .put("bigquery.credentials-file", "file") - .build(); + .buildOrThrow(); ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); assertThatThrownBy(() -> configurationFactory.build(StaticCredentialsConfig.class)) diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java index b03297123f14..aa250e3c558e 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java @@ -165,7 +165,7 @@ public Map getColumnHandles(ConnectorSession session, Conn for (CassandraColumnHandle columnHandle : table.getColumns()) { columnHandles.put(cqlNameToSqlName(columnHandle.getName()).toLowerCase(ENGLISH), columnHandle); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -181,7 +181,7 @@ public Map> listTableColumns(ConnectorSess // table disappeared during listing operation } } - return columns.build(); + return columns.buildOrThrow(); } private List listTables(ConnectorSession session, SchemaTablePrefix prefix) diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSplit.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSplit.java index 3de7ed9dbbf4..adfa7d3e2f8c 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSplit.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSplit.java @@ -81,7 +81,7 @@ public Object getInfo() return ImmutableMap.builder() .put("hosts", addresses) .put("partitionId", partitionId) - .build(); + .buildOrThrow(); } @Override diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java index d940bce1b699..a379c6ec816d 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java @@ -251,11 +251,11 @@ private static Optional createTypeForUserType(DataType dataType) } RowType trinoType = RowType.from( - argumentTypes.build().entrySet().stream() + argumentTypes.buildOrThrow().entrySet().stream() .map(field -> new RowType.Field(Optional.of(field.getKey()), field.getValue().getTrinoType())) .collect(toImmutableList())); - return Optional.of(new CassandraType(Kind.UDT, trinoType, argumentTypes.build().values().stream().collect(toImmutableList()))); + return Optional.of(new CassandraType(Kind.UDT, trinoType, argumentTypes.buildOrThrow().values().stream().collect(toImmutableList()))); } public NullableValue getColumnValue(Row row, int position) diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraClientConfig.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraClientConfig.java index 8f21e489876b..b540b36dbe83 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraClientConfig.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraClientConfig.java @@ -110,7 +110,7 @@ public void testExplicitPropertyMappings() .put("cassandra.tls.keystore-password", "keystore-password") .put("cassandra.tls.truststore-path", truststoreFile.toString()) .put("cassandra.tls.truststore-password", "truststore-password") - .build(); + .buildOrThrow(); CassandraClientConfig expected = new CassandraClientConfig() .setContactPoints("host1", "host2") diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java index 9d9b80c0265f..7a407ee7472b 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java @@ -445,7 +445,7 @@ private static ImmutableMap indexColumns(List col index.put(name, i); i++; } - return index.build(); + return index.buildOrThrow(); } private CassandraTableHandle getTableHandle(Optional> partitions, String clusteringKeyPredicates) diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestJsonCassandraHandles.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestJsonCassandraHandles.java index e08da02a58fa..8008f7a86db4 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestJsonCassandraHandles.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestJsonCassandraHandles.java @@ -63,7 +63,7 @@ public class TestJsonCassandraHandles .put("clusteringKey", true) .put("indexed", false) .put("hidden", false) - .build(); + .buildOrThrow(); private static final Map COLUMN2_HANDLE_AS_MAP = ImmutableMap.builder() .put("name", "column2") @@ -76,7 +76,7 @@ public class TestJsonCassandraHandles .put("clusteringKey", false) .put("indexed", false) .put("hidden", false) - .build(); + .buildOrThrow(); private static final Optional> PARTITIONS = Optional.of(List.of( new CassandraPartition( diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConfig.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConfig.java index ff7d1176529c..ce9159188aef 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConfig.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConfig.java @@ -50,7 +50,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("clickhouse.map-string-as-varchar", "true") - .build(); + .buildOrThrow(); ClickHouseConfig expected = new ClickHouseConfig() .setMapStringAsVarchar(true); diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java index 0765947504f9..cc3b8cabe53a 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java @@ -30,7 +30,7 @@ protected QueryRunner createQueryRunner() ImmutableMap.of(), ImmutableMap.builder() .put("clickhouse.map-string-as-varchar", "true") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } } 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 74ce54884fd8..1fd01e813d7e 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 @@ -64,7 +64,7 @@ protected QueryRunner createQueryRunner() ImmutableMap.of(), ImmutableMap.builder() .put("clickhouse.map-string-as-varchar", "true") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } @@ -476,7 +476,7 @@ private Map getTableProperties(String schemaName, String tableNa properties.put(PRIMARY_KEY_PROPERTY, resultSet.getString("primary_key")); properties.put(SAMPLE_BY_PROPERTY, resultSet.getString("sampling_key")); } - return properties.build(); + return properties.buildOrThrow(); } } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java index ee09805389fd..404b790e40f1 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java @@ -31,7 +31,7 @@ protected QueryRunner createQueryRunner() ImmutableMap.of(), ImmutableMap.builder() .put("clickhouse.map-string-as-varchar", "true") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java index cc29ef4cd184..b4d5c378f8db 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java @@ -110,7 +110,7 @@ protected QueryRunner createQueryRunner() ImmutableMap.builder() .put("metadata.cache-ttl", "10m") .put("metadata.cache-missing", "true") - .build(), + .buildOrThrow(), ImmutableList.of()); } diff --git a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java index edea3978ac0f..09fc08509ad9 100644 --- a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java +++ b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java @@ -258,7 +258,7 @@ private Map makeColumnHandles(List fi supportsPredicates(field.getType()))); } - return result.build(); + return result.buildOrThrow(); } private static boolean supportsPredicates(IndexMetadata.Type type) diff --git a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/client/ElasticsearchClient.java b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/client/ElasticsearchClient.java index 4942aeb45937..a7ec98250a47 100644 --- a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/client/ElasticsearchClient.java +++ b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/client/ElasticsearchClient.java @@ -528,7 +528,7 @@ public Map> getAliases() result.put(element.getKey(), ImmutableList.copyOf(aliasNames)); } } - return result.build(); + return result.buildOrThrow(); } catch (IOException e) { throw new TrinoException(ELASTICSEARCH_INVALID_RESPONSE, e); 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 d70c80a6c3dd..b41f61b317bf 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 @@ -254,7 +254,7 @@ public void testNullPredicate() index(indexName, ImmutableMap.builder() .put("null_keyword", 32) .put("custkey", 1301) - .build()); + .buildOrThrow()); assertQueryReturnsEmptyResult("SELECT * FROM null_predicate1 WHERE null_keyword IS NULL"); assertQueryReturnsEmptyResult("SELECT * FROM null_predicate1 WHERE null_keyword = '10' OR null_keyword IS NULL"); @@ -281,7 +281,7 @@ public void testNullPredicate() createIndex(indexName, properties); index(indexName, ImmutableMap.builder() .put("custkey", 1301) - .build()); + .buildOrThrow()); // not null filter assertQueryReturnsEmptyResult("SELECT * FROM null_predicate2 WHERE null_keyword IS NOT NULL"); @@ -297,7 +297,7 @@ public void testNullPredicate() index(indexName, ImmutableMap.builder() .put("null_keyword", 32) .put("custkey", 1302) - .build()); + .buildOrThrow()); assertQuery("SELECT custkey, null_keyword FROM null_predicate2 WHERE null_keyword = '32' OR null_keyword IS NULL", "VALUES (1301, NULL), (1302, 32)"); assertQuery("SELECT custkey FROM null_predicate2 WHERE null_keyword = '32' OR null_keyword IS NULL", "VALUES (1301), (1302)"); @@ -312,7 +312,7 @@ public void testNestedFields() .put("name", "nestfield") .put("fields.fielda", 32) .put("fields.fieldb", "valueb") - .build()); + .buildOrThrow()); assertQuery( "SELECT name, fields.fielda, fields.fieldb FROM data", @@ -328,7 +328,7 @@ public void testNameConflict() .put("field", "value") .put("Conflict", "conflict1") .put("conflict", "conflict2") - .build()); + .buildOrThrow()); assertQuery( "SELECT * FROM name_conflict", @@ -456,7 +456,7 @@ public void testArrayFields() .add(50L) .add(60L) .build()) - .build()); + .buildOrThrow()); assertQuery( "SELECT a.b.y[1], c.f[1].g[2], c.f[2].g[1], j[2], k[1] FROM test_arrays", @@ -616,7 +616,7 @@ public void testAsRawJson() .build()) .build()) .put("order_field", 1) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("es_object", ImmutableMap.builder() @@ -634,7 +634,7 @@ public void testAsRawJson() .put("array_of_string_arrays", "Check out the bi-weekly Trino Community Broadcast https://trino.io/broadcast/") .put("array_of_long_arrays", 5309L) .put("order_field", 2) - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("" + "SELECT " + @@ -793,7 +793,7 @@ public void testAsRawJsonForAllPrimitiveTypes() .put("es_double", (double) 123) .put("es_float", (float) 123) .put("order_field", 1) - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("" + "SELECT " + @@ -860,7 +860,7 @@ public void testAsRawJsonCases() .put("es_binary", "test".getBytes(UTF_8)) .put("es_boolean", true) .put("es_timestamp", 123) - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("" + "SELECT " + @@ -908,7 +908,7 @@ public void testAsRawJsonAndIsArraySameFieldException() index(indexName, ImmutableMap.builder() .put("array_raw_field", "test") - .build()); + .buildOrThrow()); assertThatThrownBy(() -> computeActual("SELECT array_raw_field FROM " + indexName)) .hasMessage("A column, (array_raw_field) cannot be declared as a Trino array and also be rendered as json."); @@ -941,16 +941,15 @@ public void testMixedArray() createIndex(indexName, mapping); - index(indexName, ImmutableMap.builder() - .build()); + index(indexName, ImmutableMap.builder().buildOrThrow()); index(indexName, ImmutableMap.builder() .put("a", "hello") - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("a", ImmutableList.of("foo", "bar")) - .build()); + .buildOrThrow()); assertQuery( "SELECT a FROM test_mixed_arrays", @@ -986,7 +985,7 @@ public void testEmptyNumericFields() .put("float_column", "") .put("scaled_float_column", "") .put("double_column", "") - .build()); + .buildOrThrow()); assertQuery( "SELECT byte_column, short_column, integer_column, long_column, float_column, scaled_float_column, double_column FROM emptynumeric", @@ -1005,7 +1004,7 @@ public void testEmptyObjectFields() .put("emptyobject", ImmutableMap.of()) .put("fields.fielda", 32) .put("fields.fieldb", ImmutableMap.of()) - .build()); + .buildOrThrow()); assertQuery( "SELECT name, fields.fielda FROM emptyobject", @@ -1082,7 +1081,7 @@ public void testDataTypes() .put("ipv4_column", "1.2.3.4") .put("ipv6_column", "2001:db8:0:0:1:0:0:1") .put("scaled_float_column", 123456.78d) - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("" + "SELECT " + @@ -1139,7 +1138,7 @@ public void testTableWithUnsupportedTypes() index(indexName, ImmutableMap.builder() .put("long_column", 1L) .put("unsupported_type", ImmutableList.of("foo", "bar")) - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("SELECT * FROM unsupported_types"); MaterializedResult expected = resultBuilder(getSession(), rows.getTypes()) @@ -1167,23 +1166,23 @@ public void testBoolean() index(indexName, ImmutableMap.builder() .put("boolean_column", true) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("boolean_column", "true") - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("boolean_column", false) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("boolean_column", "false") - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("boolean_column", "") - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("SELECT boolean_column FROM booleans"); @@ -1216,19 +1215,19 @@ public void testTimestamps() index(indexName, ImmutableMap.builder() .put("timestamp_column", "2015-01-01") - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("timestamp_column", "2015-01-01T12:10:30Z") - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("timestamp_column", 1420070400001L) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("timestamp_column", "1420070400001") - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("SELECT timestamp_column FROM timestamps"); @@ -1262,17 +1261,17 @@ public void testScaledFloat() index(indexName, ImmutableMap.builder() .put("text_column", "foo") .put("scaled_float_column", 123.4567d) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("text_column", "bar") .put("scaled_float_column", 123.46d) - .build()); + .buildOrThrow()); index(indexName, ImmutableMap.builder() .put("text_column", "random value") .put("scaled_float_column", 9.8d) - .build()); + .buildOrThrow()); // Trino query filters in the engine, so the rounding (dependent on scaling factor) does not impact results assertEquals( @@ -1310,7 +1309,7 @@ public void testCoercions() .put("double_column", "1.0") .put("integer_column", "1") .put("long_column", "1") - .build()); + .buildOrThrow()); MaterializedResult rows = computeActual("" + "SELECT " + @@ -1367,7 +1366,7 @@ public void testFilters() .put("timestamp_column", 1569888000000L) .put("ipv4_column", "1.2.3.4") .put("ipv6_column", "2001:db8:0:0:1:0:0:1") - .build()); + .buildOrThrow()); // _score column assertQuery("SELECT count(*) FROM \"filter_pushdown: cool\" WHERE _score > 0", "VALUES 1"); @@ -1498,7 +1497,7 @@ public void testDataTypesNested() .put("timestamp_column", 0) .put("ipv4_column", "1.2.3.4") .put("ipv6_column", "2001:db8:0:0:1:0:0:1") - .build())); + .buildOrThrow())); MaterializedResult rows = computeActual("" + "SELECT " + @@ -1568,7 +1567,7 @@ public void testNestedTypeDataTypesNested() .put("timestamp_column", 0) .put("ipv4_column", "1.2.3.4") .put("ipv6_column", "2001:db8:0:0:1:0:0:1") - .build())); + .buildOrThrow())); MaterializedResult rows = computeActual("" + "SELECT " + @@ -1613,7 +1612,7 @@ public void testMixedCase() index(indexName, ImmutableMap.builder() .put("Name", "john") .put("AGE", 32) - .build()); + .buildOrThrow()); assertQuery( "SELECT name, age FROM mixed_case", @@ -1639,7 +1638,7 @@ public void testNumericKeyword() createIndex(indexName, properties); index(indexName, ImmutableMap.builder() .put("numeric_keyword", 20) - .build()); + .buildOrThrow()); assertQuery( "SELECT numeric_keyword FROM numeric_keyword", diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/ElasticsearchQueryRunner.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/ElasticsearchQueryRunner.java index 831e1fed8489..8aed95ef8118 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/ElasticsearchQueryRunner.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/ElasticsearchQueryRunner.java @@ -105,7 +105,7 @@ private static void installElasticsearchPlugin(HostAndPort address, QueryRunner .put("elasticsearch.scroll-timeout", "1m") .put("elasticsearch.request-timeout", "2m") .putAll(extraConnectorProperties) - .build(); + .buildOrThrow(); queryRunner.createCatalog("elasticsearch", "elasticsearch", config); } diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestAwsSecurityConfig.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestAwsSecurityConfig.java index d67faac29f45..990a7f671c6e 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestAwsSecurityConfig.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestAwsSecurityConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("elasticsearch.aws.region", "region") .put("elasticsearch.aws.iam-role", "iamRole") .put("elasticsearch.aws.external-id", "externalId") - .build(); + .buildOrThrow(); AwsSecurityConfig expected = new AwsSecurityConfig() .setAccessKey("access") diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchConfig.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchConfig.java index 0d54d18b1cd3..658d49a6b291 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchConfig.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchConfig.java @@ -88,7 +88,7 @@ public void testExplicitPropertyMappings() .put("elasticsearch.tls.verify-hostnames", "false") .put("elasticsearch.ignore-publish-address", "true") .put("elasticsearch.security", "AWS") - .build(); + .buildOrThrow(); ElasticsearchConfig expected = new ElasticsearchConfig() .setHost("example.com") diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordAuthentication.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordAuthentication.java index 53e0650d3e6a..2c19213d0b47 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordAuthentication.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordAuthentication.java @@ -60,7 +60,7 @@ public void setUp() .put("users", loadResource("users")) .put("users_roles", loadResource("users_roles")) .put("roles.yml", loadResource("roles.yml")) - .build()); + .buildOrThrow()); HostAndPort address = elasticsearch.getAddress(); client = new RestHighLevelClient(RestClient.builder(new HttpHost(address.getHost(), address.getPort()))); @@ -73,7 +73,7 @@ public void setUp() .put("elasticsearch.security", "PASSWORD") .put("elasticsearch.auth.user", USER) .put("elasticsearch.auth.password", PASSWORD) - .build(), + .buildOrThrow(), 3); assertions = new QueryAssertions(runner); @@ -99,7 +99,7 @@ public void test() { String json = new ObjectMapper().writeValueAsString(ImmutableMap.builder() .put("value", 42L) - .build()); + .buildOrThrow()); client.getLowLevelClient() .performRequest( diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordConfig.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordConfig.java index 17f14b0df0c0..f4c75379f0be 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordConfig.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestPasswordConfig.java @@ -38,7 +38,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("elasticsearch.auth.user", "user") .put("elasticsearch.auth.password", "password") - .build(); + .buildOrThrow(); PasswordConfig expected = new PasswordConfig() .setUser("user") diff --git a/plugin/trino-example-http/src/main/java/io/trino/plugin/example/ExampleMetadata.java b/plugin/trino-example-http/src/main/java/io/trino/plugin/example/ExampleMetadata.java index 9a0d8db635f0..f1d705957d94 100644 --- a/plugin/trino-example-http/src/main/java/io/trino/plugin/example/ExampleMetadata.java +++ b/plugin/trino-example-http/src/main/java/io/trino/plugin/example/ExampleMetadata.java @@ -110,7 +110,7 @@ public Map getColumnHandles(ConnectorSession session, Conn columnHandles.put(column.getName(), new ExampleColumnHandle(column.getName(), column.getType(), index)); index++; } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -125,7 +125,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } private ConnectorTableMetadata getTableMetadata(SchemaTableName tableName) diff --git a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleConfig.java b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleConfig.java index 7deef5b175c7..363128eedd7a 100644 --- a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleConfig.java +++ b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("metadata-uri", "file://test.json") - .build(); + .buildOrThrow(); ExampleConfig expected = new ExampleConfig() .setMetadata(URI.create("file://test.json")); diff --git a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSet.java b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSet.java index fb1998b26814..29664547d074 100644 --- a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSet.java +++ b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSet.java @@ -78,7 +78,7 @@ public void testCursorSimple() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } @Test @@ -99,7 +99,7 @@ public void testCursorMixedOrder() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } // diff --git a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSetProvider.java b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSetProvider.java index 6cf777dbbe1e..fc1e09afbf8d 100644 --- a/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSetProvider.java +++ b/plugin/trino-example-http/src/test/java/io/trino/plugin/example/TestExampleRecordSetProvider.java @@ -57,7 +57,7 @@ public void testGetRecordSet() .put("ten", 10L) .put("eleven", 11L) .put("twelve", 12L) - .build()); + .buildOrThrow()); } // diff --git a/plugin/trino-geospatial/src/main/java/io/trino/plugin/geospatial/GeoFunctions.java b/plugin/trino-geospatial/src/main/java/io/trino/plugin/geospatial/GeoFunctions.java index 6806a92b2d16..1cd23a918a52 100644 --- a/plugin/trino-geospatial/src/main/java/io/trino/plugin/geospatial/GeoFunctions.java +++ b/plugin/trino-geospatial/src/main/java/io/trino/plugin/geospatial/GeoFunctions.java @@ -148,7 +148,7 @@ public final class GeoFunctions .put(OGCPolylineSelfTangency, "Self-tangency") .put(OGCPolygonSelfTangency, "Self-tangency") .put(OGCDisconnectedInterior, "Disconnected interior") - .build(); + .buildOrThrow(); private static final int NUMBER_OF_DIMENSIONS = 3; private static final Block EMPTY_ARRAY_OF_INTS = IntegerType.INTEGER.createFixedSizeBlockBuilder(0).build(); diff --git a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java index 9cb796abf014..f61c7ea79ae1 100644 --- a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java +++ b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java @@ -195,7 +195,7 @@ private Map> getAllTableSheetExpressionMapping() tableSheetMap.put(tableId.toLowerCase(Locale.ENGLISH), Optional.of(sheetId)); } } - return tableSheetMap.build(); + return tableSheetMap.buildOrThrow(); } private Credential getCredentials() diff --git a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java index 32861b35e773..e9e38d02cc0a 100644 --- a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java +++ b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java @@ -102,7 +102,7 @@ public Map getColumnHandles(ConnectorSession session, Conn columnHandles.put(column.getName(), new SheetsColumnHandle(column.getName(), column.getType(), index)); index++; } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -117,7 +117,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.get().getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } private Optional getTableMetadata(SchemaTableName tableName) diff --git a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java index b2f0cc5819fa..5152d88ff958 100644 --- a/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java +++ b/plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java @@ -86,7 +86,7 @@ public Object getInfo() .put("schemaName", schemaName) .put("tableName", tableName) .put("hostAddresses", hostAddresses) - .build(); + .buildOrThrow(); } @Override diff --git a/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsConfig.java b/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsConfig.java index 00866360236d..8ab51b521cd8 100644 --- a/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsConfig.java +++ b/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsConfig.java @@ -50,7 +50,7 @@ public void testExplicitPropertyMappings() .put("metadata-sheet-id", "foo_bar_sheet_id#Sheet1") .put("sheets-data-max-cache-size", "2000") .put("sheets-data-expire-after-write", "10m") - .build(); + .buildOrThrow(); SheetsConfig expected = new SheetsConfig() .setCredentialsFilePath(credentialsFile.toString()) diff --git a/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsPlugin.java b/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsPlugin.java index 51eac808b76e..1828fa206731 100644 --- a/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsPlugin.java +++ b/plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestSheetsPlugin.java @@ -53,7 +53,7 @@ public void testCreateConnector() Plugin plugin = new SheetsPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); Builder propertiesMap = new Builder().put("credentials-path", getTestCredentialsPath()).put("metadata-sheet-id", TEST_METADATA_SHEET_ID); - Connector connector = factory.create(GOOGLE_SHEETS, propertiesMap.build(), new TestingConnectorContext()); + Connector connector = factory.create(GOOGLE_SHEETS, propertiesMap.buildOrThrow(), new TestingConnectorContext()); assertNotNull(connector); connector.shutdown(); } diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java index 1e473392d25c..68c1fb277942 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java @@ -86,7 +86,7 @@ private void ensureTableExists(SchemaTableName table, String tableDirectoryName, .put(BUCKET_COUNT_PROPERTY, 0) .put(BUCKETED_BY_PROPERTY, ImmutableList.of()) .put(SORTED_BY_PROPERTY, ImmutableList.of()) - .build()); + .buildOrThrow()); if (!transaction.getMetadata().listTables(newSession(), Optional.of(table.getSchemaName())).contains(table)) { transaction.getMetadata().createTable(newSession(), tableMetadata, false); } diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHivePlugin.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHivePlugin.java index 0e8af491b6da..e807e55cb39f 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHivePlugin.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHivePlugin.java @@ -164,7 +164,7 @@ public void testS3SecurityMappingAndHiveCachingMutuallyExclusive() .put("hive.cache.enabled", "true") .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.cache.location", tempDirectory.toString()) - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("S3 security mapping is not compatible with Hive caching"); } @@ -181,7 +181,7 @@ public void testGcsAccessTokenAndHiveCachingMutuallyExclusive() .put("hive.cache.enabled", "true") .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.cache.location", tempDirectory.toString()) - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("Use of GCS access token is not compatible with Hive caching"); } @@ -197,7 +197,7 @@ public void testImmutablePartitionsAndInsertOverwriteMutuallyExclusive() .put("hive.insert-existing-partitions-behavior", "APPEND") .put("hive.immutable-partitions", "true") .put("hive.metastore.uri", "thrift://foo:1234") - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("insert-existing-partitions-behavior cannot be APPEND when immutable-partitions is true"); } @@ -212,7 +212,7 @@ public void testInsertOverwriteIsSetToErrorWhenImmutablePartitionsIsTrue() ImmutableMap.builder() .put("hive.immutable-partitions", "true") .put("hive.metastore.uri", "thrift://foo:1234") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertThat(getDefaultValueInsertExistingPartitionsBehavior(connector)).isEqualTo(ERROR); connector.shutdown(); @@ -227,7 +227,7 @@ public void testInsertOverwriteIsSetToAppendWhenImmutablePartitionsIsFalseByDefa "test", ImmutableMap.builder() .put("hive.metastore.uri", "thrift://foo:1234") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertThat(getDefaultValueInsertExistingPartitionsBehavior(connector)).isEqualTo(APPEND); connector.shutdown(); @@ -254,7 +254,7 @@ public void testHdfsImpersonationAndHiveCachingMutuallyExclusive() .put("hive.cache.enabled", "true") .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.cache.location", tempDirectory.toString()) - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("HDFS impersonation is not compatible with Hive caching"); } @@ -270,7 +270,7 @@ public void testRubixCache() .put("hive.cache.enabled", "true") .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.cache.location", tempDirectory.toString()) - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -287,7 +287,7 @@ public void testRubixCacheWithNonExistingCacheDirectory() .put("hive.cache.start-server-on-coordinator", "true") .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.cache.location", "/tmp/non/existing/directory") - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasRootCauseMessage("None of the cache parent directories exists"); @@ -297,7 +297,7 @@ public void testRubixCacheWithNonExistingCacheDirectory() .put("hive.cache.enabled", "true") .put("hive.cache.start-server-on-coordinator", "true") .put("hive.metastore.uri", "thrift://foo:1234") - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasRootCauseMessage("caching directories were not provided"); @@ -307,7 +307,7 @@ public void testRubixCacheWithNonExistingCacheDirectory() ImmutableMap.builder() .put("hive.cache.enabled", "true") .put("hive.metastore.uri", "thrift://foo:1234") - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -322,7 +322,7 @@ public void testAllowAllAccessControl() ImmutableMap.builder() .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.security", "allow-all") - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -337,7 +337,7 @@ public void testReadOnlyAllAccessControl() ImmutableMap.builder() .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.security", "read-only") - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -357,7 +357,7 @@ public void testFileBasedAccessControl() .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.security", "file") .put("security.config-file", tempFile.getAbsolutePath()) - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -372,7 +372,7 @@ public void testSystemAccessControl() ImmutableMap.builder() .put("hive.metastore.uri", "thrift://foo:1234") .put("hive.security", "system") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertThatThrownBy(connector::getAccessControl).isInstanceOf(UnsupportedOperationException.class); connector.shutdown(); diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java index cc747f3325d9..f002c705d3cf 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java @@ -527,7 +527,7 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect .putAll(tableMetadata.getProperties()) // we use table properties as a vehicle to pass to the analyzer the subset of columns to be analyzed .put(ANALYZE_COLUMNS_PROPERTY, columnNames) - .build(), + .buildOrThrow(), tableMetadata.getComment())) .orElse(tableMetadata); } @@ -646,7 +646,7 @@ private ConnectorTableMetadata doGetTableMetadata(ConnectorSession session, Sche properties.put(AUTO_PURGE, true); } - return new ConnectorTableMetadata(tableName, columns.build(), properties.build(), comment); + return new ConnectorTableMetadata(tableName, columns.build(), properties.buildOrThrow(), comment); } private static Optional getCsvSerdeProperty(Table table, String key) @@ -1015,7 +1015,7 @@ private Map getEmptyTableProperties(ConnectorTableMetadata table // Table comment property tableMetadata.getComment().ifPresent(value -> tableProperties.put(TABLE_COMMENT, value)); - return tableProperties.build(); + return tableProperties.buildOrThrow(); } private static void checkFormatForProperty(HiveStorageFormat actualStorageFormat, HiveStorageFormat expectedStorageFormat, String propertyName) @@ -1144,7 +1144,7 @@ private static Table buildTableObject( .setTableType((external ? EXTERNAL_TABLE : MANAGED_TABLE).name()) .setDataColumns(columns.build()) .setPartitionColumns(partitionColumns) - .setParameters(tableParameters.build()); + .setParameters(tableParameters.buildOrThrow()); tableBuilder.getStorageBuilder() .setStorageFormat(fromHiveStorageFormat(hiveStorageFormat)) @@ -1297,7 +1297,7 @@ public void finishStatisticsCollection(ConnectorSession session, ConnectorTableH } } verify(usedComputedStatistics == computedStatistics.size(), "All computed statistics must be used"); - metastore.setPartitionStatistics(identity, table, partitionStatistics.build()); + metastore.setPartitionStatistics(identity, table, partitionStatistics.buildOrThrow()); } } @@ -1952,7 +1952,7 @@ private Partition buildPartitionObject(ConnectorSession session, Table table, Pa .setParameters(ImmutableMap.builder() .put(PRESTO_VERSION_NAME, prestoVersion) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) - .build()) + .buildOrThrow()) .withStorage(storage -> storage .setStorageFormat(isRespectTableFormat(session) ? table.getStorage().getStorageFormat() : @@ -2249,7 +2249,7 @@ public void createView(ConnectorSession session, SchemaTableName viewName, Conne .put(TRINO_CREATED_BY, "Trino Hive connector") .put(PRESTO_VERSION_NAME, prestoVersion) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) - .build(); + .buildOrThrow(); Column dummyColumn = new Column("dummy", HIVE_STRING, Optional.empty()); @@ -2375,7 +2375,7 @@ else if (e.getErrorCode().equals(TABLE_NOT_FOUND.toErrorCode())) { } } } - return views.build(); + return views.buildOrThrow(); } @Override @@ -2683,7 +2683,7 @@ public Optional> applyProjecti } // Modify projections to refer to new variables - Map newVariables = newVariablesBuilder.build(); + Map newVariables = newVariablesBuilder.buildOrThrow(); List newProjections = projections.stream() .map(expression -> replaceWithNewVariables(expression, newVariables)) .collect(toImmutableList()); @@ -3340,7 +3340,7 @@ private static Function columnMetadataGetter(T } } - Map> columnComment = builder.build(); + Map> columnComment = builder.buildOrThrow(); return handle -> ColumnMetadata.builder() .setName(handle.getName()) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HivePartitionManager.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HivePartitionManager.java index e80257dd955f..5ffbb46ed0f0 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HivePartitionManager.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HivePartitionManager.java @@ -265,7 +265,7 @@ public static HivePartition parsePartition( NullableValue parsedValue = parsePartitionValue(partitionName, partitionValues.get(i), partitionColumnTypes.get(i)); builder.put(column, parsedValue); } - Map values = builder.build(); + Map values = builder.buildOrThrow(); return new HivePartition(tableName, partitionName, values); } diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSchemaProperties.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSchemaProperties.java index f46002162e9d..6ee606bf17ea 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSchemaProperties.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSchemaProperties.java @@ -42,7 +42,7 @@ public static Map fromDatabase(Database db) ImmutableMap.Builder result = ImmutableMap.builder(); db.getLocation().ifPresent(location -> result.put(HiveSchemaProperties.LOCATION_PROPERTY, location)); - return result.build(); + return result.buildOrThrow(); } public static Optional getLocation(Map schemaProperties) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplit.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplit.java index 8a25ce3d980a..a0d02cdd4f1a 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplit.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplit.java @@ -295,7 +295,7 @@ public Object getInfo() .put("deserializerClassName", getDeserializerClassName(schema)) .put("s3SelectPushdownEnabled", s3SelectPushdownEnabled) .put("splitNumber", splitNumber) - .build(); + .buildOrThrow(); } @Override diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplitManager.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplitManager.java index c2c933ba4e84..865b2a8de3d7 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplitManager.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveSplitManager.java @@ -325,7 +325,7 @@ private Iterable getPartitionMetadata(ConnectorSession se } partitionBuilder.put(entry.getKey(), entry.getValue().get()); } - Map partitions = partitionBuilder.build(); + Map partitions = partitionBuilder.buildOrThrow(); if (partitionBatch.size() != partitions.size()) { throw new TrinoException(GENERIC_INTERNAL_ERROR, format("Expected %s partitions but found %s", partitionBatch.size(), partitions.size())); } @@ -419,7 +419,7 @@ private TableToPartitionMapping getTableToPartitionMapping(ConnectorSession sess columnCoercions.put(i, partitionType.getHiveTypeName()); } } - return mapColumnsByIndex(columnCoercions.build()); + return mapColumnsByIndex(columnCoercions.buildOrThrow()); } private static boolean isPartitionUsesColumnNames(ConnectorSession session, HiveStorageFormat storageFormat) @@ -444,7 +444,7 @@ private TableToPartitionMapping getTableToPartitionMappingByColumnNames(SchemaTa for (int i = 0; i < partitionColumns.size(); i++) { partitionColumnIndexesBuilder.put(partitionColumns.get(i).getName().toLowerCase(ENGLISH), i); } - Map partitionColumnsByIndex = partitionColumnIndexesBuilder.build(); + Map partitionColumnsByIndex = partitionColumnIndexesBuilder.buildOrThrow(); ImmutableMap.Builder columnCoercions = ImmutableMap.builder(); ImmutableMap.Builder tableToPartitionColumns = ImmutableMap.builder(); @@ -466,7 +466,7 @@ private TableToPartitionMapping getTableToPartitionMappingByColumnNames(SchemaTa } } - return new TableToPartitionMapping(Optional.of(tableToPartitionColumns.build()), columnCoercions.build()); + return new TableToPartitionMapping(Optional.of(tableToPartitionColumns.buildOrThrow()), columnCoercions.buildOrThrow()); } private TrinoException tablePartitionColumnMismatchException(SchemaTableName tableName, String partName, String tableColumnName, HiveType tableType, String partitionColumnName, HiveType partitionType) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveUpdateProcessor.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveUpdateProcessor.java index ad35341ab9b8..a57ce4c972a7 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveUpdateProcessor.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveUpdateProcessor.java @@ -268,7 +268,7 @@ else if (dependencyColumnNames.contains(handle.getName())) { nonUpdatedIndex++; } } - Map nonUpdatedMap = nonUpdatedNumbersBuilder.build(); + Map nonUpdatedMap = nonUpdatedNumbersBuilder.buildOrThrow(); return nonUpdatedColumns.stream().map(nonUpdatedMap::get).collect(toImmutableList()); } } diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/RcFileFileWriterFactory.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/RcFileFileWriterFactory.java index 8b42e1e5e79c..c908d03a0688 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/RcFileFileWriterFactory.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/RcFileFileWriterFactory.java @@ -166,7 +166,7 @@ else if (ColumnarSerDe.class.getName().equals(storageFormat.getSerde())) { ImmutableMap.builder() .put(PRESTO_VERSION_NAME, nodeVersion.toString()) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) - .build(), + .buildOrThrow(), validationInputFactory)); } catch (Exception e) { diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java index c2127ca47c90..85635b575681 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java @@ -301,7 +301,7 @@ public synchronized Map getPartitionStatistics(Hive else { partitionNamesToQuery.build().forEach(partitionName -> resultBuilder.put(partitionName, PartitionStatistics.empty())); } - return resultBuilder.build(); + return resultBuilder.buildOrThrow(); } /** @@ -351,7 +351,7 @@ public synchronized HivePageSinkMetadata generatePageSinkMetadata(HiveIdentity i for (Map.Entry, Action> entry : partitionActionMap.entrySet()) { modifiedPartitionMapBuilder.put(entry.getKey(), getPartitionFromPartitionAction(entry.getValue())); } - modifiedPartitionMap = modifiedPartitionMapBuilder.build(); + modifiedPartitionMap = modifiedPartitionMapBuilder.buildOrThrow(); } return new HivePageSinkMetadata( schemaTableName, @@ -905,7 +905,7 @@ public synchronized Map> getPartitionsByNames(HiveId resultBuilder.putAll(delegateResult); } - return resultBuilder.build(); + return resultBuilder.buildOrThrow(); } private static Optional getPartitionFromPartitionAction(Action partitionAction) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/alluxio/AlluxioHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/alluxio/AlluxioHiveMetastore.java index 4e58588be5b4..b9dfcfbdb48f 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/alluxio/AlluxioHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/alluxio/AlluxioHiveMetastore.java @@ -176,7 +176,7 @@ public Map getPartitionStatistics(HiveIdentity iden Map columnStatistics = partitionColumnStatistics.getOrDefault(partitionName, ImmutableMap.of()); result.put(partitionName, new PartitionStatistics(basicStatistics, columnStatistics)); } - return result.build(); + return result.buildOrThrow(); } catch (Exception e) { throw new TrinoException(HIVE_METASTORE_ERROR, e); diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/cache/CachingHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/cache/CachingHiveMetastore.java index 528cf56adaef..626f084b2e63 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/cache/CachingHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/cache/CachingHiveMetastore.java @@ -393,7 +393,7 @@ private Map, PartitionStatistics> loadPartitionC result.put(partitionName, statisticsByPartitionName.get(stringNameForPartition)); } }); - return result.build(); + return result.buildOrThrow(); } @Override @@ -732,7 +732,7 @@ public Map> getPartitionsByNames(HiveIdentity identi for (Entry, Optional> entry : all.entrySet()) { partitionsByName.put(entry.getKey().getKey().getPartitionName().get(), entry.getValue()); } - return partitionsByName.build(); + return partitionsByName.buildOrThrow(); } private Optional loadPartitionByName(WithIdentity partitionName) @@ -769,7 +769,7 @@ private Map, Optional> loadPartitions for (WithIdentity partitionName : partitionNames) { partitions.put(partitionName, partitionsByNames.getOrDefault(partitionName.getKey().getPartitionName().get(), Optional.empty())); } - return partitions.build(); + return partitions.buildOrThrow(); } @Override diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/file/FileHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/file/FileHiveMetastore.java index 79ef11d3ba08..6230cb56066d 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/file/FileHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/file/FileHiveMetastore.java @@ -1103,7 +1103,7 @@ public synchronized Map> getPartitionsByNames(HiveId List partitionValues = toPartitionValues(partitionName); builder.put(partitionName, getPartition(identity, table, partitionValues)); } - return builder.build(); + return builder.buildOrThrow(); } @Override diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueColumnStatisticsProvider.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueColumnStatisticsProvider.java index 2a4125d13570..ebc5c36199ba 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueColumnStatisticsProvider.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueColumnStatisticsProvider.java @@ -124,7 +124,7 @@ public Map getTableColumnStatistics(Table table) fromGlueColumnStatistics(columnStatistics.getStatisticsData(), tableStatistics.getRowCount())); } } - return columnStatsMapBuilder.build(); + return columnStatsMapBuilder.buildOrThrow(); } catch (RuntimeException ex) { throw new TrinoException(HIVE_METASTORE_ERROR, ex); @@ -180,10 +180,10 @@ public Map> getPartitionColumnStati fromGlueColumnStatistics(columnStatistics.getStatisticsData(), tableStatistics.getRowCount()))); } - partitionStatistics.put(partition, columnStatsMapBuilder.build()); + partitionStatistics.put(partition, columnStatsMapBuilder.buildOrThrow()); }); - return partitionStatistics.build(); + return partitionStatistics.buildOrThrow(); } catch (RuntimeException ex) { if (ex.getCause() != null && ex.getCause() instanceof EntityNotFoundException) { diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java index 242e80febdaf..0b6003180bcd 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java @@ -901,7 +901,7 @@ private Map> getPartitionsByNames(Table table, List< Partition partition = partitionValuesToPartitionMap.get(entry.getValue()); resultBuilder.put(entry.getKey(), Optional.ofNullable(partition)); } - return resultBuilder.build(); + return resultBuilder.buildOrThrow(); } private List batchGetPartition(Table table, List partitionNames) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/BridgingHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/BridgingHiveMetastore.java index 79752d51aec8..b968f68ea782 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/BridgingHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/BridgingHiveMetastore.java @@ -373,7 +373,7 @@ public Map> getPartitionsByNames(HiveIdentity identi Partition partition = partitionValuesToPartitionMap.get(entry.getValue()); resultBuilder.put(entry.getKey(), Optional.ofNullable(partition)); } - return resultBuilder.build(); + return resultBuilder.buildOrThrow(); } private Partition fromMetastoreApiPartition(Table table, org.apache.hadoop.hive.metastore.api.Partition partition) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHiveMetastore.java index 4aeccf49e079..c116b71702a1 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHiveMetastore.java @@ -445,7 +445,7 @@ public Map getPartitionStatistics(HiveIdentity iden result.put(partitionName, new PartitionStatistics(basicStatistics, columnStatistics)); } - return result.build(); + return result.buildOrThrow(); } @Override diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java index 16153cdd329b..8cf7e8706cc5 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java @@ -205,7 +205,7 @@ private static PrincipalPrivilegeSet toMetastoreApiPrincipalPrivilegeSet(Princip .collect(toImmutableList())); } - return new PrincipalPrivilegeSet(userPrivileges.build(), ImmutableMap.of(), rolePrivileges.build()); + return new PrincipalPrivilegeSet(userPrivileges.buildOrThrow(), ImmutableMap.of(), rolePrivileges.buildOrThrow()); } public static PrivilegeGrantInfo toMetastoreApiPrivilegeGrantInfo(HivePrivilegeInfo privilegeInfo) @@ -794,7 +794,7 @@ public static Map updateStatisticsParameters(Map result.put("STATS_GENERATED_VIA_STATS_TASK", "workaround for potential lack of HIVE-12730"); } - return result.build(); + return result.buildOrThrow(); } public static ColumnStatisticsObj createMetastoreColumnStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics, OptionalLong rowCount) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/orc/OrcFileWriterFactory.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/orc/OrcFileWriterFactory.java index 9b3f8022c5df..89e7f820d4df 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/orc/OrcFileWriterFactory.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/orc/OrcFileWriterFactory.java @@ -214,7 +214,7 @@ public Optional createFileWriter( ImmutableMap.builder() .put(PRESTO_VERSION_NAME, nodeVersion.toString()) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) - .build(), + .buildOrThrow(), validationInputFactory, getOrcOptimizedWriterValidateMode(session), stats)); diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/parquet/ParquetPageSourceFactory.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/parquet/ParquetPageSourceFactory.java index d72571d27363..1aeee10e3e85 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/parquet/ParquetPageSourceFactory.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/parquet/ParquetPageSourceFactory.java @@ -437,7 +437,7 @@ public static TupleDomain getParquetTupleDomain( predicate.put(descriptor, entry.getValue()); } } - return TupleDomain.withColumnDomains(predicate.build()); + return TupleDomain.withColumnDomains(predicate.buildOrThrow()); } private static org.apache.parquet.schema.Type getParquetType(HiveColumnHandle column, MessageType messageType, boolean useParquetColumnNames) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java index 11a933295b71..446ae68cf521 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/rcfile/RcFilePageSourceFactory.java @@ -193,7 +193,7 @@ else if (deserializerClassName.equals(ColumnarSerDe.class.getName())) { RcFileReader rcFileReader = new RcFileReader( dataSource, rcFileEncoding, - readColumns.build(), + readColumns.buildOrThrow(), new AircompressorCodecFactory(new HadoopCodecFactory(configuration.getClassLoader())), start, length, diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java index 2c0f06271104..5f2a442ff874 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHive.java @@ -548,7 +548,7 @@ private static RowType toRowType(List columns) .put("t_timestamp", createIntegerColumnStatistics(OptionalLong.of(1234567L), OptionalLong.of(71234567L), OptionalLong.of(7), OptionalLong.of(5))) .put("t_short_decimal", createDecimalColumnStatistics(Optional.of(new BigDecimal(10)), Optional.of(new BigDecimal(12)), OptionalLong.of(3), OptionalLong.of(5))) .put("t_long_decimal", createDecimalColumnStatistics(Optional.of(new BigDecimal("12345678901234567.123")), Optional.of(new BigDecimal("81234567890123456.123")), OptionalLong.of(2), OptionalLong.of(1))) - .build()); + .buildOrThrow()); protected static final PartitionStatistics STATISTICS_1_1 = new PartitionStatistics( @@ -585,7 +585,7 @@ private static RowType toRowType(List columns) .put("t_timestamp", createIntegerColumnStatistics(OptionalLong.of(2345671L), OptionalLong.of(12345677L), OptionalLong.of(9), OptionalLong.of(1))) .put("t_short_decimal", createDecimalColumnStatistics(Optional.of(new BigDecimal(11)), Optional.of(new BigDecimal(14)), OptionalLong.of(5), OptionalLong.of(7))) .put("t_long_decimal", createDecimalColumnStatistics(Optional.of(new BigDecimal("71234567890123456.123")), Optional.of(new BigDecimal("78123456789012345.123")), OptionalLong.of(2), OptionalLong.of(1))) - .build()); + .buildOrThrow()); private static final PartitionStatistics STATISTICS_EMPTY_OPTIONAL_FIELDS = new PartitionStatistics( @@ -607,7 +607,7 @@ private static RowType toRowType(List columns) .put("t_timestamp", createIntegerColumnStatistics(OptionalLong.empty(), OptionalLong.empty(), OptionalLong.of(9), OptionalLong.of(1))) .put("t_short_decimal", createDecimalColumnStatistics(Optional.empty(), Optional.empty(), OptionalLong.of(5), OptionalLong.of(7))) .put("t_long_decimal", createDecimalColumnStatistics(Optional.empty(), Optional.empty(), OptionalLong.of(2), OptionalLong.of(1))) - .build()); + .buildOrThrow()); protected String database; protected SchemaTableName tablePartitionFormat; @@ -716,28 +716,28 @@ protected void setupHive(String databaseName) .put(dsColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("2012-12-29"))) .put(fileFormatColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("textfile"))) .put(dummyColumn, NullableValue.of(INTEGER, 1L)) - .build())) + .buildOrThrow())) .add(new HivePartition(tablePartitionFormat, "ds=2012-12-29/file_format=sequencefile/dummy=2", ImmutableMap.builder() .put(dsColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("2012-12-29"))) .put(fileFormatColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("sequencefile"))) .put(dummyColumn, NullableValue.of(INTEGER, 2L)) - .build())) + .buildOrThrow())) .add(new HivePartition(tablePartitionFormat, "ds=2012-12-29/file_format=rctext/dummy=3", ImmutableMap.builder() .put(dsColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("2012-12-29"))) .put(fileFormatColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("rctext"))) .put(dummyColumn, NullableValue.of(INTEGER, 3L)) - .build())) + .buildOrThrow())) .add(new HivePartition(tablePartitionFormat, "ds=2012-12-29/file_format=rcbinary/dummy=4", ImmutableMap.builder() .put(dsColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("2012-12-29"))) .put(fileFormatColumn, NullableValue.of(createUnboundedVarcharType(), utf8Slice("rcbinary"))) .put(dummyColumn, NullableValue.of(INTEGER, 4L)) - .build())) + .buildOrThrow())) .build(); tableUnpartitionedPartitions = ImmutableList.of(new HivePartition(tableUnpartitioned)); tablePartitionFormatProperties = new ConnectorTableProperties( @@ -1592,7 +1592,7 @@ public void testBucketedTableStringInt() .put(columnHandles.get(columnIndex.get("t_int")), NullableValue.of(INTEGER, (long) testInt)) .put(columnHandles.get(columnIndex.get("t_string")), NullableValue.of(createUnboundedVarcharType(), utf8Slice(testString))) .put(columnHandles.get(columnIndex.get("t_smallint")), NullableValue.of(SMALLINT, (long) testSmallint)) - .build(); + .buildOrThrow(); MaterializedResult result = readTable(transaction, tableHandle, columnHandles, session, TupleDomain.fromFixedValues(bindings), OptionalInt.of(1), Optional.empty()); @@ -1638,7 +1638,7 @@ public void testBucketedTableBigintBoolean() .put(columnHandles.get(columnIndex.get("t_string")), NullableValue.of(createUnboundedVarcharType(), utf8Slice(testString))) .put(columnHandles.get(columnIndex.get("t_bigint")), NullableValue.of(BIGINT, testBigint)) .put(columnHandles.get(columnIndex.get("t_boolean")), NullableValue.of(BOOLEAN, testBoolean)) - .build(); + .buildOrThrow(); MaterializedResult result = readTable(transaction, tableHandle, columnHandles, session, TupleDomain.fromFixedValues(bindings), OptionalInt.of(1), Optional.empty()); @@ -1673,7 +1673,7 @@ public void testBucketedTableDoubleFloat() ImmutableMap bindings = ImmutableMap.builder() .put(columnHandles.get(columnIndex.get("t_float")), NullableValue.of(REAL, (long) floatToRawIntBits(87.1f))) .put(columnHandles.get(columnIndex.get("t_double")), NullableValue.of(DOUBLE, 88.2)) - .build(); + .buildOrThrow(); // floats and doubles are not supported, so we should see all splits MaterializedResult result = readTable(transaction, tableHandle, columnHandles, session, TupleDomain.fromFixedValues(bindings), OptionalInt.of(32), Optional.empty()); @@ -2595,7 +2595,7 @@ private void doTestBucketSortedTables(SchemaTableName table) .add(new SortingColumn("value_asc", ASCENDING)) .add(new SortingColumn("value_desc", DESCENDING)) .build()) - .build()); + .buildOrThrow()); ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(session, tableMetadata, Optional.empty(), NO_RETRIES); @@ -3471,7 +3471,7 @@ public void testApplyProjection() inputAssignments = ImmutableMap.builder() .putAll(getColumnHandlesFor(columnHandlesWithSymbols, ImmutableList.of("symbol_2"))) .put(newlyCreatedColumn.getVariable(), newlyCreatedColumn.getColumn()) - .build(); + .buildOrThrow(); inputProjections = ImmutableList.of(symbol2Field0, new Variable("onelevelrow0#f_int0", BIGINT)); projectionResult = metadata.applyProjection(session, tableHandle, inputProjections, inputAssignments); expectedProjections = ImmutableList.of(new Variable("onelevelrow0#f_int0", BIGINT), new Variable("onelevelrow0#f_int0", BIGINT)); @@ -5037,7 +5037,7 @@ protected static ImmutableMap indexColumns(List c index.put(hiveColumnHandle.getName(), i); i++; } - return index.build(); + return index.buildOrThrow(); } protected static ImmutableMap indexColumns(ConnectorTableMetadata tableMetadata) @@ -5048,7 +5048,7 @@ protected static ImmutableMap indexColumns(ConnectorTableMetada index.put(columnMetadata.getName(), i); i++; } - return index.build(); + return index.buildOrThrow(); } protected SchemaTableName temporaryTable(String tableName) @@ -5075,7 +5075,7 @@ protected static Map createTableProperties(HiveStorageFormat sto .put(BUCKETED_BY_PROPERTY, ImmutableList.of()) .put(BUCKET_COUNT_PROPERTY, 0) .put(SORTED_BY_PROPERTY, ImmutableList.of()) - .build(); + .buildOrThrow(); } protected static List filterNonHiddenColumnHandles(Collection columnHandles) @@ -5142,7 +5142,7 @@ protected void createEmptyTable( .setTableName(tableName) .setOwner(Optional.of(tableOwner)) .setTableType(TableType.MANAGED_TABLE.name()) - .setParameters(tableParamBuilder.build()) + .setParameters(tableParamBuilder.buildOrThrow()) .setDataColumns(columns) .setPartitionColumns(partitionColumns); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java index 13102898f216..5ea5adbbed06 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java @@ -95,7 +95,7 @@ protected QueryRunner createQueryRunner() // Below are required to enable caching on metastore .put("hive.metastore-cache-ttl", "1d") .put("hive.metastore-refresh-interval", "1d") - .build()); + .buildOrThrow()); } @BeforeClass diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveBenchmarkQueryRunner.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveBenchmarkQueryRunner.java index 15289c5e755d..d24158711502 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveBenchmarkQueryRunner.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveBenchmarkQueryRunner.java @@ -79,7 +79,7 @@ public static LocalQueryRunner createLocalQueryRunner(File tempDir) Map hiveCatalogConfig = ImmutableMap.builder() .put("hive.max-split-size", "10GB") - .build(); + .buildOrThrow(); localQueryRunner.createCatalog("hive", new TestingHiveConnectorFactory(metastore), hiveCatalogConfig); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java index 17b9e12d4b20..542a241cb673 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java @@ -182,7 +182,7 @@ public DistributedQueryRunner build() } hiveProperties.put("hive.max-partitions-per-scan", "1000"); hiveProperties.put("hive.security", SQL_STANDARD); - hiveProperties.putAll(this.hiveProperties.build()); + hiveProperties.putAll(this.hiveProperties.buildOrThrow()); Map hiveBucketedProperties = ImmutableMap.builder() .putAll(hiveProperties) @@ -190,7 +190,7 @@ public DistributedQueryRunner build() .put("hive.max-split-size", "10kB") // so that each bucket has multiple splits .put("hive.storage-format", "TEXTFILE") // so that there's no minimum split size for the file .put("hive.compression-codec", "NONE") // so that the file is splittable - .build(); + .buildOrThrow(); queryRunner.createCatalog(HIVE_CATALOG, "hive", hiveProperties); queryRunner.createCatalog(HIVE_BUCKETED_CATALOG, "hive", hiveBucketedProperties); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHdfsConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHdfsConfig.java index 925e090e35a6..9482d4e2d9ea 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHdfsConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHdfsConfig.java @@ -75,7 +75,7 @@ public void testExplicitPropertyMappings() .put("hive.hdfs.wire-encryption.enabled", "true") .put("hive.fs.cache.max-size", "1010") .put("hive.dfs.replication", "1") - .build(); + .buildOrThrow(); HdfsConfig expected = new HdfsConfig() .setResourceConfigFiles(ImmutableList.of(resource1.toFile(), resource2.toFile())) @@ -101,7 +101,7 @@ public void testNewDirectoryPermissionsMapping() { Map properties = new ImmutableMap.Builder() .put("hive.fs.new-directory-permissions", "skip") - .build(); + .buildOrThrow(); HdfsConfig expected = new HdfsConfig() .setNewDirectoryPermissions("skip"); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConfig.java index 5ce35ab89f68..2921d26f7911 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConfig.java @@ -188,7 +188,7 @@ public void testExplicitPropertyMappings() .put("hive.iceberg-catalog-name", "iceberg") .put("hive.size-based-split-weights-enabled", "false") .put("hive.minimum-assigned-split-weight", "1.0") - .build(); + .buildOrThrow(); HiveConfig expected = new HiveConfig() .setMaxSplitSize(DataSize.of(256, Unit.MEGABYTE)) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorFactory.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorFactory.java index 6634df015135..b9b0a3c2de13 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorFactory.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveConnectorFactory.java @@ -48,7 +48,7 @@ private static void assertCreateConnector(String metastoreUri) { Map config = ImmutableMap.builder() .put("hive.metastore.uri", metastoreUri) - .build(); + .buildOrThrow(); Connector connector = new HiveConnectorFactory("hive").create("hive-test", config, new TestingConnectorContext()); ConnectorTransactionHandle transaction = connector.beginTransaction(READ_UNCOMMITTED, true, true); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveQlTranslation.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveQlTranslation.java index 8fccbfed0d0f..6eea69062eb5 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveQlTranslation.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveQlTranslation.java @@ -65,7 +65,7 @@ public class TestHiveQlTranslation // just quotes .put("'\\''", "''''") .put("\"\\\"\"", "'\"'") - .build(); + .buildOrThrow(); private static Map extendedColumnNames = ImmutableMap.builder() @@ -100,7 +100,7 @@ public class TestHiveQlTranslation .put( "\"double: two singles''\"", "'double: two singles'''''") - .build(); + .buildOrThrow(); /** * Prepare all combinations of {@code n} of the given columns. diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveReaderProjectionsUtil.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveReaderProjectionsUtil.java index 05f61dc1a062..334badbabd58 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveReaderProjectionsUtil.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveReaderProjectionsUtil.java @@ -57,7 +57,7 @@ public static Map createTestFullColumns(List n regularColumnHiveIndex++; } - return hiveColumns.build(); + return hiveColumns.buildOrThrow(); } public static HiveColumnHandle createProjectedColumnHandle(HiveColumnHandle column, List indices) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcWriterConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcWriterConfig.java index c9c533c5350c..c9ef6e7c33d1 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcWriterConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcWriterConfig.java @@ -62,7 +62,7 @@ public void testExplicitPropertyMappings() .put("hive.orc.writer.writer-identification", "LEGACY_HIVE_COMPATIBLE") .put("hive.orc.writer.validation-percentage", "0.16") .put("hive.orc.writer.validation-mode", "DETAILED") - .build(); + .buildOrThrow(); OrcWriterConfig expected = new OrcWriterConfig() .setStripeMinSize(DataSize.of(13, MEGABYTE)) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestReaderColumns.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestReaderColumns.java index 975946be097b..2c4f5c3bc12a 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestReaderColumns.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestReaderColumns.java @@ -49,7 +49,7 @@ public class TestReaderColumns .put("col_struct_of_non_primitives", ROWTYPE_OF_ROW_AND_PRIMITIVES) .put("col_partition_key_1", BIGINT) .put("col_partition_key_2", BIGINT) - .build(); + .buildOrThrow(); private static final Map TEST_FULL_COLUMNS = createTestFullColumns(TEST_COLUMN_NAMES, TEST_COLUMN_TYPES); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestRecordingMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestRecordingMetastoreConfig.java index 4340ff901150..1ab4b2de75fc 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestRecordingMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestRecordingMetastoreConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() .put("hive.metastore-recording-path", "/foo/bar") .put("hive.metastore-recording-duration", "42s") .put("hive.replay-metastore-recording", "true") - .build(); + .buildOrThrow(); RecordingMetastoreConfig expected = new RecordingMetastoreConfig() .setRecordingPath("/foo/bar") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestTableToPartitionMapping.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestTableToPartitionMapping.java index 307001afe121..e0e240ee919f 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestTableToPartitionMapping.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestTableToPartitionMapping.java @@ -30,19 +30,19 @@ public void testIsOneToOneMapping() .put(1, 1) .put(2, 2) .put(3, 3) - .build())); + .buildOrThrow())); assertFalse(isIdentityMapping(ImmutableMap.builder() .put(0, 0) .put(1, 1) .put(2, 2) .put(3, 3) .put(5, 5) - .build())); + .buildOrThrow())); assertFalse(isIdentityMapping(ImmutableMap.builder() .put(0, 0) .put(1, 1) .put(2, 2) .put(4, 5) - .build())); + .buildOrThrow())); } } diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsAuthenticationConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsAuthenticationConfig.java index 423bf087597c..df5484cfd4ef 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsAuthenticationConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsAuthenticationConfig.java @@ -39,7 +39,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("hive.hdfs.authentication.type", "KERBEROS") .put("hive.hdfs.impersonation.enabled", "true") - .build(); + .buildOrThrow(); HdfsAuthenticationConfig expected = new HdfsAuthenticationConfig() .setHdfsAuthenticationType(HdfsAuthenticationType.KERBEROS) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsKerberosConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsKerberosConfig.java index aa79d072723b..fb78242f91f2 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsKerberosConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestHdfsKerberosConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("hive.hdfs.trino.principal", "trino@EXAMPLE.COM") .put("hive.hdfs.trino.keytab", keytab.toString()) - .build(); + .buildOrThrow(); HdfsKerberosConfig expected = new HdfsKerberosConfig() .setHdfsTrinoPrincipal("trino@EXAMPLE.COM") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestMetastoreKerberosConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestMetastoreKerberosConfig.java index 20c4c5d0564c..0f1afc54f168 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestMetastoreKerberosConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/authentication/TestMetastoreKerberosConfig.java @@ -46,7 +46,7 @@ public void testExplicitPropertyMappings() .put("hive.metastore.service.principal", "hive/_HOST@EXAMPLE.COM") .put("hive.metastore.client.principal", "metastore@EXAMPLE.COM") .put("hive.metastore.client.keytab", clientKeytabFile.toString()) - .build(); + .buildOrThrow(); MetastoreKerberosConfig expected = new MetastoreKerberosConfig() .setHiveMetastoreServicePrincipal("hive/_HOST@EXAMPLE.COM") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/azure/TestHiveAzureConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/azure/TestHiveAzureConfig.java index e43fc2b5d3a3..7dc565ad120e 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/azure/TestHiveAzureConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/azure/TestHiveAzureConfig.java @@ -57,7 +57,7 @@ public void testExplicitPropertyMappings() .put("hive.azure.abfs.oauth.endpoint", "abfsoauthendpoint") .put("hive.azure.abfs.oauth.client-id", "abfsoauthclientid") .put("hive.azure.abfs.oauth.secret", "abfsoauthsecret") - .build(); + .buildOrThrow(); HiveAzureConfig expected = new HiveAzureConfig() .setWasbStorageAccount("testwasbstorage") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java index 4b3f881564c6..6307ea35db3c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java @@ -58,14 +58,14 @@ public HiveMinioDataLake(String bucketName, Map hiveHadoopFilesT .withEnvVars(ImmutableMap.builder() .put("MINIO_ACCESS_KEY", ACCESS_KEY) .put("MINIO_SECRET_KEY", SECRET_KEY) - .build()) + .buildOrThrow()) .build()); this.hiveHadoop = closer.register( HiveHadoop.builder() .withFilesToMount(ImmutableMap.builder() .put("hive_s3_insert_overwrite/hive-core-site.xml", "/etc/hadoop/conf/core-site.xml") .putAll(hiveHadoopFilesToMount) - .build()) + .buildOrThrow()) .withImage(hiveHadoopImage) .withNetwork(network) .build()); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/gcs/TestHiveGcsConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/gcs/TestHiveGcsConfig.java index e7938f6253a1..94ad826108a8 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/gcs/TestHiveGcsConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/gcs/TestHiveGcsConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("hive.gcs.json-key-file-path", jsonKeyFile.toString()) .put("hive.gcs.use-access-token", "true") - .build(); + .buildOrThrow(); HiveGcsConfig expected = new HiveGcsConfig() .setJsonKeyFilePath(jsonKeyFile.toString()) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreConfig.java index 3500eccd6db2..2c148f1ee2a8 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("hive.hide-delta-lake-tables", "true") - .build(); + .buildOrThrow(); MetastoreConfig expected = new MetastoreConfig() .setHideDeltaLakeTables(true); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreTypeConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreTypeConfig.java index 2a42e85f0c21..c2b4a46f590b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreTypeConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreTypeConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("hive.metastore", "foo") - .build(); + .buildOrThrow(); MetastoreTypeConfig expected = new MetastoreTypeConfig() .setMetastoreType("foo"); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreUtil.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreUtil.java index a7d3db77ba8e..f7158cd753af 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreUtil.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestMetastoreUtil.java @@ -181,7 +181,7 @@ public void testComputePartitionKeyFilter() .put(bucketColumnHandle(), Domain.create(ValueSet.of(INTEGER, 123L), false)) .put(dsColumn, dsDomain) .put(typeColumn, typeDomain) - .build()); + .buildOrThrow()); TupleDomain filter = computePartitionKeyFilter(partitionKeys, tupleDomain); assertThat(filter.getDomains()) @@ -189,7 +189,7 @@ public void testComputePartitionKeyFilter() .contains(ImmutableMap.builder() .put("ds", dsDomain) .put("type", typeDomain) - .build()); + .buildOrThrow()); } private static HiveColumnHandle partitionColumn(String name) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestRecordingHiveMetastore.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestRecordingHiveMetastore.java index 34c9a584f6f3..df1947db894d 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestRecordingHiveMetastore.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/TestRecordingHiveMetastore.java @@ -120,7 +120,7 @@ public class TestRecordingHiveMetastore private static final Domain PARTITION_COLUMN_EQUAL_DOMAIN = Domain.singleValue(createUnboundedVarcharType(), Slices.utf8Slice("value1")); private static final TupleDomain TUPLE_DOMAIN = TupleDomain.withColumnDomains(ImmutableMap.builder() .put(TABLE_COLUMN.getName(), PARTITION_COLUMN_EQUAL_DOMAIN) - .build()); + .buildOrThrow()); @Test public void testRecordingHiveMetastore() diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/alluxio/TestAlluxioHiveMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/alluxio/TestAlluxioHiveMetastoreConfig.java index a8903ba9f25b..a03963b08d4c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/alluxio/TestAlluxioHiveMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/alluxio/TestAlluxioHiveMetastoreConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMapping() { Map properties = new ImmutableMap.Builder() .put("hive.metastore.alluxio.master.address", "localhost:19998") - .build(); + .buildOrThrow(); AlluxioHiveMetastoreConfig expected = new AlluxioHiveMetastoreConfig() .setMasterAddress("localhost:19998"); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java index 11a11a3cdd65..75620f09ed0a 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java @@ -268,14 +268,14 @@ public void testGetPartitionNamesByParts() withColumnDomains(ImmutableMap.builder() .put(dateKeyColumn, Domain.create(ValueSet.ofRanges(Range.greaterThan(VARCHAR, utf8Slice("2020-10-01"))), false)) .put(keyColumn, Domain.create(ValueSet.of(VARCHAR, utf8Slice("val")), false)) - .build())); + .buildOrThrow())); TupleDomain withNoSingleValueFilter = computePartitionKeyFilter( partitionColumns, withColumnDomains(ImmutableMap.builder() .put(dateKeyColumn, Domain.create(ValueSet.ofRanges(Range.greaterThan(VARCHAR, utf8Slice("2020-10-01"))), false)) .put(keyColumn, Domain.create(ValueSet.ofRanges(Range.range(VARCHAR, utf8Slice("val1"), true, utf8Slice("val2"), true)), false)) - .build())); + .buildOrThrow())); assertEquals(stats.getGetPartitionNamesByParts().getTime().getAllTime().getCount(), 0.0); metastore.getPartitionNamesByFilter(IDENTITY, TEST_DATABASE, TEST_TABLE, partitionColumnNames, withNoFilter); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastoreConfig.java index e3d1e627d457..e6c4b13fc306 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastoreConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("hive.metastore-refresh-interval", "30m") .put("hive.metastore-cache-maximum-size", "5000") .put("hive.metastore-refresh-max-threads", "2500") - .build(); + .buildOrThrow(); CachingHiveMetastoreConfig expected = new CachingHiveMetastoreConfig() .setMetastoreCacheTtl(new Duration(2, TimeUnit.HOURS)) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/file/TestFileHiveMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/file/TestFileHiveMetastoreConfig.java index 640224fa2850..05537955d2de 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/file/TestFileHiveMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/file/TestFileHiveMetastoreConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMapping() .put("hive.metastore.catalog.dir", "some path") .put("hive.metastore.version-compatibility", "UNSAFE_ASSUME_COMPATIBILITY") .put("hive.metastore.user", "some user") - .build(); + .buildOrThrow(); FileHiveMetastoreConfig expected = new FileHiveMetastoreConfig() .setCatalogDirectory("some path") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestGlueHiveMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestGlueHiveMetastoreConfig.java index 3a1cd1b84661..ad3d1678e813 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestGlueHiveMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestGlueHiveMetastoreConfig.java @@ -68,7 +68,7 @@ public void testExplicitPropertyMapping() .put("hive.metastore.glue.assume-canonical-partition-keys", "true") .put("hive.metastore.glue.read-statistics-threads", "42") .put("hive.metastore.glue.write-statistics-threads", "43") - .build(); + .buildOrThrow(); GlueHiveMetastoreConfig expected = new GlueHiveMetastoreConfig() .setGlueRegion("us-east-1") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java index fc10ba851961..6fd3f32ebcbd 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java @@ -848,7 +848,7 @@ public void testStatisticsLargeNumberOfColumns() PartitionStatistics partitionStatistics = PartitionStatistics.builder() .setBasicStatistics(HIVE_BASIC_STATISTICS) - .setColumnStatistics(columnStatistics.build()).build(); + .setColumnStatistics(columnStatistics.buildOrThrow()).build(); doCreateEmptyTable(tableName, ORC, columns.build()); testUpdateTableStatistics(tableName, EMPTY_TABLE_STATISTICS, partitionStatistics); @@ -1031,7 +1031,7 @@ public void testInvalidColumnStatisticsMetadata() tableInput.setParameters(ImmutableMap.builder() .putAll(tableInput.getParameters()) .put("column_stats_bad_data", "bad data") - .build()); + .buildOrThrow()); getGlueClient().updateTable(new UpdateTableRequest() .withDatabaseName(tableName.getSchemaName()) .withTableInput(tableInput)); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java index cd0302eea866..008fc5e3bd2c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java @@ -478,7 +478,7 @@ private synchronized Map getPartitionStatistics(Str } result.put(partitionName, statistics); } - return result.build(); + return result.buildOrThrow(); } @Override diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestStaticMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestStaticMetastoreConfig.java index b685f7c1cdf6..c7e9b080d764 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestStaticMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestStaticMetastoreConfig.java @@ -41,7 +41,7 @@ public void testExplicitPropertyMappingsSingleMetastore() Map properties = new ImmutableMap.Builder() .put("hive.metastore.uri", "thrift://localhost:9083") .put("hive.metastore.username", "trino") - .build(); + .buildOrThrow(); StaticMetastoreConfig expected = new StaticMetastoreConfig() .setMetastoreUris("thrift://localhost:9083") @@ -58,7 +58,7 @@ public void testExplicitPropertyMappingsMultipleMetastores() Map properties = new ImmutableMap.Builder() .put("hive.metastore.uri", "thrift://localhost:9083,thrift://192.0.2.3:8932") .put("hive.metastore.username", "trino") - .build(); + .buildOrThrow(); StaticMetastoreConfig expected = new StaticMetastoreConfig() .setMetastoreUris("thrift://localhost:9083,thrift://192.0.2.3:8932") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreAuthenticationConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreAuthenticationConfig.java index f47127bca7ed..2da84c77db01 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreAuthenticationConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreAuthenticationConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("hive.metastore.authentication.type", "KERBEROS") - .build(); + .buildOrThrow(); ThriftMetastoreAuthenticationConfig expected = new ThriftMetastoreAuthenticationConfig() .setAuthenticationType(ThriftMetastoreAuthenticationType.KERBEROS); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreConfig.java index e30e9a26aea3..bc5364149a1a 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftMetastoreConfig.java @@ -83,7 +83,7 @@ public void testExplicitPropertyMappings() .put("hive.metastore.thrift.delete-files-on-drop", "true") .put("hive.metastore.thrift.txn-lock-max-wait", "5m") .put("hive.metastore.thrift.assume-canonical-partition-keys", "true") - .build(); + .buildOrThrow(); ThriftMetastoreConfig expected = new ThriftMetastoreConfig() .setMetastoreTimeout(new Duration(20, SECONDS)) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/orc/TestOrcReaderConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/orc/TestOrcReaderConfig.java index 178501954a9e..76228098dff2 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/orc/TestOrcReaderConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/orc/TestOrcReaderConfig.java @@ -54,7 +54,7 @@ public void testExplicitPropertyMappings() .put("hive.orc.max-read-block-size", "66kB") .put("hive.orc.lazy-read-small-ranges", "false") .put("hive.orc.nested-lazy", "false") - .build(); + .buildOrThrow(); OrcReaderConfig expected = new OrcReaderConfig() .setUseColumnNames(true) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/parquet/TestParquetReaderConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/parquet/TestParquetReaderConfig.java index 56631c7ec71f..9e34a3678caa 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/parquet/TestParquetReaderConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/parquet/TestParquetReaderConfig.java @@ -47,7 +47,7 @@ public void testExplicitPropertyMappings() .put("parquet.max-buffer-size", "1431kB") .put("parquet.max-merge-distance", "342kB") .put("parquet.use-column-index", "false") - .build(); + .buildOrThrow(); ParquetReaderConfig expected = new ParquetReaderConfig() .setIgnoreStatistics(true) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixConfig.java index 460986cc218f..6c28742941f1 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixConfig.java @@ -58,7 +58,7 @@ public void testExplicitPropertyMappings() .put("hive.cache.bookkeeper-port", "1234") .put("hive.cache.data-transfer-port", "1235") .put("hive.cache.start-server-on-coordinator", "true") - .build(); + .buildOrThrow(); RubixConfig expected = new RubixConfig() .setReadMode(RubixConfig.ReadMode.READ_THROUGH) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixEnabledConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixEnabledConfig.java index 32e1fecc48bb..0490a3267426 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixEnabledConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/rubix/TestRubixEnabledConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("hive.cache.enabled", "true") - .build(); + .buildOrThrow(); RubixEnabledConfig expected = new RubixEnabledConfig() .setCacheEnabled(true); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3Config.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3Config.java index 32abe9a15823..55b2cdd79a98 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3Config.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3Config.java @@ -110,7 +110,7 @@ public void testExplicitPropertyMappings() .put("hive.s3.requester-pays.enabled", "true") .put("hive.s3.streaming.enabled", "false") .put("hive.s3.streaming.part-size", "15MB") - .build(); + .buildOrThrow(); HiveS3Config expected = new HiveS3Config() .setS3AwsAccessKey("abc123") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3TypeConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3TypeConfig.java index 65dacdb4fe12..d78cf16b952c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3TypeConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestHiveS3TypeConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("hive.s3-file-system-type", "EMRFS") - .build(); + .buildOrThrow(); HiveS3TypeConfig expected = new HiveS3TypeConfig() .setS3FileSystemType(S3FileSystemType.EMRFS); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMapping.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMapping.java index 96b6425df8d6..daf4a601c643 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMapping.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMapping.java @@ -412,7 +412,7 @@ public HdfsContext getHdfsContext() ConnectorSession connectorSession = TestingConnectorSession.builder() .setIdentity(ConnectorIdentity.forUser(user) .withGroups(groups) - .withExtraCredentials(extraCredentials.build()) + .withExtraCredentials(extraCredentials.buildOrThrow()) .build()) .setPropertyMetadata(HIVE_SESSION_PROPERTIES.getSessionProperties()) .build(); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMappingConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMappingConfig.java index b492220d3d00..6adc46cdd0a7 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMappingConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3SecurityMappingConfig.java @@ -54,7 +54,7 @@ public void testExplicitPropertyMappingsWithFile() .put("hive.s3.security-mapping.kms-key-id-credential-name", "kms-key-id-credential-name") .put("hive.s3.security-mapping.refresh-period", "1s") .put("hive.s3.security-mapping.colon-replacement", "#") - .build(); + .buildOrThrow(); S3SecurityMappingConfig expected = new S3SecurityMappingConfig() .setConfigFilePath(securityMappingConfigFile.toString()) @@ -77,7 +77,7 @@ public void testExplicitPropertyMappingsWithUrl() .put("hive.s3.security-mapping.kms-key-id-credential-name", "kms-key-id-credential-name") .put("hive.s3.security-mapping.refresh-period", "1s") .put("hive.s3.security-mapping.colon-replacement", "#") - .build(); + .buildOrThrow(); S3SecurityMappingConfig expected = new S3SecurityMappingConfig() .setConfigFilePath("http://test:1234/example") diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacySecurityConfig.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacySecurityConfig.java index 436ed12f484a..5bee26961459 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacySecurityConfig.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacySecurityConfig.java @@ -48,7 +48,7 @@ public void testExplicitPropertyMappings() .put("hive.allow-comment-table", "true") .put("hive.allow-comment-column", "true") .put("hive.allow-rename-column", "true") - .build(); + .buildOrThrow(); LegacySecurityConfig expected = new LegacySecurityConfig() .setAllowAddColumn(true) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java index ef1a13a8cac4..9a0f02a0f8e8 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/util/TestHiveTypeTranslator.java @@ -64,7 +64,7 @@ public class TestHiveTypeTranslator .put(new ArrayType(TIMESTAMP_MILLIS), HiveType.valueOf("array")) .put(TESTING_TYPE_MANAGER.getType(mapType(BOOLEAN.getTypeSignature(), VARBINARY.getTypeSignature())), HiveType.valueOf("map")) .put(RowType.from(List.of(field("col0", INTEGER), field("col1", VARBINARY))), HiveType.valueOf("struct")) - .build(); + .buildOrThrow(); @Test public void testTypeTranslator() diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/ColumnIdentity.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/ColumnIdentity.java index 8a80ef5c7348..161120adf541 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/ColumnIdentity.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/ColumnIdentity.java @@ -64,8 +64,8 @@ public ColumnIdentity( childrenBuilder.put(child.getId(), child); childFieldIdToIndex.put(child.getId(), i); } - this.children = childrenBuilder.build(); - this.childFieldIdToIndex = childFieldIdToIndex.build(); + this.children = childrenBuilder.buildOrThrow(); + this.childFieldIdToIndex = childFieldIdToIndex.buildOrThrow(); } @JsonProperty diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/FilesTable.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/FilesTable.java index f6277196d0e7..27118a6269ce 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/FilesTable.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/FilesTable.java @@ -177,7 +177,7 @@ private static Map getIcebergIdToTypeMapping(Schema schema) for (Types.NestedField field : schema.columns()) { populateIcebergIdToTypeMapping(field, icebergIdToTypeMapping); } - return icebergIdToTypeMapping.build(); + return icebergIdToTypeMapping.buildOrThrow(); } private static void populateIcebergIdToTypeMapping(Types.NestedField field, ImmutableMap.Builder icebergIdToTypeMapping) diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergFileWriterFactory.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergFileWriterFactory.java index 435cdf7586fc..4fd1386c0095 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergFileWriterFactory.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergFileWriterFactory.java @@ -227,7 +227,7 @@ private IcebergFileWriter createOrcWriter( ImmutableMap.builder() .put(PRESTO_VERSION_NAME, nodeVersion.toString()) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) - .build(), + .buildOrThrow(), validationInputFactory, getOrcWriterValidateMode(session), orcWriterStats); diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java index 8fccd6ee8827..df3df3a508f6 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java @@ -387,7 +387,7 @@ public Map> listTableColumns(ConnectorSess // ignore table of unknown type } } - return columns.build(); + return columns.buildOrThrow(); } @Override @@ -771,7 +771,7 @@ private ConnectorTableMetadata getTableMetadata(ConnectorSession session, Schema properties.put(LOCATION_PROPERTY, icebergTable.location()); } - return new ConnectorTableMetadata(table, columns, properties.build(), getTableComment(icebergTable)); + return new ConnectorTableMetadata(table, columns, properties.buildOrThrow(), getTableComment(icebergTable)); } private List getColumnMetadatas(Table table) @@ -979,7 +979,7 @@ public Optional> applyProjecti } // Modify projections to refer to new variables - Map newVariables = newVariablesBuilder.build(); + Map newVariables = newVariablesBuilder.buildOrThrow(); List newProjections = projections.stream() .map(expression -> replaceWithNewVariables(expression, newVariables)) .collect(toImmutableList()); diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergOrcFileWriter.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergOrcFileWriter.java index 1b4a7ce48e51..7ae8b3bc8ec9 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergOrcFileWriter.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergOrcFileWriter.java @@ -128,10 +128,10 @@ private static Metrics computeMetrics(Schema icebergSchema, ColumnMetadata valueCounts = valueCountsBuilder.build(); - Map nullCounts = nullCountsBuilder.build(); - Map lowerBounds = lowerBoundsBuilder.build(); - Map upperBounds = upperBoundsBuilder.build(); + Map valueCounts = valueCountsBuilder.buildOrThrow(); + Map nullCounts = nullCountsBuilder.buildOrThrow(); + Map lowerBounds = lowerBoundsBuilder.buildOrThrow(); + Map upperBounds = upperBoundsBuilder.buildOrThrow(); return new Metrics( fileRowCount, null, // TODO: Add column size accounting to ORC column writers diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java index 42c80218a07e..e31fec31d64b 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java @@ -457,7 +457,7 @@ private static OrcColumn setMissingFieldIds(OrcColumn column, NameMapping nameMa return setMissingFieldIds(nestedColumn, nameMapping, nextQualifiedPath.build()); }) .collect(toImmutableList()), - attributes.build()); + attributes.buildOrThrow()); } /** @@ -491,7 +491,7 @@ private static Map mapIdsToOrcFileColumns(List co columnsById.put(Integer.parseInt(fieldId), column); } }); - return columnsById.build(); + return columnsById.buildOrThrow(); } private static Integer getIcebergFieldId(OrcColumn column) @@ -544,7 +544,7 @@ public IdBasedFieldMapperFactory(List columns) populateMapping(column.getColumnIdentity(), mapping); } - this.fieldNameToIdMappingForTableColumns = mapping.build(); + this.fieldNameToIdMappingForTableColumns = mapping.buildOrThrow(); } @Override @@ -768,7 +768,7 @@ public static ProjectedLayout createProjectedLayout(OrcColumn root, List getParquetTupleDomain(Map getIdentityPartitions(PartitionSpec p columns.put(field, i); } } - return columns.build(); + return columns.buildOrThrow(); } public static Map primitiveFieldTypes(Schema schema) @@ -351,7 +351,7 @@ public static Map> getPartitionKeys(FileScanTask scanT } }); - return partitionKeys.build(); + return partitionKeys.buildOrThrow(); } public static LocationProvider getLocationProvider(SchemaTableName schemaTableName, String tableLocation, Map storageProperties) @@ -395,6 +395,6 @@ public static Transaction newCreateTableTransaction(TrinoCatalog catalog, Connec propertiesBuilder.put(TABLE_COMMENT, tableMetadata.getComment().get()); } - return catalog.newCreateTableTransaction(session, schemaTableName, schema, partitionSpec, targetPath, propertiesBuilder.build()); + return catalog.newCreateTableTransaction(session, schemaTableName, schema, partitionSpec, targetPath, propertiesBuilder.buildOrThrow()); } } diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/Partition.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/Partition.java index 71f8d27e0cb7..b0f53ee87f93 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/Partition.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/Partition.java @@ -243,6 +243,6 @@ public static Map convertBounds(Map idToDetails = idToDetailsBuilder.build(); + Map idToDetails = idToDetailsBuilder.buildOrThrow(); TableScan tableScan = icebergTable.newScan() .filter(toIcebergExpression(intersection)) @@ -191,7 +191,7 @@ private TableStatistics makeTableStatistics(IcebergTableHandle tableHandle, Cons } columnHandleBuilder.put(columnHandle, columnBuilder.build()); } - return new TableStatistics(Estimate.of(recordCount), columnHandleBuilder.build()); + return new TableStatistics(Estimate.of(recordCount), columnHandleBuilder.buildOrThrow()); } private boolean dataFileMatches( diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TrinoHiveCatalog.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TrinoHiveCatalog.java index 5f4389c4f4e6..2cd715b0f55a 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TrinoHiveCatalog.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TrinoHiveCatalog.java @@ -367,7 +367,7 @@ public void createView(ConnectorSession session, SchemaTableName schemaViewName, .put(PRESTO_VERSION_NAME, trinoVersion) .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) .put(TABLE_COMMENT, PRESTO_VIEW_COMMENT) - .build(); + .buildOrThrow(); io.trino.plugin.hive.metastore.Table.Builder tableBuilder = io.trino.plugin.hive.metastore.Table.builder() .setDatabaseName(schemaViewName.getSchemaName()) @@ -461,7 +461,7 @@ public Map getViews(ConnectorSession s } } } - return views.build(); + return views.buildOrThrow(); } @Override @@ -543,7 +543,7 @@ public void createMaterializedView(ConnectorSession session, SchemaTableName sch .put(PRESTO_VIEW_FLAG, "true") .put(TRINO_CREATED_BY, TRINO_CREATED_BY_VALUE) .put(TABLE_COMMENT, ICEBERG_MATERIALIZED_VIEW_COMMENT) - .build(); + .buildOrThrow(); Column dummyColumn = new Column("dummy", HIVE_STRING, Optional.empty()); @@ -632,7 +632,7 @@ public Optional getMaterializedView(Connect .collect(toImmutableList()), definition.getComment(), materializedView.getOwner(), - properties.build())); + properties.buildOrThrow())); } @Override diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TypeConverter.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TypeConverter.java index 28d96abf17c2..4990ebd3d24e 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TypeConverter.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/TypeConverter.java @@ -224,7 +224,7 @@ private static List toOrcType(int nextFieldTypeIndex, org.apache.iceber attributes = ImmutableMap.builder() .putAll(attributes) .put(ICEBERG_LONG_TYPE, "TIME") - .build(); + .buildOrThrow(); return ImmutableList.of(new OrcType(OrcTypeKind.LONG, ImmutableList.of(), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), attributes)); case TIMESTAMP: OrcTypeKind timestampKind = ((Types.TimestampType) type).shouldAdjustToUTC() ? OrcTypeKind.TIMESTAMP_INSTANT : OrcTypeKind.TIMESTAMP; @@ -242,7 +242,7 @@ private static List toOrcType(int nextFieldTypeIndex, org.apache.iceber attributes = ImmutableMap.builder() .putAll(attributes) .put(ICEBERG_BINARY_TYPE, "UUID") - .build(); + .buildOrThrow(); return ImmutableList.of(new OrcType(OrcTypeKind.BINARY, ImmutableList.of(), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), attributes)); case STRUCT: return toOrcStructType(nextFieldTypeIndex, (Types.StructType) type, attributes); @@ -266,7 +266,7 @@ private static List toOrcStructType(int nextFieldTypeIndex, Types.Struc Map fieldAttributes = ImmutableMap.builder() .put(ORC_ICEBERG_ID_KEY, Integer.toString(field.fieldId())) .put(ORC_ICEBERG_REQUIRED_KEY, Boolean.toString(field.isRequired())) - .build(); + .buildOrThrow(); List fieldOrcTypes = toOrcType(nextFieldTypeIndex, field.type(), fieldAttributes); fieldTypesList.add(fieldOrcTypes); nextFieldTypeIndex += fieldOrcTypes.size(); @@ -292,7 +292,7 @@ private static List toOrcListType(int nextFieldTypeIndex, Types.ListTyp Map elementAttributes = ImmutableMap.builder() .put(ORC_ICEBERG_ID_KEY, Integer.toString(listType.elementId())) .put(ORC_ICEBERG_REQUIRED_KEY, Boolean.toString(listType.isElementRequired())) - .build(); + .buildOrThrow(); List itemTypes = toOrcType(nextFieldTypeIndex, listType.elementType(), elementAttributes); List orcTypes = new ArrayList<>(); @@ -315,12 +315,12 @@ private static List toOrcMapType(int nextFieldTypeIndex, Types.MapType Map keyAttributes = ImmutableMap.builder() .put(ORC_ICEBERG_ID_KEY, Integer.toString(mapType.keyId())) .put(ORC_ICEBERG_REQUIRED_KEY, Boolean.toString(true)) - .build(); + .buildOrThrow(); List keyTypes = toOrcType(nextFieldTypeIndex, mapType.keyType(), keyAttributes); Map valueAttributes = ImmutableMap.builder() .put(ORC_ICEBERG_ID_KEY, Integer.toString(mapType.valueId())) .put(ORC_ICEBERG_REQUIRED_KEY, Boolean.toString(mapType.isValueRequired())) - .build(); + .buildOrThrow(); List valueTypes = toOrcType(nextFieldTypeIndex + keyTypes.size(), mapType.valueType(), valueAttributes); List orcTypes = new ArrayList<>(); diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/util/PrimitiveTypeMapBuilder.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/util/PrimitiveTypeMapBuilder.java index 2363e5e37584..5e2a4034c4f2 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/util/PrimitiveTypeMapBuilder.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/util/PrimitiveTypeMapBuilder.java @@ -45,7 +45,7 @@ private Map, Type> buildTypeMap(List types, List colu for (int i = 0; i < types.size(); i++) { visitType(types.get(i), makeCompatibleName(columnNames.get(i)), ImmutableList.of()); } - return builder.build(); + return builder.buildOrThrow(); } private void visitType(Type type, String name, List parent) diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConfig.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConfig.java index 23bd92ef1daf..37ad431f1cb2 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConfig.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConfig.java @@ -60,7 +60,7 @@ public void testExplicitPropertyMappings() .put("iceberg.dynamic-filtering.wait-timeout", "1h") .put("iceberg.table-statistics-enabled", "false") .put("iceberg.projection-pushdown-enabled", "false") - .build(); + .buildOrThrow(); IcebergConfig expected = new IcebergConfig() .setFileFormat(PARQUET) diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConnectorFactory.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConnectorFactory.java index b84e3a3b8ae9..444eb687f059 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConnectorFactory.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergConnectorFactory.java @@ -29,7 +29,7 @@ public void testBasicConfig() { Map config = ImmutableMap.builder() .put("hive.metastore.uri", "thrift://localhost:1234") - .build(); + .buildOrThrow(); createConnector(config); } @@ -39,7 +39,7 @@ public void testCachingHiveMetastore() Map config = ImmutableMap.builder() .put("hive.metastore.uri", "thrift://localhost:1234") .put("hive.metastore-cache-ttl", "5m") - .build(); + .buildOrThrow(); assertThatThrownBy(() -> createConnector(config)) .hasMessageContaining("Hive metastore caching must not be enabled for Iceberg"); } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergPlugin.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergPlugin.java index b63b3bb238d0..860f72712838 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergPlugin.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergPlugin.java @@ -123,7 +123,7 @@ public void testAllowAllAccessControl() .put("iceberg.catalog.type", "HIVE_METASTORE") .put("hive.metastore.uri", "thrift://foo:1234") .put("iceberg.security", "allow-all") - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -139,7 +139,7 @@ public void testReadOnlyAllAccessControl() .put("iceberg.catalog.type", "HIVE_METASTORE") .put("hive.metastore.uri", "thrift://foo:1234") .put("iceberg.security", "read-only") - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } @@ -155,7 +155,7 @@ public void testSystemAccessControl() .put("iceberg.catalog.type", "HIVE_METASTORE") .put("hive.metastore.uri", "thrift://foo:1234") .put("iceberg.security", "system") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertThatThrownBy(connector::getAccessControl).isInstanceOf(UnsupportedOperationException.class); connector.shutdown(); @@ -177,7 +177,7 @@ public void testFileBasedAccessControl() .put("hive.metastore.uri", "thrift://foo:1234") .put("iceberg.security", "file") .put("security.config-file", tempFile.getAbsolutePath()) - .build(), + .buildOrThrow(), new TestingConnectorContext()) .shutdown(); } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergSecurityConfig.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergSecurityConfig.java index c537690837b0..f6c11f7ebb44 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergSecurityConfig.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergSecurityConfig.java @@ -38,7 +38,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("iceberg.security", "read-only") - .build(); + .buildOrThrow(); IcebergSecurityConfig expected = new IcebergSecurityConfig() .setSecuritySystem(READ_ONLY); diff --git a/plugin/trino-jmx/src/main/java/io/trino/plugin/jmx/JmxRecordSetProvider.java b/plugin/trino-jmx/src/main/java/io/trino/plugin/jmx/JmxRecordSetProvider.java index e12307d8b444..1fd77feaf2b8 100644 --- a/plugin/trino-jmx/src/main/java/io/trino/plugin/jmx/JmxRecordSetProvider.java +++ b/plugin/trino-jmx/src/main/java/io/trino/plugin/jmx/JmxRecordSetProvider.java @@ -220,7 +220,7 @@ private ImmutableMap> getAttributes(Set uniqueC for (Attribute attribute : mbeanServer.getAttributes(objectName, columnNamesArray).asList()) { attributes.put(attribute.getName(), Optional.ofNullable(attribute.getValue())); } - return attributes.build(); + return attributes.buildOrThrow(); } private List> getLiveRows(JmxTableHandle tableHandle, List columns) diff --git a/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/MetadataUtil.java b/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/MetadataUtil.java index c3d2183ae676..fa52b4faa78b 100644 --- a/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/MetadataUtil.java +++ b/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/MetadataUtil.java @@ -52,7 +52,7 @@ public static final class TestingTypeDeserializer private final Map types = ImmutableMap.builder() .put(StandardTypes.BIGINT, BIGINT) .put(StandardTypes.VARCHAR, createUnboundedVarcharType()) // with max value length in signature - .build(); + .buildOrThrow(); public TestingTypeDeserializer() { diff --git a/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/TestJmxConnectorConfig.java b/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/TestJmxConnectorConfig.java index 6f1f3ed4cf67..61abe8f85277 100644 --- a/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/TestJmxConnectorConfig.java +++ b/plugin/trino-jmx/src/test/java/io/trino/plugin/jmx/TestJmxConnectorConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("jmx.dump-tables", "table1,table\\,with\\,commas") .put("jmx.dump-period", "1s") .put("jmx.max-entries", "100") - .build(); + .buildOrThrow(); JmxConnectorConfig expected = new JmxConnectorConfig() .setDumpTables(ImmutableSet.of("table1", "table,with,commas")) diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaFilterManager.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaFilterManager.java index d77e441074b7..ba5a7fe20785 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaFilterManager.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaFilterManager.java @@ -185,7 +185,7 @@ private static Map overridePartitionBeginOffsets(Map newOffset = overrideFunction.apply(partition); partitionFilteredBeginOffsetsBuilder.put(partition, newOffset.map(index -> Long.max(partitionIndex, index)).orElse(partitionIndex)); }); - return partitionFilteredBeginOffsetsBuilder.build(); + return partitionFilteredBeginOffsetsBuilder.buildOrThrow(); } private static Map overridePartitionEndOffsets(Map partitionEndOffsets, @@ -196,7 +196,7 @@ private static Map overridePartitionEndOffsets(Map newOffset = overrideFunction.apply(partition); partitionFilteredEndOffsetsBuilder.put(partition, newOffset.map(index -> Long.min(partitionIndex, index)).orElse(partitionIndex)); }); - return partitionFilteredEndOffsetsBuilder.build(); + return partitionFilteredEndOffsetsBuilder.buildOrThrow(); } @VisibleForTesting diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaInternalFieldManager.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaInternalFieldManager.java index 3de5108aab8f..5f8abc09c20b 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaInternalFieldManager.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaInternalFieldManager.java @@ -179,7 +179,7 @@ public KafkaInternalFieldManager(TypeManager typeManager) OFFSET_TIMESTAMP_FIELD, "Message timestamp", TIMESTAMP_MILLIS)) - .build(); + .buildOrThrow(); } /** diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaMetadata.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaMetadata.java index 9362deb41032..da810eef590e 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaMetadata.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaMetadata.java @@ -158,7 +158,7 @@ private Map getColumnHandles(ConnectorSession session, Sch columnHandles.put(kafkaInternalField.getColumnName(), kafkaInternalField.getColumnHandle(index.getAndIncrement(), hideInternalColumns)); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -184,7 +184,7 @@ public Map> listTableColumns(ConnectorSess // information_schema table or a system table } } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaRecordSetProvider.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaRecordSetProvider.java index 48584a91970f..74f8a28945eb 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaRecordSetProvider.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/KafkaRecordSetProvider.java @@ -80,6 +80,6 @@ private static Map getDecoderParameters(Optional dataSch { ImmutableMap.Builder parameters = ImmutableMap.builder(); dataSchema.ifPresent(schema -> parameters.put("dataSchema", schema)); - return parameters.build(); + return parameters.buildOrThrow(); } } diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/schema/file/FileTableDescriptionSupplier.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/schema/file/FileTableDescriptionSupplier.java index cd68b9223ad3..9df95426d141 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/schema/file/FileTableDescriptionSupplier.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/schema/file/FileTableDescriptionSupplier.java @@ -90,7 +90,7 @@ private Map populateTables() } } - Map tableDefinitions = builder.build(); + Map tableDefinitions = builder.buildOrThrow(); log.debug("Loaded Table definitions: %s", tableDefinitions.keySet()); @@ -121,7 +121,7 @@ private Map populateTables() } } - return builder.build(); + return builder.buildOrThrow(); } catch (IOException e) { log.warn(e, "Error: "); diff --git a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/security/KafkaSslConfig.java b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/security/KafkaSslConfig.java index af379ea624ce..c196582a6189 100644 --- a/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/security/KafkaSslConfig.java +++ b/plugin/trino-kafka/src/main/java/io/trino/plugin/kafka/security/KafkaSslConfig.java @@ -171,7 +171,7 @@ public Map getKafkaClientProperties() getKeyPassword().ifPresent(v -> properties.put(SSL_KEY_PASSWORD_CONFIG, v)); getEndpointIdentificationAlgorithm().ifPresent(v -> properties.put(SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, v.getValue())); - return properties.build(); + return properties.buildOrThrow(); } @PostConstruct diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/KafkaQueryRunner.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/KafkaQueryRunner.java index 21fcc4ec0c33..940f8f8de1b2 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/KafkaQueryRunner.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/KafkaQueryRunner.java @@ -120,7 +120,7 @@ public void preInit(DistributedQueryRunner queryRunner) .putAll(extraTopicDescription) .putAll(tpchTopicDescriptions) .putAll(testTopicDescriptions.build()) - .build(); + .buildOrThrow(); setExtension(combine( extension, conditionalModule( @@ -196,7 +196,7 @@ private static Map createTpchTopicDescri topicDescriptions.put(loadTpchTopicDescription(topicDescriptionJsonCodec, tpchTable.toString(), tpchTable)); } - return topicDescriptions.build(); + return topicDescriptions.buildOrThrow(); } public static void main(String[] args) diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConfig.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConfig.java index ffa1e0ec83ed..ad35c221b1d5 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConfig.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaConfig.java @@ -49,7 +49,7 @@ public void testExplicitPropertyMappings() .put("kafka.hide-internal-columns", "false") .put("kafka.messages-per-split", "1") .put("kafka.timestamp-upper-bound-force-push-down-enabled", "true") - .build(); + .buildOrThrow(); KafkaConfig expected = new KafkaConfig() .setDefaultSchema("kafka") diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationPushDown.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationPushDown.java index e40f7a5b3286..faeeea04fbb8 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationPushDown.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationPushDown.java @@ -74,10 +74,10 @@ protected QueryRunner createQueryRunner() .put(createEmptyTopicDescription(topicNameOffset, new SchemaTableName("default", topicNameOffset))) .put(createEmptyTopicDescription(topicNameCreateTime, new SchemaTableName("default", topicNameCreateTime))) .put(createEmptyTopicDescription(topicNameLogAppend, new SchemaTableName("default", topicNameLogAppend))) - .build()) + .buildOrThrow()) .setExtraKafkaProperties(ImmutableMap.builder() .put("kafka.messages-per-split", "100") - .build()) + .buildOrThrow()) .build(); testingKafka.createTopicWithConfig(2, 1, topicNamePartition, false); testingKafka.createTopicWithConfig(2, 1, topicNameOffset, false); diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationSmokeTest.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationSmokeTest.java index bb39bd34f1b6..738f7901a393 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationSmokeTest.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaIntegrationSmokeTest.java @@ -102,13 +102,13 @@ protected QueryRunner createQueryRunner() .put(new SchemaTableName("default", headersTopic), new KafkaTopicDescription(headersTopic, Optional.empty(), headersTopic, Optional.empty(), Optional.empty())) .putAll(createJsonDateTimeTestTopic()) - .build(); + .buildOrThrow(); QueryRunner queryRunner = KafkaQueryRunner.builder(testingKafka) .setTables(TpchTable.getTables()) .setExtraTopicDescription(ImmutableMap.builder() .putAll(extraTopicDescriptions) - .build()) + .buildOrThrow()) .build(); return queryRunner; @@ -191,7 +191,7 @@ private Map getProducerProperties() .put(ACKS_CONFIG, "all") .put(KEY_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName()) - .build(); + .buildOrThrow(); } @Test diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaPlugin.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaPlugin.java index 18dc2b8b24ec..2f1f862cf929 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaPlugin.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaPlugin.java @@ -45,7 +45,7 @@ public void testSpinup() ImmutableMap.builder() .put("kafka.table-names", "test") .put("kafka.nodes", "localhost:9092") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertNotNull(connector); connector.shutdown(); @@ -81,7 +81,7 @@ public void testSslSpinup() .put("kafka.ssl.truststore.location", truststorePath.toString()) .put("kafka.ssl.truststore.password", "truststore-password") .put("kafka.ssl.endpoint-identification-algorithm", "https") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertNotNull(connector); connector.shutdown(); @@ -112,7 +112,7 @@ public void testSslKeystoreMissingFileSpindown() .put("kafka.ssl.truststore.location", truststorePath.toString()) .put("kafka.ssl.truststore.password", "truststore-password") .put("kafka.ssl.endpoint-identification-algorithm", "https") - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("Error: Invalid configuration property kafka.ssl.keystore.location: file does not exist: /not/a/real/path"); } @@ -142,7 +142,7 @@ public void testSslTruststoreMissingFileSpindown() .put("kafka.ssl.truststore.location", "/not/a/real/path") .put("kafka.ssl.truststore.password", "truststore-password") .put("kafka.ssl.endpoint-identification-algorithm", "https") - .build(), + .buildOrThrow(), new TestingConnectorContext())) .hasMessageContaining("Error: Invalid configuration property kafka.ssl.truststore.location: file does not exist: /not/a/real/path"); } diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSecurityConfig.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSecurityConfig.java index c4ba1284b19d..a630a9a6e85b 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSecurityConfig.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSecurityConfig.java @@ -43,7 +43,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("kafka.security-protocol", "SSL") - .build(); + .buildOrThrow(); KafkaSecurityConfig expected = new KafkaSecurityConfig() .setSecurityProtocol(SSL); diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSslConfig.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSslConfig.java index d8cf8e912dda..5bf0590463ec 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSslConfig.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestKafkaSslConfig.java @@ -80,7 +80,7 @@ public void testExplicitPropertyMappings() .put("kafka.ssl.truststore.type", "PKCS12") .put("kafka.ssl.key.password", "key-password") .put("kafka.ssl.endpoint-identification-algorithm", "disabled") - .build(); + .buildOrThrow(); KafkaSslConfig expected = new KafkaSslConfig() .setKeystoreLocation(keystorePath.toString()) .setKeystorePassword("keystore-password") diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestMinimalFunctionality.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestMinimalFunctionality.java index b61de8371e79..c790a2c04fb7 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestMinimalFunctionality.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/TestMinimalFunctionality.java @@ -44,10 +44,10 @@ protected QueryRunner createQueryRunner() QueryRunner queryRunner = KafkaQueryRunner.builder(testingKafka) .setExtraTopicDescription(ImmutableMap.builder() .put(createEmptyTopicDescription(topicName, new SchemaTableName("default", topicName))) - .build()) + .buildOrThrow()) .setExtraKafkaProperties(ImmutableMap.builder() .put("kafka.messages-per-split", "100") - .build()) + .buildOrThrow()) .build(); return queryRunner; } diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroConfluentRowDecoder.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroConfluentRowDecoder.java index 922ba823c1db..6829c6387767 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroConfluentRowDecoder.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroConfluentRowDecoder.java @@ -156,7 +156,7 @@ private static RowDecoder getRowDecoder(SchemaRegistryClient schemaRegistryClien { ImmutableMap decoderParams = ImmutableMap.builder() .put(DATA_SCHEMA, schema.toString()) - .build(); + .buildOrThrow(); return getAvroRowDecoderyFactory(schemaRegistryClient).create(decoderParams, columnHandles); } diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroSchemaConverter.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroSchemaConverter.java index 06acd92e6c84..715171842a7b 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroSchemaConverter.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestAvroSchemaConverter.java @@ -126,7 +126,7 @@ public void testTypesWithDefaults() .name("map_col").type().map().values().intType().mapDefault(ImmutableMap.builder() .put("one", 1) .put("two", 2) - .build()) + .buildOrThrow()) .name("record_col").type().record("record_col") .fields() .name("nested_list").type().array().items().map().values().stringType().noDefault() @@ -140,15 +140,15 @@ public void testTypesWithDefaults() ImmutableMap.builder() .put("key", "value") .put("key1", "value1") - .build(), + .buildOrThrow(), ImmutableMap.builder() .put("key2", "value2") .put("key3", "value3") - .build())) + .buildOrThrow())) .set("nested_map", ImmutableMap.>builder() .put("key1", Arrays.asList("one", "two", "three")) .put("key2", Arrays.asList("four", "two", "three")) - .build()) + .buildOrThrow()) .build()) .endRecord(); AvroSchemaConverter avroSchemaConverter = new AvroSchemaConverter(new TestingTypeManager(), IGNORE); diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestConfluentSchemaRegistryConfig.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestConfluentSchemaRegistryConfig.java index 81c9bf59a82e..7c8325b75202 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestConfluentSchemaRegistryConfig.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestConfluentSchemaRegistryConfig.java @@ -46,7 +46,7 @@ public void testExplicitPropertyMappings() .put("kafka.confluent-schema-registry-client-cache-size", "1500") .put("kafka.empty-field-strategy", "ADD_DUMMY") .put("kafka.confluent-subjects-cache-refresh-interval", "2s") - .build(); + .buildOrThrow(); ConfluentSchemaRegistryConfig expected = new ConfluentSchemaRegistryConfig() .setConfluentSchemaRegistryUrls("http://schema-registry-a:8081, http://schema-registry-b:8081") diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestKafkaWithConfluentSchemaRegistryMinimalFunctionality.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestKafkaWithConfluentSchemaRegistryMinimalFunctionality.java index 3a11ee036b7c..a6b9c1ba9347 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestKafkaWithConfluentSchemaRegistryMinimalFunctionality.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/confluent/TestKafkaWithConfluentSchemaRegistryMinimalFunctionality.java @@ -84,7 +84,7 @@ protected QueryRunner createQueryRunner() return KafkaWithConfluentSchemaRegistryQueryRunner.builder(testingKafka) .setExtraKafkaProperties(ImmutableMap.builder() .put("kafka.confluent-subjects-cache-refresh-interval", "1ms") - .build()) + .buildOrThrow()) .build(); } @@ -100,7 +100,7 @@ public void testBasicTopic() schemaRegistryAwareProducer(testingKafka) .put(KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) - .build()); + .buildOrThrow()); } @Test @@ -115,7 +115,7 @@ public void testTopicWithKeySubject() schemaRegistryAwareProducer(testingKafka) .put(KEY_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) - .build()); + .buildOrThrow()); } @Test @@ -131,7 +131,7 @@ public void testTopicWithRecordNameStrategy() .put(KEY_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SUBJECT_NAME_STRATEGY, RecordNameStrategy.class.getName()) - .build()); + .buildOrThrow()); } @Test @@ -147,7 +147,7 @@ public void testTopicWithTopicRecordNameStrategy() .put(KEY_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SUBJECT_NAME_STRATEGY, TopicRecordNameStrategy.class.getName()) - .build()); + .buildOrThrow()); } @Test @@ -163,7 +163,7 @@ public void testUnsupportedInsert() schemaRegistryAwareProducer(testingKafka) .put(KEY_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) - .build()); + .buildOrThrow()); waitUntilTableExists(topicName); @@ -184,7 +184,7 @@ public void testUnsupportedFormat() schemaRegistryAwareProducer(testingKafka) .put(KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaJsonSchemaSerializer.class.getName()) - .build()); + .buildOrThrow()); String errorMessage = "Not supported schema: JSON"; assertEventually( diff --git a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/file/TestFileTableDescriptionSupplierConfig.java b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/file/TestFileTableDescriptionSupplierConfig.java index 2a385a48fdb3..59ec69afee81 100644 --- a/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/file/TestFileTableDescriptionSupplierConfig.java +++ b/plugin/trino-kafka/src/test/java/io/trino/plugin/kafka/schema/file/TestFileTableDescriptionSupplierConfig.java @@ -39,7 +39,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("kafka.table-description-dir", "/var/lib/kafka") .put("kafka.table-names", "table1, table2, table3") - .build(); + .buildOrThrow(); FileTableDescriptionSupplierConfig expected = new FileTableDescriptionSupplierConfig() .setTableDescriptionDir(new File("/var/lib/kafka")) diff --git a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisMetadata.java b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisMetadata.java index 4a03c8286bf8..f265d38a3cb3 100644 --- a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisMetadata.java +++ b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisMetadata.java @@ -133,7 +133,7 @@ public Map getColumnHandles(ConnectorSession connectorSess columnHandles.put(kinesisInternalFieldDescription.getColumnName(), kinesisInternalFieldDescription.getColumnHandle(index++, isHideInternalColumns)); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -164,7 +164,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } private static String getDataFormat(KinesisStreamFieldGroup fieldGroup) diff --git a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisTableDescriptionSupplier.java b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisTableDescriptionSupplier.java index 9f6c57e71300..b891aedca52b 100644 --- a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisTableDescriptionSupplier.java +++ b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/KinesisTableDescriptionSupplier.java @@ -85,7 +85,7 @@ public Map getTablesFromPath() } } - Map tableDefinitions = builder.build(); + Map tableDefinitions = builder.buildOrThrow(); log.debug("Loaded table definitions: %s", tableDefinitions.keySet()); return tableDefinitions; diff --git a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/s3config/S3TableConfigClient.java b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/s3config/S3TableConfigClient.java index cff98e93cec6..f3bae26d13fd 100644 --- a/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/s3config/S3TableConfigClient.java +++ b/plugin/trino-kinesis/src/main/java/io/trino/plugin/kinesis/s3config/S3TableConfigClient.java @@ -125,7 +125,7 @@ public Map getTablesFromS3() for (KinesisStreamDescription stream : streamValues) { builder.put(new SchemaTableName(stream.getSchemaName(), stream.getTableName()), stream); } - return builder.build(); + return builder.buildOrThrow(); } @Override diff --git a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisConfig.java b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisConfig.java index 7315bbf97325..e16028b7e092 100644 --- a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisConfig.java +++ b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisConfig.java @@ -71,7 +71,7 @@ public void testExplicitPropertyMappings() .put("kinesis.dynamo-write-capacity", "20") .put("kinesis.checkpoint-logical-name", "process") .put("kinesis.iterator-number", "1") - .build(); + .buildOrThrow(); KinesisConfig expected = new KinesisConfig() .setTableDescriptionLocation("/var/lib/kinesis") diff --git a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisPlugin.java b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisPlugin.java index 61bda4d328ac..68c1b73fba7c 100644 --- a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisPlugin.java +++ b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisPlugin.java @@ -50,7 +50,7 @@ public void testCreateConnector() .put("kinesis.hide-internal-columns", "false") .put("kinesis.access-key", TestUtils.noneToBlank(accessKey)) .put("kinesis.secret-key", TestUtils.noneToBlank(secretKey)) - .build(), new TestingConnectorContext()); + .buildOrThrow(), new TestingConnectorContext()); assertNotNull(c); // Verify that the key objects have been created on the connector diff --git a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisTableDescriptionSupplier.java b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisTableDescriptionSupplier.java index 9b2101561578..525c0761a1f1 100644 --- a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisTableDescriptionSupplier.java +++ b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/TestKinesisTableDescriptionSupplier.java @@ -45,7 +45,7 @@ public void start() .put("kinesis.table-description-location", "etc/kinesis") .put("kinesis.default-schema", "kinesis") .put("kinesis.hide-internal-columns", "true") - .build(); + .buildOrThrow(); KinesisTestClientManager kinesisTestClientManager = new KinesisTestClientManager(); MockKinesisClient mockClient = (MockKinesisClient) kinesisTestClientManager.getClient(); diff --git a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/s3config/TestS3TableConfigClient.java b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/s3config/TestS3TableConfigClient.java index e06298a96c95..b235e710c1ff 100644 --- a/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/s3config/TestS3TableConfigClient.java +++ b/plugin/trino-kinesis/src/test/java/io/trino/plugin/kinesis/s3config/TestS3TableConfigClient.java @@ -94,7 +94,7 @@ public void testTableReading(String tableDescriptionS3, String accessKey, String .put("kinesis.hide-internal-columns", "false") .put("kinesis.access-key", TestUtils.noneToBlank(accessKey)) .put("kinesis.secret-key", TestUtils.noneToBlank(secretKey)) - .build(); + .buildOrThrow(); KinesisPlugin kinesisPlugin = new KinesisPlugin(); KinesisConnector kinesisConnector = TestUtils.createConnector(kinesisPlugin, properties, false); diff --git a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java index 282455e21b63..04870ebce1c3 100755 --- a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java +++ b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java @@ -118,7 +118,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } private ColumnMetadata getColumnMetadata(ColumnSchema column) @@ -185,7 +185,7 @@ public Map getColumnHandles(ConnectorSession session, Conn columnHandles.put(name, columnHandle); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override diff --git a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduRecordSet.java b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduRecordSet.java index f688cb0c4034..cc686497c8c6 100755 --- a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduRecordSet.java +++ b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduRecordSet.java @@ -67,7 +67,7 @@ public RecordCursor cursor() } } - return new KuduRecordCursor(scanner, getTable(), getColumnTypes(), builder.build()); + return new KuduRecordCursor(scanner, getTable(), getColumnTypes(), builder.buildOrThrow()); } KuduTable getTable() diff --git a/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileMetadata.java b/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileMetadata.java index 6f4ff95056e9..7d757e3eb2c2 100644 --- a/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileMetadata.java +++ b/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileMetadata.java @@ -102,7 +102,7 @@ private Map getColumnHandles(LocalFileTableHandle tableHan } columnHandles.put(column.getName(), new LocalFileColumnHandle(column.getName(), column.getType(), ordinalPosition)); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -122,7 +122,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, localFileTables.getColumns(tableHandle)); } } - return columns.build(); + return columns.buildOrThrow(); } private List listTables(ConnectorSession session, SchemaTablePrefix prefix) diff --git a/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileTables.java b/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileTables.java index caa33d90852d..41e510177e47 100644 --- a/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileTables.java +++ b/plugin/trino-local-file/src/main/java/io/trino/plugin/localfile/LocalFileTables.java @@ -74,9 +74,9 @@ public LocalFileTables(LocalFileConfig config) dataLocationBuilder.put(table, dataLocation); } - tables = tablesBuilder.build(); - tableColumns = tableColumnsBuilder.build(); - tableDataLocations = dataLocationBuilder.build(); + tables = tablesBuilder.buildOrThrow(); + tableColumns = tableColumnsBuilder.buildOrThrow(); + tableDataLocations = dataLocationBuilder.buildOrThrow(); cachedFiles = CacheBuilder.newBuilder() .expireAfterWrite(10, SECONDS) diff --git a/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/MetadataUtil.java b/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/MetadataUtil.java index d1b5a7d554c4..3108d0b00f72 100644 --- a/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/MetadataUtil.java +++ b/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/MetadataUtil.java @@ -59,7 +59,7 @@ public static final class TestingTypeDeserializer .put(createTimestampWithTimeZoneType(3).getTypeId(), createTimestampWithTimeZoneType(3)) .put(DATE.getTypeId(), DATE) .put(VARCHAR.getTypeId(), createUnboundedVarcharType()) - .build(); + .buildOrThrow(); public TestingTypeDeserializer() { diff --git a/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/TestLocalFileConfig.java b/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/TestLocalFileConfig.java index 0bf29a470bc9..bee6ca823798 100644 --- a/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/TestLocalFileConfig.java +++ b/plugin/trino-local-file/src/test/java/io/trino/plugin/localfile/TestLocalFileConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("trino-logs.http-request-log.location", httpRequestLogFile.toString()) .put("trino-logs.http-request-log.pattern", "bar") - .build(); + .buildOrThrow(); LocalFileConfig expected = new LocalFileConfig() .setHttpRequestLogLocation(httpRequestLogFile.toString()) 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 859b0c77b0b6..b38a4d753c1a 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 @@ -74,7 +74,7 @@ protected QueryRunner createQueryRunner() .put("dynamic-filtering.large-partitioned.range-row-limit-per-driver", "100000") // disable semi join to inner join rewrite to test semi join operators explicitly .put("optimizer.rewrite-filtering-semi-join-to-inner-join", "false") - .build(), + .buildOrThrow(), ImmutableSet.>builder() .addAll(REQUIRED_TPCH_TABLES) .add(TpchTable.PART) diff --git a/plugin/trino-memsql/src/test/java/io/trino/plugin/memsql/TestMemSqlConfig.java b/plugin/trino-memsql/src/test/java/io/trino/plugin/memsql/TestMemSqlConfig.java index 618f1ac4ba71..848c6b17ebf8 100644 --- a/plugin/trino-memsql/src/test/java/io/trino/plugin/memsql/TestMemSqlConfig.java +++ b/plugin/trino-memsql/src/test/java/io/trino/plugin/memsql/TestMemSqlConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("memsql.auto-reconnect", "false") .put("memsql.connection-timeout", "4s") - .build(); + .buildOrThrow(); MemSqlConfig expected = new MemSqlConfig() .setAutoReconnect(false) diff --git a/plugin/trino-ml/src/main/java/io/trino/plugin/ml/StringClassifierAdapter.java b/plugin/trino-ml/src/main/java/io/trino/plugin/ml/StringClassifierAdapter.java index ba481f2fe7b1..15ee8151c91e 100644 --- a/plugin/trino-ml/src/main/java/io/trino/plugin/ml/StringClassifierAdapter.java +++ b/plugin/trino-ml/src/main/java/io/trino/plugin/ml/StringClassifierAdapter.java @@ -89,7 +89,7 @@ public static StringClassifierAdapter deserialize(byte[] data) builder.put(key, value); } - return new StringClassifierAdapter((Classifier) classifier, builder.build()); + return new StringClassifierAdapter((Classifier) classifier, builder.buildOrThrow()); } @Override diff --git a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java index 45636d30ab2a..d0a3d1fe041f 100644 --- a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java +++ b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java @@ -121,7 +121,7 @@ public Map getColumnHandles(ConnectorSession session, Conn for (MongoColumnHandle columnHandle : columns) { columnHandles.put(columnHandle.getName(), columnHandle); } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -137,7 +137,7 @@ public Map> listTableColumns(ConnectorSess // table disappeared during listing operation } } - return columns.build(); + return columns.buildOrThrow(); } private List listTables(ConnectorSession session, SchemaTablePrefix prefix) diff --git a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java index c5de9fe2a8fc..54dbfae49f7c 100644 --- a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java +++ b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java @@ -701,7 +701,7 @@ private boolean isView(String schemaName, String tableName) .put("listCollections", 1.0) .put("filter", documentOf("name", tableName)) .put("nameOnly", true) - .build()); + .buildOrThrow()); Document cursor = client.getDatabase(schemaName).runCommand(listCollectionsCommand).get("cursor", Document.class); List firstBatch = cursor.get("firstBatch", List.class); if (firstBatch.isEmpty()) { diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java index 1db285fcda66..e05f05e5c85a 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java @@ -70,7 +70,7 @@ public void testExplicitPropertyMappings() .put("mongodb.write-concern", "UNACKNOWLEDGED") .put("mongodb.required-replica-set", "replica_set") .put("mongodb.implicit-row-field-prefix", "_prefix") - .build(); + .buildOrThrow(); ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); MongoClientConfig config = configurationFactory.build(MongoClientConfig.class); diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestCredentialPassthrough.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestCredentialPassthrough.java index 502b0f86f51b..88632325b3b8 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestCredentialPassthrough.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestCredentialPassthrough.java @@ -50,7 +50,7 @@ public void createQueryRunner() .put("connection-url", mySqlServer.getJdbcUrl()) .put("user-credential-name", "mysql.user") .put("password-credential-name", "mysql.password") - .build(); + .buildOrThrow(); queryRunner.createCatalog("mysql", "mysql", properties); } catch (Exception e) { diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlCaseInsensitiveMapping.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlCaseInsensitiveMapping.java index af54b493ecb1..7ff2351d22b4 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlCaseInsensitiveMapping.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlCaseInsensitiveMapping.java @@ -48,7 +48,7 @@ protected QueryRunner createQueryRunner() .put("case-insensitive-name-matching", "true") .put("case-insensitive-name-matching.config-file", mappingFile.toFile().getAbsolutePath()) .put("case-insensitive-name-matching.config-file.refresh-period", "1ms") // ~always refresh - .build(), + .buildOrThrow(), ImmutableList.of()); } diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlConfig.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlConfig.java index 3f618325b8ba..9922efef9d7b 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlConfig.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlConfig.java @@ -44,7 +44,7 @@ public void testExplicitPropertyMappings() .put("mysql.max-reconnects", "4") .put("mysql.connection-timeout", "4s") .put("mysql.jdbc.use-information-schema", "false") - .build(); + .buildOrThrow(); MySqlConfig expected = new MySqlConfig() .setAutoReconnect(false) diff --git a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java index 52d94753b7a8..653b4d788231 100644 --- a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java +++ b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java @@ -162,7 +162,7 @@ public class OracleClient .put(VARBINARY, WriteMapping.sliceMapping("blob", varbinaryWriteFunction())) .put(DATE, WriteMapping.longMapping("date", oracleDateWriteFunction())) .put(TIMESTAMP_TZ_MILLIS, WriteMapping.longMapping("timestamp(3) with time zone", oracleTimestampWithTimeZoneWriteFunction())) - .build(); + .buildOrThrow(); @Inject public OracleClient( diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/OracleQueryRunner.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/OracleQueryRunner.java index 242345817f4f..adf06ad0cc94 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/OracleQueryRunner.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/OracleQueryRunner.java @@ -79,7 +79,7 @@ public static Map connectionProperties(TestingOracleServer serve .put("connection-user", TEST_USER) .put("connection-password", TEST_PASS) .put("allow-drop-table", "true") - .build(); + .buildOrThrow(); } public static void main(String[] args) @@ -98,7 +98,7 @@ public static void main(String[] args) .put("allow-drop-table", "true") .put("oracle.connection-pool.enabled", "false") .put("oracle.remarks-reporting.enabled", "false") - .build(), + .buildOrThrow(), TpchTable.getTables()); Logger log = Logger.get(OracleQueryRunner.class); diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java index 946d000fc712..d1c849e33aec 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java @@ -50,7 +50,7 @@ protected QueryRunner createQueryRunner() ImmutableMap.builder() .putAll(OracleQueryRunner.connectionProperties(oracleServer)) .put("case-insensitive-name-matching", "true") - .build(), + .buildOrThrow(), ImmutableList.of()); } diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConfig.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConfig.java index ea2d60adbb0b..d123c6f6188d 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConfig.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConfig.java @@ -58,7 +58,7 @@ public void testExplicitPropertyMappings() .put("oracle.connection-pool.min-size", "10") .put("oracle.connection-pool.max-size", "20") .put("oracle.connection-pool.inactive-timeout", "30s") - .build(); + .buildOrThrow(); OracleConfig expected = new OracleConfig() .setSynonymsEnabled(true) diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConnectorTest.java index 2fc9f09b3de4..655ffc3c4a99 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConnectorTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleConnectorTest.java @@ -49,7 +49,7 @@ protected QueryRunner createQueryRunner() .put("allow-drop-table", "true") .put("oracle.connection-pool.enabled", "false") .put("oracle.remarks-reporting.enabled", "false") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolConnectorSmokeTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolConnectorSmokeTest.java index 30d6108283df..86dd64c168cb 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolConnectorSmokeTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolConnectorSmokeTest.java @@ -43,7 +43,7 @@ protected QueryRunner createQueryRunner() .put("allow-drop-table", "true") .put("oracle.connection-pool.enabled", "true") .put("oracle.remarks-reporting.enabled", "false") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolRemarksReportingConnectorSmokeTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolRemarksReportingConnectorSmokeTest.java index af4752375c9d..b5147db43d68 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolRemarksReportingConnectorSmokeTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOraclePoolRemarksReportingConnectorSmokeTest.java @@ -46,7 +46,7 @@ protected QueryRunner createQueryRunner() .put("allow-drop-table", "true") .put("oracle.connection-pool.enabled", "true") .put("oracle.remarks-reporting.enabled", "true") - .build(), + .buildOrThrow(), REQUIRED_TPCH_TABLES); } diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleTypeMapping.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleTypeMapping.java index 581d6f8a173f..ed74aa671d9d 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleTypeMapping.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleTypeMapping.java @@ -42,7 +42,7 @@ protected QueryRunner createQueryRunner() .put("allow-drop-table", "true") .put("oracle.connection-pool.enabled", "false") .put("oracle.remarks-reporting.enabled", "false") - .build(), + .buildOrThrow(), ImmutableList.of()); } diff --git a/plugin/trino-password-authenticators/src/main/java/io/trino/plugin/password/ldap/JdkLdapAuthenticatorClient.java b/plugin/trino-password-authenticators/src/main/java/io/trino/plugin/password/ldap/JdkLdapAuthenticatorClient.java index 7e0d5f2af8ad..0bdd6a0fcdc8 100644 --- a/plugin/trino-password-authenticators/src/main/java/io/trino/plugin/password/ldap/JdkLdapAuthenticatorClient.java +++ b/plugin/trino-password-authenticators/src/main/java/io/trino/plugin/password/ldap/JdkLdapAuthenticatorClient.java @@ -69,7 +69,7 @@ public JdkLdapAuthenticatorClient(LdapConfig ldapConfig) .put(INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory") .put(PROVIDER_URL, ldapUrl) .put(REFERRAL, ldapConfig.isIgnoreReferrals() ? "ignore" : "follow") - .build(); + .buildOrThrow(); this.sslContext = Optional.ofNullable(ldapConfig.getTrustCertificate()) .map(JdkLdapAuthenticatorClient::createSslContext); @@ -146,7 +146,7 @@ private Map createEnvironment(String userDistinguishedName, Stri environment.put("java.naming.ldap.factory.socket", LdapSslSocketFactory.class.getName()); }); - return environment.build(); + return environment.buildOrThrow(); } private static SSLContext createSslContext(File trustCertificate) diff --git a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileConfig.java b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileConfig.java index 4ef23a200947..04177fa3fea2 100644 --- a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileConfig.java +++ b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileConfig.java @@ -49,7 +49,7 @@ public void testExplicitConfig() .put("file.password-file", passwordFile.toString()) .put("file.refresh-period", "42s") .put("file.auth-token-cache.max-size", "1234") - .build(); + .buildOrThrow(); FileConfig expected = new FileConfig() .setPasswordFile(passwordFile.toFile()) diff --git a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileGroupConfig.java b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileGroupConfig.java index 1b6f25a4171f..cf68a2409a64 100644 --- a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileGroupConfig.java +++ b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/file/TestFileGroupConfig.java @@ -47,7 +47,7 @@ public void testExplicitConfig() Map properties = new ImmutableMap.Builder() .put("file.group-file", groupFile.toString()) .put("file.refresh-period", "42s") - .build(); + .buildOrThrow(); FileGroupConfig expected = new FileGroupConfig() .setGroupFile(groupFile.toFile()) diff --git a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapConfig.java b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapConfig.java index ecc714ccb6c4..2271ffc01b10 100644 --- a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapConfig.java +++ b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/ldap/TestLdapConfig.java @@ -70,7 +70,7 @@ public void testExplicitConfig() .put("ldap.bind-password", "password1234") .put("ldap.ignore-referrals", "true") .put("ldap.cache-ttl", "2m") - .build(); + .buildOrThrow(); LdapConfig expected = new LdapConfig() .setLdapUrl("ldaps://localhost:636") diff --git a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/salesforce/TestSalesforceConfig.java b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/salesforce/TestSalesforceConfig.java index 8be0be1be29e..9d53802e7310 100644 --- a/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/salesforce/TestSalesforceConfig.java +++ b/plugin/trino-password-authenticators/src/test/java/io/trino/plugin/password/salesforce/TestSalesforceConfig.java @@ -50,7 +50,7 @@ public void testExplicitConfig() .put("salesforce.allowed-organizations", org) .put("salesforce.cache-size", cacheSize) .put("salesforce.cache-expire-duration", cacheExpire) - .build(); + .buildOrThrow(); SalesforceConfig expected = new SalesforceConfig() .setAllowedOrganizations(org) diff --git a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java index 20ef8d57d70d..b05ccb91eb26 100644 --- a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java +++ b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java @@ -692,7 +692,7 @@ public Map getTableProperties(ConnectorSession session, JdbcTabl catch (IOException | SQLException e) { throw new TrinoException(PHOENIX_METADATA_ERROR, "Couldn't get Phoenix table properties", e); } - return properties.build(); + return properties.buildOrThrow(); } private static ColumnMapping arrayColumnMapping(ConnectorSession session, ArrayType arrayType, String elementJdbcTypeName) diff --git a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/PhoenixQueryRunner.java b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/PhoenixQueryRunner.java index 8a4a1fd345c5..c1f11c220a99 100644 --- a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/PhoenixQueryRunner.java +++ b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/PhoenixQueryRunner.java @@ -61,7 +61,7 @@ public static DistributedQueryRunner createPhoenixQueryRunner(TestingPhoenixServ Map properties = ImmutableMap.builder() .put("phoenix.connection-url", server.getJdbcUrl()) .put("case-insensitive-name-matching", "true") - .build(); + .buildOrThrow(); queryRunner.installPlugin(new PhoenixPlugin()); queryRunner.createCatalog("phoenix", "phoenix", properties); diff --git a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConfig.java b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConfig.java index 81c34d6db949..9119684a85c9 100644 --- a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConfig.java +++ b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConfig.java @@ -46,7 +46,7 @@ public void testExplicitPropertyMappings() .put("phoenix.connection-url", "jdbc:phoenix:localhost:2181:/hbase") .put("phoenix.config.resources", configFile.toString()) .put("phoenix.max-scans-per-split", "1") - .build(); + .buildOrThrow(); PhoenixConfig expected = new PhoenixConfig() .setConnectionUrl("jdbc:phoenix:localhost:2181:/hbase") diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java index 237c562aeeae..fb3f8fe04c5d 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java @@ -684,7 +684,7 @@ public Map getTableProperties(ConnectorSession session, JdbcTabl catch (IOException | SQLException e) { throw new TrinoException(PHOENIX_METADATA_ERROR, "Couldn't get Phoenix table properties", e); } - return properties.build(); + return properties.buildOrThrow(); } private static ColumnMapping arrayColumnMapping(ConnectorSession session, ArrayType arrayType, String elementJdbcTypeName) diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/PhoenixQueryRunner.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/PhoenixQueryRunner.java index 018ef52560d9..e988eccf70cd 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/PhoenixQueryRunner.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/PhoenixQueryRunner.java @@ -61,7 +61,7 @@ public static DistributedQueryRunner createPhoenixQueryRunner(TestingPhoenixServ Map properties = ImmutableMap.builder() .put("phoenix.connection-url", server.getJdbcUrl()) .put("case-insensitive-name-matching", "true") - .build(); + .buildOrThrow(); queryRunner.installPlugin(new PhoenixPlugin()); queryRunner.createCatalog("phoenix", "phoenix5", properties); diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java index 1b4cc73b2d98..32e4779779e0 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java @@ -46,7 +46,7 @@ public void testExplicitPropertyMappings() .put("phoenix.connection-url", "jdbc:phoenix:localhost:2181:/hbase") .put("phoenix.config.resources", configFile.toString()) .put("phoenix.max-scans-per-split", "1") - .build(); + .buildOrThrow(); PhoenixConfig expected = new PhoenixConfig() .setConnectionUrl("jdbc:phoenix:localhost:2181:/hbase") diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java index b18fbbabb4e9..cc113b8715c1 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java @@ -207,7 +207,7 @@ public Map getPinotColumnHandles(String tableName) columnHandlesBuilder.put(columnMetadata.getName(), new PinotColumnHandle(getPinotColumnName(columnMetadata), columnMetadata.getType())); } - return columnHandlesBuilder.build(); + return columnHandlesBuilder.buildOrThrow(); } private static String getPinotColumnName(ColumnMetadata columnMetadata) @@ -228,7 +228,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } @Override @@ -533,7 +533,7 @@ private Map getDynamicTableColumnHandles(PinotTableHandle } dynamicTable.getAggregateColumns() .forEach(columnHandle -> columnHandlesBuilder.put(columnHandle.getColumnName().toLowerCase(ENGLISH), columnHandle)); - return columnHandlesBuilder.build(); + return columnHandlesBuilder.buildOrThrow(); } private ConnectorTableMetadata getTableMetadata(SchemaTableName tableName) @@ -556,7 +556,7 @@ private static ColumnMetadata createPinotColumnMetadata(PinotColumnHandle pinotC .setType(pinotColumn.getDataType()) .setProperties(ImmutableMap.builder() .put(PINOT_COLUMN_NAME_PROPERTY, pinotColumn.getColumnName()) - .build()) + .buildOrThrow()) .build(); } diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java index 62d5b786dd47..6cc8377a6b01 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java @@ -317,13 +317,13 @@ public Map>> getRoutingTableForTable(String tab segmentBuilder.put(segmentEntry.getKey(), segmentEntry.getValue()); } } - Map> segmentMap = segmentBuilder.build(); + Map> segmentMap = segmentBuilder.buildOrThrow(); if (!segmentMap.isEmpty()) { routingTableMap.put(tablenameWithType, segmentMap); } } } - return routingTableMap.build(); + return routingTableMap.buildOrThrow(); } public static class TimeBoundary diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/query/DynamicTableBuilder.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/query/DynamicTableBuilder.java index 920a4d819e30..28964f347adf 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/query/DynamicTableBuilder.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/query/DynamicTableBuilder.java @@ -91,7 +91,7 @@ public static DynamicTable buildFromPql(PinotMetadata pinotMetadata, SchemaTable aggregateTypesBuilder.put(aggregationFunction.getResultColumnName(), toTrinoType(aggregationFunction.getFinalResultColumnType())); } } - Map aggregateTypes = aggregateTypesBuilder.build(); + Map aggregateTypes = aggregateTypesBuilder.buildOrThrow(); if (queryContext.getSelectExpressions() != null) { checkState(!queryContext.getSelectExpressions().isEmpty(), "Pinot selections is empty"); selectColumns = getPinotColumns(schemaTableName, queryContext.getSelectExpressions(), queryContext.getAliasList(), columnHandles, pinotTypeResolver, aggregateTypes); diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MetadataUtil.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MetadataUtil.java index 9e8f30cb3c15..5c525f853167 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MetadataUtil.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MetadataUtil.java @@ -77,7 +77,7 @@ protected Type _deserialize(String value, DeserializationContext context) objectMapperProvider.setJsonDeserializers(ImmutableMap., JsonDeserializer>builder() .put(Type.class, new TestingTypeDeserializer()) .put(DataSchema.class, new PinotModule.DataSchemaDeserializer()) - .build()); + .buildOrThrow()); JsonCodecFactory codecFactory = new JsonCodecFactory(objectMapperProvider); COLUMN_CODEC = codecFactory.jsonCodec(PinotColumnHandle.class); TABLES_JSON_CODEC = codecFactory.jsonCodec(PinotClient.GetTables.class); diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MockPinotClient.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MockPinotClient.java index b93ce18ec74c..2f393ae93a85 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MockPinotClient.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/MockPinotClient.java @@ -102,7 +102,7 @@ public Map>> getRoutingTableForTable(String tab "server4", ImmutableList.of("segment41", "segment42"))); } - return routingTable.build(); + return routingTable.buildOrThrow(); } @Override diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/PinotQueryRunner.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/PinotQueryRunner.java index e20d1e83bd66..c14f6897f3df 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/PinotQueryRunner.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/PinotQueryRunner.java @@ -77,7 +77,7 @@ public static void main(String[] args) .put("pinot.controller-urls", pinot.getControllerConnectString()) .put("pinot.segments-per-split", "10") .put("pinot.request-timeout", "3m") - .build(); + .buildOrThrow(); DistributedQueryRunner queryRunner = createPinotQueryRunner(properties, pinotProperties, Optional.empty()); Thread.sleep(10); Logger log = Logger.get(PinotQueryRunner.class); diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java index 7123cb59b22c..52eeb7be2ee7 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java @@ -175,7 +175,7 @@ public void testFilterWithPushdownConstraint() TupleDomain tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.builder() .put(columnHandle, Domain.create(ValueSet.ofRanges(Range.equal(VARCHAR, Slices.utf8Slice("Catfish Paradise"))), false)) - .build()); + .buildOrThrow()); String expectedPql = "select \"FlightNum\" from realtimeonly where (\"OriginCityName\" = 'Catfish Paradise') limit 60"; assertEquals(extractPql(dynamicTable, tupleDomain, ImmutableList.builder() .add(columnHandle) diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java index 3f28e9f689fe..7bd9ad3d73db 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java @@ -74,7 +74,7 @@ public void testExplicitPropertyMappings() .put("pinot.max-rows-for-broker-queries", "5000") .put("pinot.aggregation-pushdown.enabled", "false") .put("pinot.count-distinct-pushdown.enabled", "false") - .build(); + .buildOrThrow(); PinotConfig expected = new PinotConfig() .setControllerUrls("host1:1111,host2:1111") diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java index 3593f269dddb..e39caa072fa6 100644 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java @@ -298,7 +298,7 @@ protected QueryRunner createQueryRunner() .put("pinot.controller-urls", pinot.getControllerConnectString()) .put("pinot.max-rows-per-split-for-segment-queries", String.valueOf(MAX_ROWS_PER_SPLIT_FOR_SEGMENT_QUERIES)) .put("pinot.max-rows-for-broker-queries", String.valueOf(MAX_ROWS_PER_SPLIT_FOR_BROKER_QUERIES)) - .build(); + .buildOrThrow(); return PinotQueryRunner.createPinotQueryRunner( ImmutableMap.of(), @@ -313,7 +313,7 @@ private static Map schemaRegistryAwareProducer(TestingKafka test .put(SCHEMA_REGISTRY_URL_CONFIG, testingKafka.getSchemaRegistryConnectString()) .put(KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()) .put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()) - .build(); + .buildOrThrow(); } private static GenericRecord createTestRecord( diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotQueryBase.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotQueryBase.java index 2b2d8ebfccc8..ee226ad98a18 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotQueryBase.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotQueryBase.java @@ -108,6 +108,6 @@ public static Map getTestingMetadata() .addSingleValueDimension("non_quoted", DataType.STRING) .addSingleValueDimension("qu\"ot\"ed", DataType.STRING) .build()) - .build(); + .buildOrThrow(); } } diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotSplitManager.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotSplitManager.java index 32d8da633000..1682a10785fe 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotSplitManager.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotSplitManager.java @@ -118,7 +118,7 @@ public static ConnectorSession createSessionWithNumSplits(int numSegmentsPerSpli .setPropertyValues(ImmutableMap.builder() .put(PinotSessionProperties.SEGMENTS_PER_SPLIT, numSegmentsPerSplit) .put(PinotSessionProperties.FORBID_SEGMENT_QUERIES, forbidSegmentQueries) - .build()) + .buildOrThrow()) .build(); } diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java index 5c5ec888cc58..05b26dac4579 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java @@ -47,7 +47,7 @@ protected QueryRunner createQueryRunner() .put("case-insensitive-name-matching", "true") .put("case-insensitive-name-matching.config-file", mappingFile.toFile().getAbsolutePath()) .put("case-insensitive-name-matching.config-file.refresh-period", "1ms") // ~always refresh - .build(), + .buildOrThrow(), ImmutableSet.of()); } diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConfig.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConfig.java index a5297222f177..abe57354111b 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConfig.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() .put("postgresql.array-mapping", "AS_ARRAY") .put("postgresql.include-system-tables", "true") .put("postgresql.experimental.enable-string-pushdown-with-collate", "true") - .build(); + .buildOrThrow(); PostgreSqlConfig expected = new PostgreSqlConfig() .setArrayMapping(PostgreSqlConfig.ArrayMapping.AS_ARRAY) diff --git a/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusMetadata.java b/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusMetadata.java index 97151f11f553..46cafc5c5d8c 100644 --- a/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusMetadata.java +++ b/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusMetadata.java @@ -109,7 +109,7 @@ public Map getColumnHandles(ConnectorSession session, Conn columnHandles.put(column.getName(), new PrometheusColumnHandle(column.getName(), column.getType(), index)); index++; } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -124,7 +124,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } private ConnectorTableMetadata getTableMetadata(SchemaTableName tableName) diff --git a/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusRecordCursor.java b/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusRecordCursor.java index 6ced95079521..f0b55c946bc7 100644 --- a/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusRecordCursor.java +++ b/plugin/trino-prometheus/src/main/java/io/trino/plugin/prometheus/PrometheusRecordCursor.java @@ -197,7 +197,7 @@ private List prometheusResultsInStandardizedForm(List private static Map metricHeaderToMap(Map mapToConvert) { - return ImmutableMap.builder().putAll(mapToConvert).build(); + return ImmutableMap.builder().putAll(mapToConvert).buildOrThrow(); } static Block getBlockFromMap(Type mapType, Map map) diff --git a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/MetadataUtil.java b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/MetadataUtil.java index 9c169f420870..e5fdb5e05b6b 100644 --- a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/MetadataUtil.java +++ b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/MetadataUtil.java @@ -64,7 +64,7 @@ public static final class TestingTypeDeserializer .put("timestamp(3) with time zone", TIMESTAMP_COLUMN_TYPE) .put(StandardTypes.DOUBLE, DOUBLE) .put(StandardTypes.VARCHAR, createUnboundedVarcharType()) - .build(); + .buildOrThrow(); public TestingTypeDeserializer() { diff --git a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusConnectorConfig.java b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusConnectorConfig.java index 3d78ad004a5c..36d48c561ece 100644 --- a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusConnectorConfig.java +++ b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusConnectorConfig.java @@ -55,7 +55,7 @@ public void testExplicitPropertyMappings() .put("prometheus.cache.ttl", "60s") .put("prometheus.bearer.token.file", "/tmp/bearer_token.txt") .put("prometheus.read-timeout", "30s") - .build(); + .buildOrThrow(); URI uri = URI.create("file://test.json"); PrometheusConnectorConfig expected = new PrometheusConnectorConfig(); diff --git a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusRecordSetProvider.java b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusRecordSetProvider.java index e0f82b4888c0..e87e9bb82e0e 100644 --- a/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusRecordSetProvider.java +++ b/plugin/trino-prometheus/src/test/java/io/trino/plugin/prometheus/TestPrometheusRecordSetProvider.java @@ -92,7 +92,7 @@ public void testGetRecordSet() .put(ofEpochMilli(1565963014044L), ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")) - .build(); + .buildOrThrow(); assertEquals(actual, expected); } } diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java index 6fc2a02d9875..ae43ea6875a0 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java @@ -243,7 +243,7 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect columns.add(hiddenColumn(BUCKET_NUMBER_COLUMN_NAME, INTEGER)); } - return new ConnectorTableMetadata(tableName, columns, properties.build()); + return new ConnectorTableMetadata(tableName, columns, properties.buildOrThrow()); } @Override @@ -269,7 +269,7 @@ public Map getColumnHandles(ConnectorSession session, Conn builder.put(bucketNumberColumn.getColumnName(), bucketNumberColumn); } - return builder.build(); + return builder.buildOrThrow(); } @Override @@ -358,7 +358,7 @@ public Optional getNewTableLayout(ConnectorSession sess columnId++; } - Optional distribution = getOrCreateDistribution(map.build(), metadata.getProperties()); + Optional distribution = getOrCreateDistribution(map.buildOrThrow(), metadata.getProperties()); if (distribution.isEmpty()) { return Optional.empty(); } @@ -883,7 +883,7 @@ public Map getViews(ConnectorSession s for (ViewResult view : dao.getViews(schemaName.orElse(null), null)) { map.put(view.getName(), VIEW_CODEC.fromJson(view.getData())); } - return map.build(); + return map.buildOrThrow(); } @Override diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/backup/BackupModule.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/backup/BackupModule.java index d394dbed0d1a..63c1b1c0132d 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/backup/BackupModule.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/backup/BackupModule.java @@ -44,7 +44,7 @@ public BackupModule(Map providers) .put("file", new FileBackupModule()) .put("http", new HttpBackupModule()) .putAll(providers) - .build(); + .buildOrThrow(); } @Override diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/metadata/IndexInserter.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/metadata/IndexInserter.java index 9a9d910a9d98..aeadbdaade5a 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/metadata/IndexInserter.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/metadata/IndexInserter.java @@ -97,8 +97,8 @@ public IndexInserter(Connection connection, long tableId, List colum } this.columns = columnBuilder.build(); - this.indexes = indexBuilder.build(); - this.types = typeBuilder.build(); + this.indexes = indexBuilder.buildOrThrow(); + this.types = typeBuilder.buildOrThrow(); String sql = "" + "INSERT INTO " + shardIndexTable(tableId) + "\n" + diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/BucketBalancer.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/BucketBalancer.java index 86cb68fc0caa..cbf09f00e192 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/BucketBalancer.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/BucketBalancer.java @@ -302,7 +302,7 @@ ClusterState fetchClusterState() } } - return new ClusterState(activeNodes, assignedNodeSize, distributionAssignments.build(), distributionBucketSize.build()); + return new ClusterState(activeNodes, assignedNodeSize, distributionAssignments.build(), distributionBucketSize.buildOrThrow()); } @VisibleForTesting diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/OrcFileWriter.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/OrcFileWriter.java index 272686f2486f..26a878f7e213 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/OrcFileWriter.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/storage/OrcFileWriter.java @@ -240,7 +240,7 @@ public void preFooterWrite(OrcFile.WriterContext context) for (int i = 0; i < columnIds.size(); i++) { columnTypesMap.put(columnIds.get(i), columnTypes.get(i).getTypeId()); } - byte[] bytes = METADATA_CODEC.toJsonBytes(new OrcFileMetadata(columnTypesMap.build())); + byte[] bytes = METADATA_CODEC.toJsonBytes(new OrcFileMetadata(columnTypesMap.buildOrThrow())); context.getWriter().addUserMetadata(OrcFileMetadata.KEY, ByteBuffer.wrap(bytes)); } }; diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorBenchmarkQueryRunner.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorBenchmarkQueryRunner.java index 7936ab9b03b9..4d61164179b6 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorBenchmarkQueryRunner.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorBenchmarkQueryRunner.java @@ -81,6 +81,6 @@ private static Map createRaptorConfig(String cacheDir) .put("metadata.db.filename", databaseDir.getAbsolutePath()) .put("storage.data-directory", dataDir.getAbsolutePath()) .put("storage.compress", "false") - .build(); + .buildOrThrow(); } } diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorQueryRunner.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorQueryRunner.java index cb03726fa92c..577b3baa6025 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorQueryRunner.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/RaptorQueryRunner.java @@ -70,7 +70,7 @@ public static DistributedQueryRunner createRaptorQueryRunner( .put("storage.max-shard-rows", "2000") .put("backup.provider", "file") .put("backup.directory", new File(baseDir, "backup").getAbsolutePath()) - .build(); + .buildOrThrow(); queryRunner.createCatalog("raptor", "raptor-legacy", raptorProperties); @@ -117,7 +117,7 @@ else if (table.equals(TpchTable.REGION)) { throw new IllegalArgumentException("Unsupported table: " + table); } } - Map, String> tablesMap = tablesMapBuilder.build(); + Map, String> tablesMap = tablesMapBuilder.buildOrThrow(); log.info("Loading data from %s.%s...", catalog, schema); long startTime = System.nanoTime(); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorIntegrationSmokeTestMySql.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorIntegrationSmokeTestMySql.java index ea3161c6fade..7a7ed2ee6ff3 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorIntegrationSmokeTestMySql.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorIntegrationSmokeTestMySql.java @@ -73,7 +73,7 @@ private static QueryRunner createRaptorMySqlQueryRunner(String mysqlUrl) .put("storage.max-shard-rows", "2000") .put("backup.provider", "file") .put("backup.directory", new File(baseDir, "backup").getAbsolutePath()) - .build(); + .buildOrThrow(); queryRunner.createCatalog("raptor", "raptor-legacy", raptorProperties); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorPlugin.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorPlugin.java index e566602cff8c..fe2495cfc445 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorPlugin.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/TestRaptorPlugin.java @@ -44,7 +44,7 @@ public void testPlugin() .put("metadata.db.type", "h2") .put("metadata.db.filename", tmpDir.getAbsolutePath()) .put("storage.data-directory", tmpDir.getAbsolutePath()) - .build(); + .buildOrThrow(); factory.create("test", config, new TestingConnectorContext()).shutdown(); } diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestBackupConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestBackupConfig.java index 5ab335349682..3f55480d1574 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestBackupConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestBackupConfig.java @@ -45,7 +45,7 @@ public void testExplicitPropertyMappings() .put("backup.timeout", "42s") .put("backup.timeout-threads", "13") .put("backup.threads", "3") - .build(); + .buildOrThrow(); BackupConfig expected = new BackupConfig() .setProvider("file") diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupConfig.java index 6be18b8b3266..a368e5951f31 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("backup.directory", "/backup") - .build(); + .buildOrThrow(); FileBackupConfig expected = new FileBackupConfig() .setBackupDirectory(new File("/backup")); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupConfig.java index c070f1b8114e..e3f23c069a72 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupConfig.java @@ -37,7 +37,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("backup.http.uri", "http://example.net:8080") - .build(); + .buildOrThrow(); HttpBackupConfig expected = new HttpBackupConfig() .setUri(URI.create("http://example.net:8080")); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java index 6d1e3f7d7299..dd1b43cf408a 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java @@ -57,7 +57,7 @@ public void setup() Map properties = ImmutableMap.builder() .put("backup.http.uri", "http://localhost:8080") - .build(); + .buildOrThrow(); Bootstrap app = new Bootstrap( new TestingNodeModule(), diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestDatabaseConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestDatabaseConfig.java index 82b93c78400d..257d5981e600 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestDatabaseConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestDatabaseConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = ImmutableMap.builder() .put("metadata.db.type", "h2") - .build(); + .buildOrThrow(); DatabaseConfig expected = new DatabaseConfig() .setDatabaseType("h2"); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestJdbcDatabaseConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestJdbcDatabaseConfig.java index 1b7ad7de22d1..b2d422cf7d1f 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestJdbcDatabaseConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestJdbcDatabaseConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = ImmutableMap.builder() .put("metadata.db.url", "jdbc:test://example.net/test") - .build(); + .buildOrThrow(); JdbcDatabaseConfig expected = new JdbcDatabaseConfig() .setUrl("jdbc:test://example.net/test"); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestMetadataConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestMetadataConfig.java index d20052641278..be84ddae1f08 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestMetadataConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestMetadataConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() .put("raptor.startup-grace-period", "42m") .put("raptor.reassignment-delay", "6m") .put("raptor.reassignment-interval", "7m") - .build(); + .buildOrThrow(); MetadataConfig expected = new MetadataConfig() .setStartupGracePeriod(new Duration(42, MINUTES)) diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestShardCleanerConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestShardCleanerConfig.java index 020dd6b715c0..d545bad1f177 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestShardCleanerConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/metadata/TestShardCleanerConfig.java @@ -54,7 +54,7 @@ public void testExplicitPropertyMappings() .put("raptor.backup-clean-time", "35m") .put("raptor.backup-deletion-threads", "37") .put("raptor.max-completed-transaction-age", "39m") - .build(); + .buildOrThrow(); ShardCleanerConfig expected = new ShardCleanerConfig() .setMaxTransactionAge(new Duration(42, MINUTES)) diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorSecurityConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorSecurityConfig.java index af18a3c76550..79b6214fecbb 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorSecurityConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorSecurityConfig.java @@ -38,7 +38,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("raptor.security", "read-only") - .build(); + .buildOrThrow(); RaptorSecurityConfig expected = new RaptorSecurityConfig() .setSecuritySystem(READ_ONLY); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestBucketBalancerConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestBucketBalancerConfig.java index 64c8f5ad02cd..907151cd8127 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestBucketBalancerConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestBucketBalancerConfig.java @@ -40,7 +40,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("storage.balancer-enabled", "false") .put("storage.balancer-interval", "5h") - .build(); + .buildOrThrow(); BucketBalancerConfig expected = new BucketBalancerConfig() .setBalancerEnabled(false) diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestOrcFileRewriter.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestOrcFileRewriter.java index ca0df5d0d755..8713557dfb08 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestOrcFileRewriter.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestOrcFileRewriter.java @@ -182,7 +182,7 @@ public void testRewrite() .put(10L, mapType.getTypeId()) .put(11L, arrayOfArrayType.getTypeId()) .put(12L, decimalType.getTypeId()) - .build())); + .buildOrThrow())); } BitSet rowsToDelete = new BitSet(5); @@ -255,7 +255,7 @@ public void testRewrite() .put(10L, mapType.getTypeId()) .put(11L, arrayOfArrayType.getTypeId()) .put(12L, decimalType.getTypeId()) - .build())); + .buildOrThrow())); } } diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestRaptorStorageManager.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestRaptorStorageManager.java index 578494421cc7..2e17b05481e6 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestRaptorStorageManager.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestRaptorStorageManager.java @@ -298,7 +298,7 @@ public void testReader() // tuple domain within the column range tupleDomain = TupleDomain.fromFixedValues(ImmutableMap.builder() .put(new RaptorColumnHandle("c1", 2, BIGINT), NullableValue.of(BIGINT, 124L)) - .build()); + .buildOrThrow()); try (ConnectorPageSource pageSource = getPageSource(manager, columnIds, columnTypes, uuid, tupleDomain)) { MaterializedResult result = materializeSourceDataStream(SESSION, pageSource, columnTypes); @@ -308,7 +308,7 @@ public void testReader() // tuple domain outside the column range tupleDomain = TupleDomain.fromFixedValues(ImmutableMap.builder() .put(new RaptorColumnHandle("c1", 2, BIGINT), NullableValue.of(BIGINT, 122L)) - .build()); + .buildOrThrow()); try (ConnectorPageSource pageSource = getPageSource(manager, columnIds, columnTypes, uuid, tupleDomain)) { MaterializedResult result = materializeSourceDataStream(SESSION, pageSource, columnTypes); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestShardWriter.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestShardWriter.java index 13f6b20207b8..f5cd1bcf3ac4 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestShardWriter.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestShardWriter.java @@ -184,7 +184,7 @@ public void testWriter() .put(8L, arrayType.getTypeId()) .put(9L, mapType.getTypeId()) .put(10L, arrayOfArrayType.getTypeId()) - .build())); + .buildOrThrow())); } File crcFile = new File(file.getParentFile(), "." + file.getName() + ".crc"); diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestStorageManagerConfig.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestStorageManagerConfig.java index 6e9abd2a7d5e..ad55cff7a707 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestStorageManagerConfig.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/storage/TestStorageManagerConfig.java @@ -95,7 +95,7 @@ public void testExplicitPropertyMappings() .put("storage.max-shard-size", "10MB") .put("storage.max-buffer-size", "512MB") .put("storage.one-split-per-bucket-threshold", "4") - .build(); + .buildOrThrow(); StorageManagerConfig expected = new StorageManagerConfig() .setDataDirectory(new File("/data")) diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/systemtables/TestShardMetadataRecordCursor.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/systemtables/TestShardMetadataRecordCursor.java index e2c4b58c3c84..ff986057a561 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/systemtables/TestShardMetadataRecordCursor.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/systemtables/TestShardMetadataRecordCursor.java @@ -133,7 +133,7 @@ public void testSimple() .put(1, Domain.create(ValueSet.ofRanges(lessThanOrEqual(createVarcharType(10), table)), true)) .put(8, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)) .put(9, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)) - .build()); + .buildOrThrow()); List actual; try (RecordCursor cursor = new ShardMetadataSystemTable(dbi).cursor(null, SESSION, tupleDomain)) { @@ -165,7 +165,7 @@ public void testNoSchemaFilter() TupleDomain tupleDomain = TupleDomain.withColumnDomains( ImmutableMap.builder() .put(1, Domain.singleValue(createVarcharType(10), utf8Slice("orders"))) - .build()); + .buildOrThrow()); MetadataDao metadataDao = dummyHandle.attach(MetadataDao.class); Set actual = ImmutableSet.copyOf(ShardMetadataRecordCursor.getTableIds(dbi, tupleDomain)); @@ -191,7 +191,7 @@ public void testNoTableFilter() TupleDomain tupleDomain = TupleDomain.withColumnDomains( ImmutableMap.builder() .put(0, Domain.singleValue(createVarcharType(10), utf8Slice("test"))) - .build()); + .buildOrThrow()); MetadataDao metadataDao = dummyHandle.attach(MetadataDao.class); Set actual = ImmutableSet.copyOf(ShardMetadataRecordCursor.getTableIds(dbi, tupleDomain)); diff --git a/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisMetadata.java b/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisMetadata.java index 2d9537209d88..455d99972601 100644 --- a/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisMetadata.java +++ b/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisMetadata.java @@ -174,7 +174,7 @@ public Map getColumnHandles(ConnectorSession session, Conn index++; } - return columnHandles.build(); + return columnHandles.buildOrThrow(); } @Override @@ -199,7 +199,7 @@ public Map> listTableColumns(ConnectorSess columns.put(tableName, tableMetadata.getColumns()); } } - return columns.build(); + return columns.buildOrThrow(); } @Override diff --git a/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisTableDescriptionSupplier.java b/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisTableDescriptionSupplier.java index ce9a3dc9d2e1..e99e7036fd87 100644 --- a/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisTableDescriptionSupplier.java +++ b/plugin/trino-redis/src/main/java/io/trino/plugin/redis/RedisTableDescriptionSupplier.java @@ -67,7 +67,7 @@ public Map get() } } - Map tableDefinitions = builder.build(); + Map tableDefinitions = builder.buildOrThrow(); log.debug("Loaded table definitions: %s", tableDefinitions.keySet()); @@ -96,7 +96,7 @@ public Map get() } } - return builder.build(); + return builder.buildOrThrow(); } catch (IOException e) { log.warn(e, "Error: "); diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/RedisQueryRunner.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/RedisQueryRunner.java index dd183de2ff74..e5a5c168559a 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/RedisQueryRunner.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/RedisQueryRunner.java @@ -121,7 +121,7 @@ private static Map createTpchTableDescri tableDescriptions.put(loadTpchTableDescription(tableDescriptionJsonCodec, tpchTable, dataFormat)); } - return tableDescriptions.build(); + return tableDescriptions.buildOrThrow(); } public static Session createSession() diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java index b1a421865ec8..e44334fe9171 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java @@ -76,7 +76,7 @@ public void spinUp() installRedisPlugin(redisServer, queryRunner, ImmutableMap.builder() .put(createEmptyTableDescription(new SchemaTableName("default", tableName))) - .build()); + .buildOrThrow()); } @AfterMethod(alwaysRun = true) diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisConnectorConfig.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisConnectorConfig.java index b62c97f5f61e..09961e808220 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisConnectorConfig.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisConnectorConfig.java @@ -57,7 +57,7 @@ public void testExplicitPropertyMappings() .put("redis.connect-timeout", "10s") .put("redis.database-index", "5") .put("redis.password", "secret") - .build(); + .buildOrThrow(); RedisConnectorConfig expected = new RedisConnectorConfig() .setTableDescriptionDir(new File("/var/lib/redis")) diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java index cd2a5e33d1ed..1d09a94026a3 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java @@ -38,7 +38,7 @@ public void testStartup() ImmutableMap.builder() .put("redis.table-names", "test") .put("redis.nodes", "localhost:6379") - .build(), + .buildOrThrow(), new TestingConnectorContext()); assertNotNull(connector); connector.shutdown(); diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/util/RedisLoader.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/util/RedisLoader.java index c0532ee9b35d..311904d66f90 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/util/RedisLoader.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/util/RedisLoader.java @@ -119,7 +119,7 @@ public void addResults(QueryStatusInfo statusInfo, QueryData data) builder.put(columns.get(i).getName(), value); } } - jedis.set(redisKey, jsonEncoder.toString(builder.build())); + jedis.set(redisKey, jsonEncoder.toString(builder.buildOrThrow())); break; case "hash": // add keys to zset diff --git a/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/TestFileResourceGroupConfig.java b/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/TestFileResourceGroupConfig.java index 85ceff6e6d45..18ea7905df1c 100644 --- a/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/TestFileResourceGroupConfig.java +++ b/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/TestFileResourceGroupConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("resource-groups.config-file", resourceGroupConfigFile.toString()) - .build(); + .buildOrThrow(); FileResourceGroupConfig expected = new FileResourceGroupConfig() .setConfigFile(resourceGroupConfigFile.toString()); diff --git a/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/db/TestDbResourceGroupConfig.java b/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/db/TestDbResourceGroupConfig.java index 1694d744284d..a28d448b4acf 100644 --- a/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/db/TestDbResourceGroupConfig.java +++ b/plugin/trino-resource-group-managers/src/test/java/io/trino/plugin/resourcegroups/db/TestDbResourceGroupConfig.java @@ -47,7 +47,7 @@ public void testExplicitPropertyMappings() .put("resource-groups.config-db-password", "trino_admin_pass") .put("resource-groups.max-refresh-interval", "1m") .put("resource-groups.exact-match-selector-enabled", "true") - .build(); + .buildOrThrow(); DbResourceGroupConfig expected = new DbResourceGroupConfig() .setConfigDbUrl("jdbc:mysql://localhost:3306/config") .setConfigDbUser("trino_admin") diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java index dbb486ac3332..7572d66e9d6f 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java @@ -45,7 +45,7 @@ public void testExplicitPropertyMappings() .put("session-property-manager.db.username", "bar") .put("session-property-manager.db.password", "pass") .put("session-property-manager.db.refresh-period", "50s") - .build(); + .buildOrThrow(); DbSessionPropertyManagerConfig expected = new DbSessionPropertyManagerConfig() .setConfigDbUrl("foo") diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java index 8d5015757e42..59b012c3ddde 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java @@ -112,7 +112,7 @@ public void setupTest() .put("session-property-manager.db.url", mysqlContainer.getJdbcUrl()) .put("session-property-manager.db.username", mysqlContainer.getUsername()) .put("session-property-manager.db.password", mysqlContainer.getPassword()) - .build()); + .buildOrThrow()); MysqlDataSource dataSource = new MysqlDataSource(); dataSource.setURL(mysqlContainer.getJdbcUrl()); diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManagerConfig.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManagerConfig.java index 17037914b530..84ea13d44a67 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManagerConfig.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManagerConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("session-property-manager.config-file", configFile.toString()) - .build(); + .buildOrThrow(); FileSessionPropertyManagerConfig expected = new FileSessionPropertyManagerConfig() .setConfigFile(configFile.toFile()); diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerCaseInsensitiveMapping.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerCaseInsensitiveMapping.java index 91a7ca52ff75..87061daee760 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerCaseInsensitiveMapping.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerCaseInsensitiveMapping.java @@ -52,7 +52,7 @@ protected QueryRunner createQueryRunner() .put("case-insensitive-name-matching", "true") .put("case-insensitive-name-matching.config-file", mappingFile.toFile().getAbsolutePath()) .put("case-insensitive-name-matching.config-file.refresh-period", "1ms") // ~always refresh - .build(), + .buildOrThrow(), ImmutableList.of()); } diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConfig.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConfig.java index c2e5b1750613..51521f1b0ced 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConfig.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConfig.java @@ -36,7 +36,7 @@ public void testExplicitPropertyMappings() { Map properties = new ImmutableMap.Builder() .put("sqlserver.snapshot-isolation.disabled", "true") - .build(); + .buildOrThrow(); SqlServerConfig expected = new SqlServerConfig() .setSnapshotIsolationDisabled(true); diff --git a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/TestThriftConnectorConfig.java b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/TestThriftConnectorConfig.java index 8f7c82502020..849e83ae6baa 100644 --- a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/TestThriftConnectorConfig.java +++ b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/TestThriftConnectorConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() .put("trino-thrift.max-response-size", "2MB") .put("trino-thrift.metadata-refresh-threads", "10") .put("trino-thrift.lookup-requests-concurrency", "8") - .build(); + .buildOrThrow(); ThriftConnectorConfig expected = new ThriftConnectorConfig() .setMaxResponseSize(DataSize.of(2, MEGABYTE)) diff --git a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftProjectionPushdown.java b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftProjectionPushdown.java index 4efa37be2ae0..463a63d3fc8e 100644 --- a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftProjectionPushdown.java +++ b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/TestThriftProjectionPushdown.java @@ -99,7 +99,7 @@ protected Optional createLocalQueryRunner() .put("trino.thrift.client.addresses", addresses) .put("trino.thrift.client.connect-timeout", "30s") .put("trino-thrift.lookup-requests-concurrency", "2") - .build(); + .buildOrThrow(); LocalQueryRunner runner = LocalQueryRunner.create(SESSION); runner.createCatalog(CATALOG, getOnlyElement(new ThriftPlugin().getConnectorFactories()), connectorProperties); @@ -221,7 +221,7 @@ public void testPruneColumns() ImmutableMap.builder() .put(nationKey, nationKeyColumn) .put(name, nameColumn) - .build())); + .buildOrThrow())); }) .withSession(SESSION) .matches(project( diff --git a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/ThriftQueryRunner.java b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/ThriftQueryRunner.java index fc9539e506b2..749080f27c42 100644 --- a/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/ThriftQueryRunner.java +++ b/plugin/trino-thrift/src/test/java/io/trino/plugin/thrift/integration/ThriftQueryRunner.java @@ -142,7 +142,7 @@ private static DistributedQueryRunner createThriftQueryRunnerInternal(List getColumnHandles(ConnectorSession session, Conn for (ColumnMetadata columnMetadata : getTableMetadata(session, tableHandle).getColumns()) { builder.put(columnMetadata.getName(), new TpcdsColumnHandle(columnMetadata.getName(), columnMetadata.getType())); } - return builder.build(); + return builder.buildOrThrow(); } @Override @@ -173,7 +173,7 @@ public Map> listTableColumns(ConnectorSess } } } - return tableColumns.build(); + return tableColumns.buildOrThrow(); } @Override diff --git a/plugin/trino-tpch/src/main/java/io/trino/plugin/tpch/TpchMetadata.java b/plugin/trino-tpch/src/main/java/io/trino/plugin/tpch/TpchMetadata.java index 635962d00896..3ddc4ccabafb 100644 --- a/plugin/trino-tpch/src/main/java/io/trino/plugin/tpch/TpchMetadata.java +++ b/plugin/trino-tpch/src/main/java/io/trino/plugin/tpch/TpchMetadata.java @@ -251,7 +251,7 @@ public Map getColumnHandles(ConnectorSession session, Conn for (ColumnMetadata columnMetadata : getTableMetadata(session, tableHandle).getColumns()) { builder.put(columnMetadata.getName(), new TpchColumnHandle(columnMetadata.getName(), columnMetadata.getType())); } - return builder.build(); + return builder.buildOrThrow(); } @Override @@ -266,7 +266,7 @@ public Map> listTableColumns(ConnectorSess } } } - return tableColumns.build(); + return tableColumns.buildOrThrow(); } @Override diff --git a/service/trino-proxy/src/test/java/io/trino/proxy/TestJwtHandlerConfig.java b/service/trino-proxy/src/test/java/io/trino/proxy/TestJwtHandlerConfig.java index f8de2b2f1c6d..69697f64537d 100644 --- a/service/trino-proxy/src/test/java/io/trino/proxy/TestJwtHandlerConfig.java +++ b/service/trino-proxy/src/test/java/io/trino/proxy/TestJwtHandlerConfig.java @@ -50,7 +50,7 @@ public void testExplicitPropertyMappings() .put("jwt.key-id", "testkeyid") .put("jwt.issuer", "testissuer") .put("jwt.audience", "testaudience") - .build(); + .buildOrThrow(); JwtHandlerConfig expected = new JwtHandlerConfig() .setJwtKeyFile(keyFile.toFile()) diff --git a/service/trino-proxy/src/test/java/io/trino/proxy/TestProxyConfig.java b/service/trino-proxy/src/test/java/io/trino/proxy/TestProxyConfig.java index c10a7759a4a3..0353f45163a7 100644 --- a/service/trino-proxy/src/test/java/io/trino/proxy/TestProxyConfig.java +++ b/service/trino-proxy/src/test/java/io/trino/proxy/TestProxyConfig.java @@ -45,7 +45,7 @@ public void testExplicitPropertyMappings() Map properties = new ImmutableMap.Builder() .put("proxy.uri", "http://example.net/") .put("proxy.shared-secret-file", sharedSecretFile.toString()) - .build(); + .buildOrThrow(); ProxyConfig expected = new ProxyConfig() .setUri(URI.create("http://example.net/")) diff --git a/service/trino-verifier/src/test/java/io/trino/verifier/TestVerifierConfig.java b/service/trino-verifier/src/test/java/io/trino/verifier/TestVerifierConfig.java index f76bf76e8793..769010986157 100644 --- a/service/trino-verifier/src/test/java/io/trino/verifier/TestVerifierConfig.java +++ b/service/trino-verifier/src/test/java/io/trino/verifier/TestVerifierConfig.java @@ -135,7 +135,7 @@ public void testExplicitPropertyMappings() .put("control.teardown-retries", "5") .put("test.teardown-retries", "7") .put("run-teardown-on-result-mismatch", "true") - .build(); + .buildOrThrow(); VerifierConfig expected = new VerifierConfig().setTestUsernameOverride("verifier-test") .setSuites("my_suite") diff --git a/testing/trino-benchmark/src/main/java/io/trino/benchmark/AbstractOperatorBenchmark.java b/testing/trino-benchmark/src/main/java/io/trino/benchmark/AbstractOperatorBenchmark.java index 08235b6d17b9..6dad9df645f8 100644 --- a/testing/trino-benchmark/src/main/java/io/trino/benchmark/AbstractOperatorBenchmark.java +++ b/testing/trino-benchmark/src/main/java/io/trino/benchmark/AbstractOperatorBenchmark.java @@ -248,7 +248,7 @@ protected final OperatorFactory createHashProjectOperator(int operatorId, PlanNo Map, Type> expressionTypes = createTestingTypeAnalyzer(localQueryRunner.getPlannerContext()) .getTypes(session, TypeProvider.copyOf(symbolTypes), hashExpression.get()); - RowExpression translated = translate(hashExpression.get(), expressionTypes, symbolToInputMapping.build(), localQueryRunner.getMetadata(), session, false); + RowExpression translated = translate(hashExpression.get(), expressionTypes, symbolToInputMapping.buildOrThrow(), localQueryRunner.getMetadata(), session, false); PageFunctionCompiler functionCompiler = new PageFunctionCompiler(localQueryRunner.getMetadata(), 0); projections.add(functionCompiler.compileProjection(translated, Optional.empty()).get()); @@ -343,7 +343,6 @@ protected Map runOnce() .put("input_bytes", inputBytes) .put("output_rows", outputRows) .put("output_bytes", outputBytes) - - .build(); + .buildOrThrow(); } } diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveCoercion.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveCoercion.java index 628f26433656..7f8a67bb1cd4 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveCoercion.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveCoercion.java @@ -489,7 +489,7 @@ protected Map> expectedValuesForEngineProvider(Engine engin .put("id", Arrays.asList( 1, 1)) - .build(); + .buildOrThrow(); } private List removeUnsupportedColumnsForHive(List columns, String tableName) @@ -559,8 +559,7 @@ protected Map expectedExceptionsWithContext() .put(columnContext("3.1", "rcbinary", "row_to_row"), "java.util.ArrayList cannot be cast to org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct") .put(columnContext("3.1", "rcbinary", "list_to_list"), "java.util.ArrayList cannot be cast to org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryArray") .put(columnContext("3.1", "rcbinary", "map_to_map"), "java.util.LinkedHashMap cannot be cast to org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryMap") - - .build(); + .buildOrThrow(); } private void assertQueryResults( @@ -681,7 +680,7 @@ private void assertColumnTypes( .put("varchar_to_bigger_varchar", VARCHAR) .put("varchar_to_smaller_varchar", VARCHAR) .put("id", BIGINT) - .build(); + .buildOrThrow(); assertThat(queryResult) .hasColumns(columns.stream().map(expectedTypes::get).collect(toImmutableList())); diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java index cd8d9e32ff30..bec4765e6c44 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java @@ -2110,7 +2110,7 @@ private static Stream> mapRows(QueryResult result) singleRow.put(columnName, (String) row.get(column)); } - rows.add(singleRow.build()); + rows.add(singleRow.buildOrThrow()); } return rows.build().stream(); diff --git a/testing/trino-server-dev/src/test/java/io/trino/server/TestDevelopmentLoaderConfig.java b/testing/trino-server-dev/src/test/java/io/trino/server/TestDevelopmentLoaderConfig.java index eac7e2fc33f3..806987c590ee 100644 --- a/testing/trino-server-dev/src/test/java/io/trino/server/TestDevelopmentLoaderConfig.java +++ b/testing/trino-server-dev/src/test/java/io/trino/server/TestDevelopmentLoaderConfig.java @@ -42,7 +42,7 @@ public void testExplicitPropertyMappings() .put("plugin.bundles", "a,b,c") .put("maven.repo.local", "local-repo") .put("maven.repo.remote", "remote-a,remote-b") - .build(); + .buildOrThrow(); DevelopmentLoaderConfig expected = new DevelopmentLoaderConfig() .setPlugins(ImmutableList.of("a", "b", "c")) diff --git a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestFailureRecovery.java b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestFailureRecovery.java index 9cc17d4192bf..cc4ecc145811 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestFailureRecovery.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestFailureRecovery.java @@ -97,10 +97,10 @@ protected final QueryRunner createQueryRunner() .put("retry-attempts", "1") .put("failure-injection.request-timeout", new Duration(REQUEST_TIMEOUT.toMillis() * 2, MILLISECONDS).toString()) .put("exchange.http-client.idle-timeout", REQUEST_TIMEOUT.toString()) - .build(), + .buildOrThrow(), ImmutableMap.builder() .put("scheduler.http-client.idle-timeout", REQUEST_TIMEOUT.toString()) - .build()); + .buildOrThrow()); } protected abstract QueryRunner createQueryRunner(List> requiredTpchTables, Map configProperties, Map coordinatorProperties) diff --git a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestingTrinoClient.java b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestingTrinoClient.java index 3f174cb0728d..1f1190f30e54 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestingTrinoClient.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestingTrinoClient.java @@ -163,8 +163,8 @@ private static ClientSession toClientSession(Session session, URI server, Durati session.getPath().toString(), ZoneId.of(session.getTimeZoneKey().getId()), session.getLocale(), - resourceEstimates.build(), - properties.build(), + resourceEstimates.buildOrThrow(), + properties.buildOrThrow(), session.getPreparedStatements(), getRoles(session), session.getIdentity().getExtraCredentials(), @@ -178,7 +178,7 @@ private static Map getRoles(Session session) ImmutableMap.Builder builder = ImmutableMap.builder(); session.getIdentity().getEnabledRoles().forEach(role -> builder.put("system", toClientSelectedRole(new SelectedRole(ROLE, Optional.of(role))))); session.getIdentity().getCatalogRoles().forEach((key, value) -> builder.put(key, toClientSelectedRole(value))); - return builder.build(); + return builder.buildOrThrow(); } private static ClientSelectedRole toClientSelectedRole(io.trino.spi.security.SelectedRole value) diff --git a/testing/trino-testing/src/main/java/io/trino/testing/DistributedQueryRunner.java b/testing/trino-testing/src/main/java/io/trino/testing/DistributedQueryRunner.java index f56800848f12..e8cb7f166fe9 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/DistributedQueryRunner.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/DistributedQueryRunner.java @@ -233,7 +233,7 @@ private static TestingTrinoServer createTestingTrinoServer( propertiesBuilder.put("scheduler.http-client.min-threads", "1"); // default 8 propertiesBuilder.put("workerInfo.http-client.min-threads", "1"); // default 8 } - HashMap properties = new HashMap<>(propertiesBuilder.build()); + HashMap properties = new HashMap<>(propertiesBuilder.buildOrThrow()); properties.putAll(extraProperties); TestingTrinoServer server = TestingTrinoServer.builder() diff --git a/testing/trino-testing/src/main/java/io/trino/testing/StandaloneQueryRunner.java b/testing/trino-testing/src/main/java/io/trino/testing/StandaloneQueryRunner.java index 26ccba2c512b..945d8a1968fc 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/StandaloneQueryRunner.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/StandaloneQueryRunner.java @@ -301,7 +301,7 @@ private static TestingTrinoServer createTestingTrinoServer() .put("query.client.timeout", "10m") .put("exchange.http-client.idle-timeout", "1h") .put("node-scheduler.min-candidates", "1") - .build()) + .buildOrThrow()) .build(); } } diff --git a/testing/trino-testing/src/main/java/io/trino/testing/statistics/MetricComparator.java b/testing/trino-testing/src/main/java/io/trino/testing/statistics/MetricComparator.java index a23663e58325..23fd61c597e7 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/statistics/MetricComparator.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/statistics/MetricComparator.java @@ -76,7 +76,7 @@ private static StatsContext buildStatsContext(Plan queryPlan, OutputNode outputN for (int columnId = 0; columnId < outputNode.getColumnNames().size(); ++columnId) { columnSymbols.put(outputNode.getColumnNames().get(columnId), outputNode.getOutputSymbols().get(columnId)); } - return new StatsContext(columnSymbols.build(), queryPlan.getTypes()); + return new StatsContext(columnSymbols.buildOrThrow(), queryPlan.getTypes()); } private static List getActualValues(List metrics, String query, QueryRunner runner) diff --git a/testing/trino-testing/src/main/java/io/trino/testing/tpch/TpchIndexedData.java b/testing/trino-testing/src/main/java/io/trino/testing/tpch/TpchIndexedData.java index b6af4300886c..53f1c2a1087d 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/tpch/TpchIndexedData.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/tpch/TpchIndexedData.java @@ -79,7 +79,7 @@ public TpchIndexedData(TpchIndexSpec tpchIndexSpec) } } - indexedTables = indexedTablesBuilder.build(); + indexedTables = indexedTablesBuilder.buildOrThrow(); } public Optional getIndexedTable(String tableName, double scaleFactor, Set indexColumnNames) diff --git a/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java b/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java index dba9183532cb..144f6a5899de 100644 --- a/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java +++ b/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java @@ -64,7 +64,7 @@ public void setup() .put("http-server.authentication.type", "password") .put("http-server.authentication.allow-insecure-over-http", "false") .put("http-server.process-forwarded", "true") - .build()) + .buildOrThrow()) .build(); server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestTestingTrinoClient::authenticate); diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java b/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java index b348bf46f912..75143adeb1f0 100644 --- a/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java +++ b/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java @@ -108,7 +108,7 @@ public class TestTableRedirection .collect(toImmutableMap( i -> schemaTableName(SCHEMA_THREE, REDIRECTION_CHAIN.get(i)), i -> schemaTableName(SCHEMA_THREE, REDIRECTION_CHAIN.get(i + 1))))) - .build(); + .buildOrThrow(); private static final Map> columnMetadatas = ImmutableMap.of( SCHEMA_ONE, diff --git a/testing/trino-tests/src/test/java/io/trino/memory/TestMemoryManager.java b/testing/trino-tests/src/test/java/io/trino/memory/TestMemoryManager.java index ef2e68721f5d..05f24233867f 100644 --- a/testing/trino-tests/src/test/java/io/trino/memory/TestMemoryManager.java +++ b/testing/trino-tests/src/test/java/io/trino/memory/TestMemoryManager.java @@ -89,7 +89,7 @@ public void testResourceOverCommit() .put("query.max-memory-per-node", "1kB") .put("query.max-total-memory-per-node", "1kB") .put("query.max-memory", "1kB") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { assertThatThrownBy(() -> queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk")) @@ -113,7 +113,7 @@ public void testOutOfMemoryKiller() .put("task.verbose-stats", "true") .put("query.low-memory-killer.delay", "5s") .put("query.low-memory-killer.policy", "total-reservation") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { // Reserve all the memory @@ -170,7 +170,7 @@ public void testReservedPoolDisabled() .put("experimental.reserved-pool-disabled", "true") .put("query.low-memory-killer.delay", "5s") .put("query.low-memory-killer.policy", "total-reservation") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { // Reserve all the memory @@ -220,7 +220,7 @@ private void testNoLeak(@Language("SQL") String query) Map properties = ImmutableMap.builder() .put("experimental.reserved-pool-disabled", "false") .put("task.verbose-stats", "true") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { executor.submit(() -> queryRunner.execute(query)).get(); @@ -247,7 +247,7 @@ public void testClusterPools() Map properties = ImmutableMap.builder() .put("experimental.reserved-pool-disabled", "false") .put("task.verbose-stats", "true") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { // Reserve all the memory @@ -353,7 +353,7 @@ public void testQueryUserMemoryLimit() .put("task.max-partial-aggregation-memory", "1B") .put("query.max-memory", "1kB") .put("query.max-total-memory", "1GB") - .build(); + .buildOrThrow(); try (QueryRunner queryRunner = createQueryRunner(SESSION, properties)) { queryRunner.execute(SESSION, "SELECT COUNT(*), repeat(orderstatus, 1000) FROM orders GROUP BY 2"); } @@ -366,7 +366,7 @@ public void testQueryTotalMemoryLimit() Map properties = ImmutableMap.builder() .put("query.max-memory", "1kB") .put("query.max-total-memory", "2kB") - .build(); + .buildOrThrow(); try (QueryRunner queryRunner = createQueryRunner(SESSION, properties)) { queryRunner.execute(SESSION, "SELECT COUNT(*), repeat(orderstatus, 1000) FROM orders GROUP BY 2"); } @@ -379,7 +379,7 @@ public void testQueryMemoryPerNodeLimit() Map properties = ImmutableMap.builder() .put("task.max-partial-aggregation-memory", "1B") .put("query.max-memory-per-node", "1kB") - .build(); + .buildOrThrow(); try (QueryRunner queryRunner = createQueryRunner(SESSION, properties)) { queryRunner.execute(SESSION, "SELECT COUNT(*), repeat(orderstatus, 1000) FROM orders GROUP BY 2"); } diff --git a/testing/trino-tests/src/test/java/io/trino/tests/AbstractTestEngineOnlyQueries.java b/testing/trino-tests/src/test/java/io/trino/tests/AbstractTestEngineOnlyQueries.java index 94595233e997..94651e8ec6ca 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/AbstractTestEngineOnlyQueries.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/AbstractTestEngineOnlyQueries.java @@ -5284,12 +5284,12 @@ public void testShowSession() ImmutableMap.builder() .put("test_string", "foo string") .put("test_long", "424242") - .build(), + .buildOrThrow(), ImmutableMap.of(), ImmutableMap.of(TESTING_CATALOG, ImmutableMap.builder() .put("connector_string", "bar string") .put("connector_long", "11") - .build()), + .buildOrThrow()), getQueryRunner().getSessionPropertyManager(), getSession().getPreparedStatements(), getSession().getProtocolHeaders()); diff --git a/testing/trino-tests/src/test/java/io/trino/tests/BaseQueryAssertionsTest.java b/testing/trino-tests/src/test/java/io/trino/tests/BaseQueryAssertionsTest.java index e531fd4ce104..4ef9921c8bb6 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/BaseQueryAssertionsTest.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/BaseQueryAssertionsTest.java @@ -77,7 +77,7 @@ protected void configureCatalog(QueryRunner queryRunner) Map jdbcWithAggregationPushdownDisabledConfigurationProperties = ImmutableMap.builder() .putAll(jdbcConfigurationProperties) .put("aggregation-pushdown.enabled", "false") - .build(); + .buildOrThrow(); queryRunner.createCatalog("jdbc_with_aggregation_pushdown_disabled", "base-jdbc", jdbcWithAggregationPushdownDisabledConfigurationProperties); } diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestDistributedSpilledQueries.java b/testing/trino-tests/src/test/java/io/trino/tests/TestDistributedSpilledQueries.java index dc45d910ac7a..c61df33dbab3 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestDistributedSpilledQueries.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestDistributedSpilledQueries.java @@ -53,7 +53,7 @@ public static DistributedQueryRunner createSpillingQueryRunner() .put("spiller-max-used-space-threshold", "1.0") .put("memory-revoking-threshold", "0.0") // revoke always .put("memory-revoking-target", "0.0") - .build(); + .buildOrThrow(); DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession) .setNodeCount(2) diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestGracefulShutdown.java b/testing/trino-tests/src/test/java/io/trino/tests/TestGracefulShutdown.java index 410d748f579e..c590088576b2 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestGracefulShutdown.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestGracefulShutdown.java @@ -70,7 +70,7 @@ public void testShutdown() Map properties = ImmutableMap.builder() .put("node-scheduler.include-coordinator", "false") .put("shutdown.grace-period", "10s") - .build(); + .buildOrThrow(); try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) { List> queryFutures = new ArrayList<>(); diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java b/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java index 5131015edec4..956050942e7c 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java @@ -50,7 +50,7 @@ public void testInsufficientWorkerNodes() .setCoordinatorProperties(ImmutableMap.builder() .put("query-manager.required-workers", "5") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(4) .build()) { queryRunner.execute("SELECT COUNT(*) from lineitem"); @@ -67,7 +67,7 @@ public void testInsufficientWorkerNodesWithCoordinatorExcluded() .put("node-scheduler.include-coordinator", "false") .put("query-manager.required-workers", "4") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(4) .build()) { queryRunner.execute("SELECT COUNT(*) from lineitem"); @@ -83,7 +83,7 @@ public void testInsufficientWorkerNodesInternalSystemQuery() .setCoordinatorProperties(ImmutableMap.builder() .put("query-manager.required-workers", "5") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(4) .build()) { queryRunner.execute("SELECT 1"); @@ -105,7 +105,7 @@ public void testInsufficientWorkerNodesAfterDrop() .setCoordinatorProperties(ImmutableMap.builder() .put("query-manager.required-workers", "4") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(4) .build()) { queryRunner.execute("SELECT COUNT(*) from lineitem"); @@ -127,7 +127,7 @@ public void testRequiredNodesMaxWaitSessionOverride() .setCoordinatorProperties(ImmutableMap.builder() .put("query-manager.required-workers", "3") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(2) .build()) { Session session = testSessionBuilder() @@ -149,7 +149,7 @@ public void testRequiredWorkerNodesSessionOverride() .setCoordinatorProperties(ImmutableMap.builder() .put("query-manager.required-workers", "5") .put("query-manager.required-workers-max-wait", "1ns") - .build()) + .buildOrThrow()) .setNodeCount(4) .build()) { // Query should be allowed to run if session override allows it diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestServer.java b/testing/trino-tests/src/test/java/io/trino/tests/TestServer.java index 53239818c2a5..8e949dfc0b4d 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestServer.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestServer.java @@ -94,7 +94,7 @@ public void setup() server = TestingTrinoServer.builder() .setProperties(ImmutableMap.builder() .put("http-server.process-forwarded", "true") - .build()) + .buildOrThrow()) .build(); server.installPlugin(new MemoryPlugin()); @@ -204,7 +204,7 @@ public void testQuery() .put(QUERY_MAX_MEMORY, "1GB") .put(JOIN_DISTRIBUTION_TYPE, "partitioned") .put(HASH_PARTITION_COUNT, "43") - .build()); + .buildOrThrow()); // verify client info in session assertEquals(queryInfo.getSession().getClientInfo().get(), "{\"clientVersion\":\"testVersion\"}"); @@ -212,7 +212,7 @@ public void testQuery() // verify prepared statements assertEquals(queryInfo.getSession().getPreparedStatements(), ImmutableMap.builder() .put("foo", "select * from bar") - .build()); + .buildOrThrow()); List> rows = data.build(); assertEquals(rows, ImmutableList.of(ImmutableList.of("memory"), ImmutableList.of("system"))); diff --git a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java index 6438a71ad728..6756cdc8ff3f 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java @@ -31,7 +31,7 @@ public static void main(String[] args) .put("http-server.http.port", "8080") .put("sql.default-catalog", "tpch") .put("sql.default-schema", "tiny") - .build()) + .buildOrThrow()) .build(); Thread.sleep(10); Logger log = Logger.get(TpchQueryRunner.class); diff --git a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunnerBuilder.java b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunnerBuilder.java index 3a6bdfefead0..748d712073c9 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunnerBuilder.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunnerBuilder.java @@ -95,7 +95,7 @@ public DistributedQueryRunner build() destinationCatalog.ifPresent(value -> properties.put(TPCH_TABLE_SCAN_REDIRECTION_CATALOG, value)); destinationSchema.ifPresent(value -> properties.put(TPCH_TABLE_SCAN_REDIRECTION_SCHEMA, value)); splitsPerNode.ifPresent(value -> properties.put(TPCH_SPLITS_PER_NODE, Integer.toString(value))); - queryRunner.createCatalog("tpch", "tpch", properties.build()); + queryRunner.createCatalog("tpch", "tpch", properties.buildOrThrow()); return queryRunner; } catch (Exception e) {