From 098e9c92325ebd35736a8a05dd2569116c946215 Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Wed, 27 Mar 2024 21:37:31 +0100 Subject: [PATCH 1/2] Replace lambda with method reference --- .../main/java/io/trino/cost/JoinStatsRule.java | 2 +- .../trino/dispatcher/LocalDispatchQuery.java | 2 +- .../minmaxbyn/TypedKeyValueHeap.java | 2 +- .../operator/join/LookupOuterOperator.java | 2 +- .../operator/join/NestedLoopJoinOperator.java | 2 +- .../unspilled/LookupJoinOperatorFactory.java | 4 ++-- .../src/main/java/io/trino/sql/ir/IrUtils.java | 4 ++-- .../io/trino/sql/planner/DomainTranslator.java | 3 ++- .../trino/sql/planner/EqualityInference.java | 2 +- .../sql/planner/LocalExecutionPlanner.java | 4 ++-- .../sql/planner/SortExpressionExtractor.java | 2 +- ...ractCommonPredicatesExpressionRewriter.java | 3 ++- .../OptimizeDuplicateInsensitiveJoins.java | 3 ++- .../rule/PushAggregationIntoTableScan.java | 2 +- .../rule/PushProjectionThroughJoin.java | 3 ++- .../optimizations/MetadataQueryOptimizer.java | 3 ++- ...ntifiedComparisonApplyToCorrelatedJoin.java | 5 +++-- .../trino/cost/TestAggregationStatsRule.java | 2 +- .../trino/execution/TestQueryStateMachine.java | 2 +- .../io/trino/operator/TestTopNOperator.java | 2 +- .../io/trino/sql/planner/BenchmarkPlanner.java | 5 ++--- .../sql/planner/TestEqualityInference.java | 12 ++++++------ .../java/io/trino/sql/tree/ShowGrants.java | 2 +- .../io/trino/filesystem/gcs/GcsFileSystem.java | 3 ++- .../NativeLogicalTypesAvroTypeManager.java | 2 +- .../predicate/TupleDomainParquetPredicate.java | 10 +++++----- .../zookeeper/client/StaticHostProvider.java | 2 +- .../plugin/jdbc/TestJdbcTableProperties.java | 2 +- .../plugin/jdbc/TestLazyConnectionFactory.java | 2 +- .../trino/plugin/jdbc/TestingH2JdbcModule.java | 2 +- .../bigquery/BaseBigQueryTypeMapping.java | 2 +- .../plugin/cassandra/CassandraTypeManager.java | 2 +- .../cassandra/TestCassandraConnectorTest.java | 18 +++++++++--------- .../plugin/hive/BaseHiveConnectorTest.java | 2 +- .../io/trino/plugin/pinot/PinotModule.java | 4 ++-- .../plugin/pinot/PinotSegmentPageSource.java | 2 +- .../trino/plugin/pinot/TestBrokerQueries.java | 2 +- .../plugin/snowflake/SnowflakeClient.java | 16 ++++++++-------- .../launcher/env/EnvironmentListener.java | 5 +---- 39 files changed, 76 insertions(+), 73 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/cost/JoinStatsRule.java b/core/trino-main/src/main/java/io/trino/cost/JoinStatsRule.java index 5dcb936dc404..18a028ed681b 100644 --- a/core/trino-main/src/main/java/io/trino/cost/JoinStatsRule.java +++ b/core/trino-main/src/main/java/io/trino/cost/JoinStatsRule.java @@ -273,7 +273,7 @@ PlanNodeStatsEstimate calculateJoinComplementStats( .map(drivingClause -> calculateJoinComplementStats(leftStats, rightStats, drivingClause, criteria.size() - 1 + numberOfFilterClauses)) .filter(estimate -> !estimate.isOutputRowCountUnknown()) .max(comparingDouble(PlanNodeStatsEstimate::getOutputRowCount)) - .map(estimate -> normalizer.normalize(estimate)) + .map(normalizer::normalize) .orElse(PlanNodeStatsEstimate.unknown()); } diff --git a/core/trino-main/src/main/java/io/trino/dispatcher/LocalDispatchQuery.java b/core/trino-main/src/main/java/io/trino/dispatcher/LocalDispatchQuery.java index 994b860204d5..25cd3e240014 100644 --- a/core/trino-main/src/main/java/io/trino/dispatcher/LocalDispatchQuery.java +++ b/core/trino-main/src/main/java/io/trino/dispatcher/LocalDispatchQuery.java @@ -127,7 +127,7 @@ private void waitForMinimumWorkers() ListenableFuture minimumWorkerFuture = clusterSizeMonitor.waitForMinimumWorkers(executionMinCount, getRequiredWorkersMaxWait(session)); // when worker requirement is met, start the execution addSuccessCallback(minimumWorkerFuture, () -> startExecution(queryExecution), queryExecutor); - addExceptionCallback(minimumWorkerFuture, throwable -> stateMachine.transitionToFailed(throwable), queryExecutor); + addExceptionCallback(minimumWorkerFuture, stateMachine::transitionToFailed, queryExecutor); // cancel minimumWorkerFuture if query fails for some reason or is cancelled by user stateMachine.addStateChangeListener(state -> { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxbyn/TypedKeyValueHeap.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxbyn/TypedKeyValueHeap.java index 60e7a64b973c..da2de6d4e56b 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxbyn/TypedKeyValueHeap.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxbyn/TypedKeyValueHeap.java @@ -182,7 +182,7 @@ public void writeValuesSorted(BlockBuilder valueBlockBuilder) for (int i = 0; i < indexes.length; i++) { indexes[i] = i; } - IntArrays.quickSort(indexes, (a, b) -> compare(a, b)); + IntArrays.quickSort(indexes, this::compare); for (int index : indexes) { write(index, null, valueBlockBuilder); diff --git a/core/trino-main/src/main/java/io/trino/operator/join/LookupOuterOperator.java b/core/trino-main/src/main/java/io/trino/operator/join/LookupOuterOperator.java index 97f5ac8eb73a..a8453f4633ff 100644 --- a/core/trino-main/src/main/java/io/trino/operator/join/LookupOuterOperator.java +++ b/core/trino-main/src/main/java/io/trino/operator/join/LookupOuterOperator.java @@ -73,7 +73,7 @@ public Operator createOperator(DriverContext driverContext) ListenableFuture outerPositionsFuture = joinBridgeManager.getOuterPositionsFuture(); OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, LookupOuterOperator.class.getSimpleName()); joinBridgeManager.outerOperatorCreated(); - return new LookupOuterOperator(operatorContext, outerPositionsFuture, probeOutputTypes, buildOutputTypes, () -> joinBridgeManager.outerOperatorClosed()); + return new LookupOuterOperator(operatorContext, outerPositionsFuture, probeOutputTypes, buildOutputTypes, joinBridgeManager::outerOperatorClosed); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/join/NestedLoopJoinOperator.java b/core/trino-main/src/main/java/io/trino/operator/join/NestedLoopJoinOperator.java index 534c932d47a3..797f4f62cbc2 100644 --- a/core/trino-main/src/main/java/io/trino/operator/join/NestedLoopJoinOperator.java +++ b/core/trino-main/src/main/java/io/trino/operator/join/NestedLoopJoinOperator.java @@ -100,7 +100,7 @@ public Operator createOperator(DriverContext driverContext) nestedLoopJoinBridge, probeChannels, buildChannels, - () -> joinBridgeManager.probeOperatorClosed()); + joinBridgeManager::probeOperatorClosed); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/join/unspilled/LookupJoinOperatorFactory.java b/core/trino-main/src/main/java/io/trino/operator/join/unspilled/LookupJoinOperatorFactory.java index 6d20cc151ee5..1122c53caa75 100644 --- a/core/trino-main/src/main/java/io/trino/operator/join/unspilled/LookupJoinOperatorFactory.java +++ b/core/trino-main/src/main/java/io/trino/operator/join/unspilled/LookupJoinOperatorFactory.java @@ -193,7 +193,7 @@ public WorkProcessorOperator create(ProcessorContext processorContext, WorkProce waitForBuild, lookupSourceFactory, joinProbeFactory, - () -> joinBridgeManager.probeOperatorClosed(), + joinBridgeManager::probeOperatorClosed, processorContext, Optional.of(sourcePages)); } @@ -212,7 +212,7 @@ public AdapterWorkProcessorOperator createAdapterOperator(ProcessorContext proce waitForBuild, lookupSourceFactory, joinProbeFactory, - () -> joinBridgeManager.probeOperatorClosed(), + joinBridgeManager::probeOperatorClosed, processorContext, Optional.empty()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java b/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java index eea2897ff943..5040c3d1ad03 100644 --- a/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java +++ b/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java @@ -204,12 +204,12 @@ public static Expression combineDisjunctsWithDefault(Collection expr public static Expression filterDeterministicConjuncts(Metadata metadata, Expression expression) { - return filterConjuncts(expression, expression1 -> DeterminismEvaluator.isDeterministic(expression1)); + return filterConjuncts(expression, DeterminismEvaluator::isDeterministic); } public static Expression filterNonDeterministicConjuncts(Metadata metadata, Expression expression) { - return filterConjuncts(expression, not(testExpression -> DeterminismEvaluator.isDeterministic(testExpression))); + return filterConjuncts(expression, not(DeterminismEvaluator::isDeterministic)); } public static Expression filterConjuncts(Expression expression, Predicate predicate) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java b/core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java index 8e6f9d1c16fa..35fb66776074 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java @@ -46,6 +46,7 @@ import io.trino.sql.ir.Constant; import io.trino.sql.ir.Expression; import io.trino.sql.ir.In; +import io.trino.sql.ir.IrUtils; import io.trino.sql.ir.IrVisitor; import io.trino.sql.ir.IsNull; import io.trino.sql.ir.Logical; @@ -114,7 +115,7 @@ public Expression toPredicate(TupleDomain tupleDomain) Map domains = tupleDomain.getDomains().get(); return domains.entrySet().stream() .map(entry -> toPredicate(entry.getValue(), entry.getKey().toSymbolReference())) - .collect(collectingAndThen(toImmutableList(), expressions -> combineConjuncts(expressions))); + .collect(collectingAndThen(toImmutableList(), IrUtils::combineConjuncts)); } private Expression toPredicate(Domain domain, Reference reference) 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 c37fbb97c4f5..200543e6b3d8 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 @@ -71,7 +71,7 @@ public EqualityInference(Collection expressions) DisjointSet equalities = new DisjointSet<>(); expressions.stream() .flatMap(expression -> extractConjuncts(expression).stream()) - .filter(expression -> isInferenceCandidate(expression)) + .filter(EqualityInference::isInferenceCandidate) .forEach(expression -> { Comparison comparison = (Comparison) expression; Expression expression1 = comparison.left(); 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 e47c533803b4..2097182d2254 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 @@ -638,7 +638,7 @@ public LocalExecutionPlan plan( Function pagePreprocessor = enforceLoadedLayoutProcessor(outputLayout, physicalOperation.getLayout()); List outputTypes = outputLayout.stream() - .map(symbol -> symbol.getType()) + .map(Symbol::getType) .collect(toImmutableList()); context.addDriverFactory( @@ -3698,7 +3698,7 @@ private List getSourceOperatorTypes(PlanNode node) private List getSymbolTypes(List symbols) { return symbols.stream() - .map(symbol -> symbol.getType()) + .map(Symbol::getType) .collect(toImmutableList()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/SortExpressionExtractor.java b/core/trino-main/src/main/java/io/trino/sql/planner/SortExpressionExtractor.java index a0ec155fb424..7d0f59b521ff 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/SortExpressionExtractor.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/SortExpressionExtractor.java @@ -64,7 +64,7 @@ public static Optional extractSortExpression(Set SortExpressionVisitor visitor = new SortExpressionVisitor(buildSymbols); List sortExpressionCandidates = ImmutableList.copyOf(filterConjuncts.stream() - .filter(expression -> DeterminismEvaluator.isDeterministic(expression)) + .filter(DeterminismEvaluator::isDeterministic) .map(visitor::process) .filter(Optional::isPresent) .map(Optional::get) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExtractCommonPredicatesExpressionRewriter.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExtractCommonPredicatesExpressionRewriter.java index 714baa82c6d9..13375d43c550 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExtractCommonPredicatesExpressionRewriter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/ExtractCommonPredicatesExpressionRewriter.java @@ -20,6 +20,7 @@ import io.trino.sql.ir.ExpressionRewriter; import io.trino.sql.ir.ExpressionTreeRewriter; import io.trino.sql.ir.Logical; +import io.trino.sql.planner.DeterminismEvaluator; import java.util.Collection; import java.util.List; @@ -168,7 +169,7 @@ private Expression distributeIfPossible(Logical expression) private Set filterDeterministicPredicates(List predicates) { return predicates.stream() - .filter(expression -> isDeterministic(expression)) + .filter(DeterminismEvaluator::isDeterministic) .collect(toSet()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/OptimizeDuplicateInsensitiveJoins.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/OptimizeDuplicateInsensitiveJoins.java index d19d44ccb8f3..c3f3ebf6c466 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/OptimizeDuplicateInsensitiveJoins.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/OptimizeDuplicateInsensitiveJoins.java @@ -18,6 +18,7 @@ import io.trino.Session; import io.trino.matching.Captures; import io.trino.matching.Pattern; +import io.trino.sql.planner.DeterminismEvaluator; import io.trino.sql.planner.iterative.GroupReference; import io.trino.sql.planner.iterative.Lookup; import io.trino.sql.planner.iterative.Rule; @@ -103,7 +104,7 @@ public Optional visitFilter(FilterNode node, Void context) public Optional visitProject(ProjectNode node, Void context) { boolean isDeterministic = node.getAssignments().getExpressions().stream() - .allMatch(expression -> isDeterministic(expression)); + .allMatch(DeterminismEvaluator::isDeterministic); if (!isDeterministic) { // non-deterministic projections could be used in downstream filters which could // filter duplicate rows probabilistically diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationIntoTableScan.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationIntoTableScan.java index 467d0602dc1c..1681ab3f3eda 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationIntoTableScan.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushAggregationIntoTableScan.java @@ -141,7 +141,7 @@ public static Optional pushAggregationIntoTableScan( List aggregateFunctions = aggregationsList.stream() .map(Entry::getValue) - .map(aggregation -> toAggregateFunction(aggregation)) + .map(PushAggregationIntoTableScan::toAggregateFunction) .collect(toImmutableList()); List aggregationOutputSymbols = aggregationsList.stream() diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughJoin.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughJoin.java index 41f4326cdcb9..c18c0456ec43 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughJoin.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushProjectionThroughJoin.java @@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; import io.trino.sql.ir.Expression; +import io.trino.sql.planner.DeterminismEvaluator; import io.trino.sql.planner.PlanNodeIdAllocator; import io.trino.sql.planner.Symbol; import io.trino.sql.planner.SymbolsExtractor; @@ -48,7 +49,7 @@ public static Optional pushProjectionThroughJoin( Lookup lookup, PlanNodeIdAllocator planNodeIdAllocator) { - if (!projectNode.getAssignments().getExpressions().stream().allMatch(expression -> isDeterministic(expression))) { + if (!projectNode.getAssignments().getExpressions().stream().allMatch(DeterminismEvaluator::isDeterministic)) { return Optional.empty(); } 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 e1e309bff1cf..e5dbbfeeeed0 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 @@ -31,6 +31,7 @@ import io.trino.sql.ir.Constant; import io.trino.sql.ir.Expression; import io.trino.sql.ir.Row; +import io.trino.sql.planner.DeterminismEvaluator; import io.trino.sql.planner.PlanNodeIdAllocator; import io.trino.sql.planner.Symbol; import io.trino.sql.planner.plan.AggregationNode; @@ -186,7 +187,7 @@ private Optional findTableScan(PlanNode source) } else if (source instanceof ProjectNode project) { // verify projections are deterministic - if (!Iterables.all(project.getAssignments().getExpressions(), expression -> isDeterministic(expression))) { + if (!Iterables.all(project.getAssignments().getExpressions(), DeterminismEvaluator::isDeterministic)) { return Optional.empty(); } source = project.getSource(); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/TransformQuantifiedComparisonApplyToCorrelatedJoin.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/TransformQuantifiedComparisonApplyToCorrelatedJoin.java index 6412b812f636..f6a53c241cd7 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/TransformQuantifiedComparisonApplyToCorrelatedJoin.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/TransformQuantifiedComparisonApplyToCorrelatedJoin.java @@ -22,6 +22,7 @@ import io.trino.sql.ir.Comparison; import io.trino.sql.ir.Constant; import io.trino.sql.ir.Expression; +import io.trino.sql.ir.IrUtils; import io.trino.sql.ir.Switch; import io.trino.sql.ir.WhenClause; import io.trino.sql.planner.PlanNodeIdAllocator; @@ -179,11 +180,11 @@ public Expression rewriteUsingBounds(ApplyNode.QuantifiedComparison quantifiedCo Function, Expression> quantifier; if (quantifiedComparison.quantifier() == ALL) { emptySetResult = TRUE; - quantifier = expressions -> combineConjuncts(expressions); + quantifier = IrUtils::combineConjuncts; } else { emptySetResult = FALSE; - quantifier = expressions -> combineDisjuncts(expressions); + quantifier = IrUtils::combineDisjuncts; } Expression comparisonWithExtremeValue = getBoundComparisons(quantifiedComparison, minValue, maxValue); diff --git a/core/trino-main/src/test/java/io/trino/cost/TestAggregationStatsRule.java b/core/trino-main/src/test/java/io/trino/cost/TestAggregationStatsRule.java index 1a1a02b3b799..b0a12c57a83b 100644 --- a/core/trino-main/src/test/java/io/trino/cost/TestAggregationStatsRule.java +++ b/core/trino-main/src/test/java/io/trino/cost/TestAggregationStatsRule.java @@ -182,6 +182,6 @@ public void testAggregationWithMoreGroupingSets() .addSymbolStatistics(new Symbol(UNKNOWN, "y"), SymbolStatsEstimate.builder().setDistinctValuesCount(50).build()) .addSymbolStatistics(new Symbol(UNKNOWN, "z"), SymbolStatsEstimate.builder().setDistinctValuesCount(50).build()) .build()) - .check(check -> check.outputRowsCountUnknown()); + .check(PlanNodeStatsAssertion::outputRowsCountUnknown); } } 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 d40f9c65b137..54e75e633b4e 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 @@ -881,7 +881,7 @@ public QueryStateMachine build() if (setAuthorizationUser != null) { stateMachine.setSetAuthorizationUser(setAuthorizationUser); } - addPreparedStatements.forEach((key, value) -> stateMachine.addPreparedStatement(key, value)); + addPreparedStatements.forEach(stateMachine::addPreparedStatement); if (transactionId != null) { stateMachine.setStartedTransactionId(transactionId); } diff --git a/core/trino-main/src/test/java/io/trino/operator/TestTopNOperator.java b/core/trino-main/src/test/java/io/trino/operator/TestTopNOperator.java index 5ca535088280..8293afd2ba2d 100644 --- a/core/trino-main/src/test/java/io/trino/operator/TestTopNOperator.java +++ b/core/trino-main/src/test/java/io/trino/operator/TestTopNOperator.java @@ -200,7 +200,7 @@ public void testExceedMemoryLimit() ImmutableList.of(ASC_NULLS_LAST)); Operator operator = operatorFactory.createOperator(smallDiverContext); operator.addInput(input.get(0)); - assertThatThrownBy(() -> operator.getOutput()) + assertThatThrownBy(operator::getOutput) .isInstanceOf(ExceededMemoryLimitException.class) .hasMessageStartingWith("Query exceeded per-node memory limit of "); } diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/BenchmarkPlanner.java b/core/trino-main/src/test/java/io/trino/sql/planner/BenchmarkPlanner.java index bf6379dff3aa..09605b09ae6d 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/BenchmarkPlanner.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/BenchmarkPlanner.java @@ -165,7 +165,7 @@ public static enum Queries .collect(joining(", ", "(", ")")))), // 86k columns present in the query with 500 group bys MULTIPLE_GROUP_BY(() -> ImmutableList.of("WITH " + IntStream.rangeClosed(0, 500) - .mapToObj(i -> """ + .mapToObj(""" t%s AS ( SELECT * FROM lineitem a JOIN tiny.lineitem b ON a.l_orderkey = b.l_orderkey @@ -173,8 +173,7 @@ public static enum Queries JOIN sf100.lineitem d ON a.l_orderkey = d.l_orderkey JOIN sf1000.lineitem e ON a.l_orderkey = e.l_orderkey WHERE a.l_orderkey = (SELECT max(o_orderkey) FROM orders GROUP BY o_orderkey)) - """ - .formatted(i)) + """::formatted) .collect(joining(",")) + "SELECT 1 FROM lineitem")), GROUP_BY_WITH_MANY_REFERENCED_COLUMNS(() -> ImmutableList.of("SELECT * FROM mock.default.t GROUP BY " + diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestEqualityInference.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestEqualityInference.java index b1d8edd8dea1..85a3973352ac 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestEqualityInference.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestEqualityInference.java @@ -182,17 +182,17 @@ public void testEqualityPartitionGeneration() // There should be equalities in the scope, that only use c1 and are all inferrable equalities assertThat(equalityPartition.getScopeEqualities().isEmpty()).isFalse(); assertThat(Iterables.all(equalityPartition.getScopeEqualities(), matchesSymbolScope(matchesSymbols("c1")))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // There should be equalities in the inverse scope, that never use c1 and are all inferrable equalities assertThat(equalityPartition.getScopeComplementEqualities().isEmpty()).isFalse(); assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), matchesSymbolScope(not(matchesSymbols("c1"))))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // There should be equalities in the straddling scope, that should use both c1 and not c1 symbols assertThat(equalityPartition.getScopeStraddlingEqualities().isEmpty()).isFalse(); assertThat(Iterables.any(equalityPartition.getScopeStraddlingEqualities(), matchesStraddlingScope(matchesSymbols("c1")))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeStraddlingEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeStraddlingEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // There should be a "full cover" of all of the equalities used // THUS, we should be able to plug the generated equalities back in and get an equivalent set of equalities back the next time around @@ -227,17 +227,17 @@ public void testMultipleEqualitySetsPredicateGeneration() // There should be equalities in the scope, that only use a* and b* symbols and are all inferrable equalities assertThat(equalityPartition.getScopeEqualities().isEmpty()).isFalse(); assertThat(Iterables.all(equalityPartition.getScopeEqualities(), matchesSymbolScope(symbolBeginsWith("a", "b")))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // There should be equalities in the inverse scope, that never use a* and b* symbols and are all inferrable equalities assertThat(equalityPartition.getScopeComplementEqualities().isEmpty()).isFalse(); assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), matchesSymbolScope(not(symbolBeginsWith("a", "b"))))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeComplementEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // There should be equalities in the straddling scope, that should use both c1 and not c1 symbols assertThat(equalityPartition.getScopeStraddlingEqualities().isEmpty()).isFalse(); assertThat(Iterables.any(equalityPartition.getScopeStraddlingEqualities(), matchesStraddlingScope(symbolBeginsWith("a", "b")))).isTrue(); - assertThat(Iterables.all(equalityPartition.getScopeStraddlingEqualities(), expression -> isInferenceCandidate(expression))).isTrue(); + assertThat(Iterables.all(equalityPartition.getScopeStraddlingEqualities(), EqualityInference::isInferenceCandidate)).isTrue(); // Again, there should be a "full cover" of all of the equalities used // THUS, we should be able to plug the generated equalities back in and get an equivalent set of equalities back the next time around diff --git a/core/trino-parser/src/main/java/io/trino/sql/tree/ShowGrants.java b/core/trino-parser/src/main/java/io/trino/sql/tree/ShowGrants.java index 9f6ab63c94ee..4d33d185122c 100644 --- a/core/trino-parser/src/main/java/io/trino/sql/tree/ShowGrants.java +++ b/core/trino-parser/src/main/java/io/trino/sql/tree/ShowGrants.java @@ -44,7 +44,7 @@ public ShowGrants(Optional location, Optional grantOb public Optional getEntityKind() { - return grantObject.flatMap(scope -> scope.getEntityKind()); + return grantObject.flatMap(GrantObject::getEntityKind); } public Optional getGrantObject() diff --git a/lib/trino-filesystem-gcs/src/main/java/io/trino/filesystem/gcs/GcsFileSystem.java b/lib/trino-filesystem-gcs/src/main/java/io/trino/filesystem/gcs/GcsFileSystem.java index c971925b3491..1fce21f00270 100644 --- a/lib/trino-filesystem-gcs/src/main/java/io/trino/filesystem/gcs/GcsFileSystem.java +++ b/lib/trino-filesystem-gcs/src/main/java/io/trino/filesystem/gcs/GcsFileSystem.java @@ -15,6 +15,7 @@ import com.google.api.gax.paging.Page; import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Storage; import com.google.cloud.storage.Storage.BlobListOption; import com.google.cloud.storage.StorageBatch; @@ -250,7 +251,7 @@ public Set listDirectories(Location location) GcsLocation gcsLocation = new GcsLocation(normalizeToDirectory(location)); try { Page page = getPage(gcsLocation, currentDirectory(), matchGlob(gcsLocation.path() + "*/")); - Iterator blobIterator = Iterators.filter(page.iterateAll().iterator(), blob -> blob.isDirectory()); + Iterator blobIterator = Iterators.filter(page.iterateAll().iterator(), BlobInfo::isDirectory); ImmutableSet.Builder locationBuilder = ImmutableSet.builder(); while (blobIterator.hasNext()) { locationBuilder.add(Location.of(gcsLocation.getBase() + blobIterator.next().getName())); diff --git a/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/avro/NativeLogicalTypesAvroTypeManager.java b/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/avro/NativeLogicalTypesAvroTypeManager.java index 84a72f09d10a..4f5f4f4aa627 100644 --- a/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/avro/NativeLogicalTypesAvroTypeManager.java +++ b/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/avro/NativeLogicalTypesAvroTypeManager.java @@ -238,7 +238,7 @@ private static BiFunction getAvroFunction(LogicalType lo } if (timestampType.isShort()) { // Don't use method reference because it causes an NPE in errorprone - yield (block, position) -> timestampType.getLong(block, position); + yield timestampType::getLong; } else { yield (block, position) -> diff --git a/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/TupleDomainParquetPredicate.java b/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/TupleDomainParquetPredicate.java index 3a49bc2fc5c8..a881975a3186 100644 --- a/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/TupleDomainParquetPredicate.java +++ b/lib/trino-parquet/src/main/java/io/trino/parquet/predicate/TupleDomainParquetPredicate.java @@ -810,11 +810,11 @@ private Function getConverter(PrimitiveType primitiveType) { return switch (primitiveType.getPrimitiveTypeName()) { case BOOLEAN -> throw new ParquetDecodingException("Dictionary encoding does not support: " + primitiveType.getPrimitiveTypeName()); - case INT32 -> (i) -> dictionary.decodeToInt(i); - case INT64 -> (i) -> dictionary.decodeToLong(i); - case FLOAT -> (i) -> dictionary.decodeToFloat(i); - case DOUBLE -> (i) -> dictionary.decodeToDouble(i); - case FIXED_LEN_BYTE_ARRAY, BINARY, INT96 -> (i) -> dictionary.decodeToSlice(i); + case INT32 -> dictionary::decodeToInt; + case INT64 -> dictionary::decodeToLong; + case FLOAT -> dictionary::decodeToFloat; + case DOUBLE -> dictionary::decodeToDouble; + case FIXED_LEN_BYTE_ARRAY, BINARY, INT96 -> dictionary::decodeToSlice; }; } } diff --git a/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java b/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java index 1f8a7517b948..3b475118fa30 100644 --- a/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java +++ b/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java @@ -48,7 +48,7 @@ InetAddress[] getAllByName(String name) */ public StaticHostProvider(Collection serverAddresses) { - this.resolver = name -> InetAddress.getAllByName(name); + this.resolver = InetAddress::getAllByName; init(serverAddresses); } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcTableProperties.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcTableProperties.java index 8dc5ab420eaf..2bb7e5d5003c 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcTableProperties.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcTableProperties.java @@ -66,7 +66,7 @@ public void testGetTablePropertiesIsNotCalledForSelect() public void testGetTablePropertiesIsCalled() { AtomicInteger counter = new AtomicInteger(); - onGetTableProperties = () -> counter.incrementAndGet(); + onGetTableProperties = counter::incrementAndGet; assertQuerySucceeds("SHOW CREATE TABLE nation"); assertThat(counter.get()).isOne(); } diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java index b514da62efb8..797faadd65b3 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestLazyConnectionFactory.java @@ -62,7 +62,7 @@ public void testConnectionCannotBeReusedAfterClose() try (LazyConnectionFactory lazyConnectionFactory = injector.getInstance(LazyConnectionFactory.class)) { Connection connection = lazyConnectionFactory.openConnection(SESSION); connection.close(); - assertThatThrownBy(() -> connection.createStatement()) + assertThatThrownBy(connection::createStatement) .hasMessage("Connection is already closed"); } } 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 5f3f5d1b81cb..0f9e98c1b4ef 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 @@ -39,7 +39,7 @@ public class TestingH2JdbcModule public TestingH2JdbcModule() { - this((config, connectionFactory, identifierMapping) -> new TestingH2JdbcClient(config, connectionFactory, identifierMapping)); + this(TestingH2JdbcClient::new); } public TestingH2JdbcModule(TestingH2JdbcClientFactory testingH2JdbcClientFactory) diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryTypeMapping.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryTypeMapping.java index b3374bd27f3c..de5d9abc4bb7 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryTypeMapping.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/BaseBigQueryTypeMapping.java @@ -825,6 +825,6 @@ private DataSetup bigqueryViewCreateAndInsert(String tableNamePrefix) private SqlExecutor getBigQuerySqlExecutor() { - return sql -> bigQuerySqlExecutor.execute(sql); + return bigQuerySqlExecutor; } } diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java index f0311c869728..6753c4f41970 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java @@ -150,7 +150,7 @@ private Optional createTypeForTuple(DataType dataType) { TupleType tupleType = (TupleType) dataType; List> argumentTypesOptionals = tupleType.getComponentTypes().stream() - .map(componentType -> toCassandraType(componentType)) + .map(this::toCassandraType) .collect(toImmutableList()); if (argumentTypesOptionals.stream().anyMatch(Optional::isEmpty)) { diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java index 6dc4e831701d..617769ec4479 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java @@ -450,9 +450,9 @@ public void testSelect() columnsValue(9, ImmutableList.of( rowNumber -> format("'key %d'", rowNumber), rowNumber -> format("00000000-0000-0000-0000-%012d", rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), + String::valueOf, + String::valueOf, + String::valueOf, rowNumber -> String.valueOf(rowNumber + 1000), rowNumber -> toHexString(ByteBuffer.wrap(Ints.toByteArray(rowNumber)).asReadOnlyBuffer()), rowNumber -> format("'%s'", DateTimeFormatter.ofPattern("uuuu-MM-dd").format(TIMESTAMP_VALUE)), @@ -499,9 +499,9 @@ public void testSelect() columnsValue(9, ImmutableList.of( rowNumber -> format("'key %d'", rowNumber), rowNumber -> format("00000000-0000-0000-0000-%012d", rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), + String::valueOf, + String::valueOf, + String::valueOf, rowNumber -> String.valueOf(rowNumber + 1000), rowNumber -> toHexString(ByteBuffer.wrap(Ints.toByteArray(rowNumber))), rowNumber -> format("'%s'", DateTimeFormatter.ofPattern("uuuu-MM-dd").format(TIMESTAMP_VALUE)), @@ -562,9 +562,9 @@ public void testCreateTableAs() columnsValue(9, ImmutableList.of( rowNumber -> format("'key %d'", rowNumber), rowNumber -> format("00000000-0000-0000-0000-%012d", rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), - rowNumber -> String.valueOf(rowNumber), + String::valueOf, + String::valueOf, + String::valueOf, rowNumber -> String.valueOf(rowNumber + 1000), rowNumber -> toHexString(ByteBuffer.wrap(Ints.toByteArray(rowNumber))), rowNumber -> format("'%s'", DateTimeFormatter.ofPattern("uuuu-MM-dd").format(TIMESTAMP_VALUE)), diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index 33f7aa52ca3e..2ccf6381f17b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -8633,7 +8633,7 @@ private void testTimestampPrecisionInsert(Session session, HiveStorageFormat sto @Test public void testTimestampPrecisionCtas() { - testWithAllStorageFormats((session, storageFormat) -> testTimestampPrecisionCtas(session, storageFormat)); + testWithAllStorageFormats(this::testTimestampPrecisionCtas); } private void testTimestampPrecisionCtas(Session session, HiveStorageFormat storageFormat) diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotModule.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotModule.java index c019ec43e844..87d295b76129 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotModule.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotModule.java @@ -99,7 +99,7 @@ public void setup(Binder binder) install(conditionalModule( PinotConfig.class, - config -> config.isGrpcEnabled(), + PinotConfig::isGrpcEnabled, new PinotGrpcModule(), new LegacyClientModule())); } @@ -136,7 +136,7 @@ public void setup(Binder binder) binder.bind(PinotDataFetcher.Factory.class).to(PinotGrpcDataFetcher.Factory.class).in(Scopes.SINGLETON); install(conditionalModule( PinotGrpcServerQueryClientConfig.class, - config -> config.isUsePlainText(), + PinotGrpcServerQueryClientConfig::isUsePlainText, plainTextBinder -> plainTextBinder.bind(PinotGrpcDataFetcher.GrpcQueryClientFactory.class).to(PinotGrpcDataFetcher.PlainTextGrpcQueryClientFactory.class).in(Scopes.SINGLETON), tlsBinder -> { configBinder(tlsBinder).bindConfig(PinotGrpcServerQueryClientTlsConfig.class); diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotSegmentPageSource.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotSegmentPageSource.java index c00c5c61c474..20f4e085a04d 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotSegmentPageSource.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotSegmentPageSource.java @@ -71,7 +71,7 @@ public PinotSegmentPageSource( this.columnHandles = requireNonNull(columnHandles, "columnHandles is null"); this.columnTypes = columnHandles .stream() - .map(columnHandle -> columnHandle.getDataType()) + .map(PinotColumnHandle::getDataType) .collect(Collectors.toList()); this.targetSegmentPageSizeBytes = targetSegmentPageSizeBytes; this.pinotDataFetcher = requireNonNull(pinotDataFetcher, "pinotDataFetcher is null"); diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java index 61d5430f6bed..ac61ad881a80 100644 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java @@ -169,7 +169,7 @@ public void testBrokerResponseHasTooManyRows() testingPinotClient, LIMIT_FOR_BROKER_QUERIES); assertThatExceptionOfType(PinotException.class) - .isThrownBy(() -> pageSource.getNextPage()) + .isThrownBy(pageSource::getNextPage) .withMessage("Broker query returned '3' rows, maximum allowed is '2' rows. with query \"SELECT col_1, col_2, col_3 FROM test_table\""); } } diff --git a/plugin/trino-snowflake/src/main/java/io/trino/plugin/snowflake/SnowflakeClient.java b/plugin/trino-snowflake/src/main/java/io/trino/plugin/snowflake/SnowflakeClient.java index da831cb28df2..e1865592758b 100644 --- a/plugin/trino-snowflake/src/main/java/io/trino/plugin/snowflake/SnowflakeClient.java +++ b/plugin/trino-snowflake/src/main/java/io/trino/plugin/snowflake/SnowflakeClient.java @@ -235,14 +235,14 @@ public WriteMapping toWriteMapping(ConnectorSession session, Type type) final Map snowflakeWriteMappings = ImmutableMap.builder() .put("TimeType", writeType -> WriteMapping.longMapping("time", timeWriteFunction(((TimeType) writeType).getPrecision()))) - .put("ShortTimestampType", writeType -> SnowflakeClient.snowFlakeTimestampWriter(writeType)) - .put("ShortTimestampWithTimeZoneType", writeType -> SnowflakeClient.snowFlakeTimestampWithTZWriter(writeType)) - .put("LongTimestampType", writeType -> SnowflakeClient.snowFlakeTimestampWithTZWriter(writeType)) - .put("LongTimestampWithTimeZoneType", writeType -> SnowflakeClient.snowFlakeTimestampWithTZWriter(writeType)) - .put("VarcharType", writeType -> SnowflakeClient.snowFlakeVarCharWriter(writeType)) - .put("CharType", writeType -> SnowflakeClient.snowFlakeCharWriter(writeType)) - .put("LongDecimalType", writeType -> SnowflakeClient.snowFlakeDecimalWriter(writeType)) - .put("ShortDecimalType", writeType -> SnowflakeClient.snowFlakeDecimalWriter(writeType)) + .put("ShortTimestampType", SnowflakeClient::snowFlakeTimestampWriter) + .put("ShortTimestampWithTimeZoneType", SnowflakeClient::snowFlakeTimestampWithTZWriter) + .put("LongTimestampType", SnowflakeClient::snowFlakeTimestampWithTZWriter) + .put("LongTimestampWithTimeZoneType", SnowflakeClient::snowFlakeTimestampWithTZWriter) + .put("VarcharType", SnowflakeClient::snowFlakeVarCharWriter) + .put("CharType", SnowflakeClient::snowFlakeCharWriter) + .put("LongDecimalType", SnowflakeClient::snowFlakeDecimalWriter) + .put("ShortDecimalType", SnowflakeClient::snowFlakeDecimalWriter) .buildOrThrow(); WriteMappingFunction writeMappingFunction = snowflakeWriteMappings.get(simple); diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java index db074142a32b..cc25199b21ea 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentListener.java @@ -231,10 +231,7 @@ public void environmentStopping(Environment environment) public void environmentStarted(Environment environment) { // Print stats for all containers every 30s after environment is started - executorService.scheduleWithFixedDelay(() -> - { - printContainerStats(); - }, 5 * 1000L, 30 * 1000L, MILLISECONDS); + executorService.scheduleWithFixedDelay(this::printContainerStats, 5 * 1000L, 30 * 1000L, MILLISECONDS); } @Override From a2dfcd30bc9a8950d0e76dfadb78fec42a61a71d Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Wed, 27 Mar 2024 21:39:53 +0100 Subject: [PATCH 2/2] Remove unused argument --- .../main/java/io/trino/sql/ir/IrUtils.java | 5 ++-- .../planner/EffectivePredicateExtractor.java | 2 +- ...emoveRedundantPredicateAboveTableScan.java | 4 +-- .../optimizations/PredicatePushDown.java | 26 +++++++++---------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java b/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java index 5040c3d1ad03..438354f9ef9b 100644 --- a/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java +++ b/core/trino-main/src/main/java/io/trino/sql/ir/IrUtils.java @@ -17,7 +17,6 @@ import com.google.common.collect.Iterables; import com.google.common.graph.SuccessorsFunction; import com.google.common.graph.Traverser; -import io.trino.metadata.Metadata; import io.trino.spi.type.Type; import io.trino.sql.planner.DeterminismEvaluator; import io.trino.sql.planner.Symbol; @@ -202,12 +201,12 @@ public static Expression combineDisjunctsWithDefault(Collection expr return disjuncts.isEmpty() ? emptyDefault : or(disjuncts); } - public static Expression filterDeterministicConjuncts(Metadata metadata, Expression expression) + public static Expression filterDeterministicConjuncts(Expression expression) { return filterConjuncts(expression, DeterminismEvaluator::isDeterministic); } - public static Expression filterNonDeterministicConjuncts(Metadata metadata, Expression expression) + public static Expression filterNonDeterministicConjuncts(Expression expression) { return filterConjuncts(expression, not(DeterminismEvaluator::isDeterministic)); } 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 bb3a74074b43..4e1215c598e6 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 @@ -162,7 +162,7 @@ public Expression visitFilter(FilterNode node, Void context) Expression predicate = node.getPredicate(); // Remove non-deterministic conjuncts - predicate = filterDeterministicConjuncts(metadata, predicate); + predicate = filterDeterministicConjuncts(predicate); return combineConjuncts(predicate, underlyingPredicate); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RemoveRedundantPredicateAboveTableScan.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RemoveRedundantPredicateAboveTableScan.java index ab4875a1e177..ca9a822c4137 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RemoveRedundantPredicateAboveTableScan.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/RemoveRedundantPredicateAboveTableScan.java @@ -85,8 +85,8 @@ public Result apply(FilterNode filterNode, Captures captures, Context context) TableScanNode node = captures.get(TABLE_SCAN); Expression predicate = filterNode.getPredicate(); - Expression deterministicPredicate = filterDeterministicConjuncts(plannerContext.getMetadata(), predicate); - Expression nonDeterministicPredicate = filterNonDeterministicConjuncts(plannerContext.getMetadata(), predicate); + Expression deterministicPredicate = filterDeterministicConjuncts(predicate); + Expression nonDeterministicPredicate = filterNonDeterministicConjuncts(predicate); ExtractionResult decomposedPredicate = getFullyExtractedPredicates( session, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PredicatePushDown.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PredicatePushDown.java index 9fec25b78544..0902310ec4e7 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PredicatePushDown.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PredicatePushDown.java @@ -824,14 +824,14 @@ private OuterJoinPushDownResult processLimitedOuterJoin( extractConjuncts(inheritedPredicate).stream() .filter(expression -> !isDeterministic(expression)) .forEach(postJoinConjuncts::add); - inheritedPredicate = filterDeterministicConjuncts(metadata, inheritedPredicate); + inheritedPredicate = filterDeterministicConjuncts(inheritedPredicate); - outerEffectivePredicate = filterDeterministicConjuncts(metadata, outerEffectivePredicate); - innerEffectivePredicate = filterDeterministicConjuncts(metadata, innerEffectivePredicate); + outerEffectivePredicate = filterDeterministicConjuncts(outerEffectivePredicate); + innerEffectivePredicate = filterDeterministicConjuncts(innerEffectivePredicate); extractConjuncts(joinPredicate).stream() .filter(expression -> !isDeterministic(expression)) .forEach(joinConjuncts::add); - joinPredicate = filterDeterministicConjuncts(metadata, joinPredicate); + joinPredicate = filterDeterministicConjuncts(joinPredicate); // Generate equality inferences EqualityInference inheritedInference = new EqualityInference(inheritedPredicate); @@ -956,15 +956,15 @@ private InnerJoinPushDownResult processInnerJoin( extractConjuncts(inheritedPredicate).stream() .filter(deterministic -> !isDeterministic(deterministic)) .forEach(joinConjuncts::add); - inheritedPredicate = filterDeterministicConjuncts(metadata, inheritedPredicate); + inheritedPredicate = filterDeterministicConjuncts(inheritedPredicate); extractConjuncts(joinPredicate).stream() .filter(expression -> !isDeterministic(expression)) .forEach(joinConjuncts::add); - joinPredicate = filterDeterministicConjuncts(metadata, joinPredicate); + joinPredicate = filterDeterministicConjuncts(joinPredicate); - leftEffectivePredicate = filterDeterministicConjuncts(metadata, leftEffectivePredicate); - rightEffectivePredicate = filterDeterministicConjuncts(metadata, rightEffectivePredicate); + leftEffectivePredicate = filterDeterministicConjuncts(leftEffectivePredicate); + rightEffectivePredicate = filterDeterministicConjuncts(rightEffectivePredicate); ImmutableSet leftScope = ImmutableSet.copyOf(leftSymbols); ImmutableSet rightScope = ImmutableSet.copyOf(rightSymbols); @@ -1300,9 +1300,9 @@ private PlanNode visitNonFilteringSemiJoin(SemiJoinNode node, RewriteContext context) { Expression inheritedPredicate = context.get(); - Expression deterministicInheritedPredicate = filterDeterministicConjuncts(metadata, inheritedPredicate); - Expression sourceEffectivePredicate = filterDeterministicConjuncts(metadata, effectivePredicateExtractor.extract(session, node.getSource())); - Expression filteringSourceEffectivePredicate = filterDeterministicConjuncts(metadata, effectivePredicateExtractor.extract(session, node.getFilteringSource())); + Expression deterministicInheritedPredicate = filterDeterministicConjuncts(inheritedPredicate); + Expression sourceEffectivePredicate = filterDeterministicConjuncts(effectivePredicateExtractor.extract(session, node.getSource())); + Expression filteringSourceEffectivePredicate = filterDeterministicConjuncts(effectivePredicateExtractor.extract(session, node.getFilteringSource())); Expression joinExpression = new Comparison( EQUAL, node.getSourceJoinSymbol().toSymbolReference(), @@ -1417,7 +1417,7 @@ public PlanNode visitAggregation(AggregationNode node, RewriteContext !isDeterministic(expression)) .forEach(postAggregationConjuncts::add); - inheritedPredicate = filterDeterministicConjuncts(metadata, inheritedPredicate); + inheritedPredicate = filterDeterministicConjuncts(inheritedPredicate); // Sort non-equality predicates by those that can be pushed down and those that cannot Set groupingKeys = ImmutableSet.copyOf(node.getGroupingKeys()); @@ -1479,7 +1479,7 @@ public PlanNode visitUnnest(UnnestNode node, RewriteContext context) extractConjuncts(inheritedPredicate).stream() .filter(expression -> !isDeterministic(expression)) .forEach(postUnnestConjuncts::add); - inheritedPredicate = filterDeterministicConjuncts(metadata, inheritedPredicate); + inheritedPredicate = filterDeterministicConjuncts(inheritedPredicate); // Sort non-equality predicates by those that can be pushed down and those that cannot Set replicatedSymbols = ImmutableSet.copyOf(node.getReplicateSymbols());