From 33568e53d9b8bb871af334acea36c260e132f08e Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Tue, 11 Oct 2022 10:26:39 +0200 Subject: [PATCH 1/3] Annotate PatternRecognitionMatcher builder methods Add `@CanIgnoreReturnValue` to suppress error-prone complaining about these. --- .../assertions/PatternRecognitionMatcher.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 39360db53377..1538a53d516d 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 @@ -14,6 +14,7 @@ package io.trino.sql.planner.assertions; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.trino.Session; import io.trino.cost.StatsProvider; import io.trino.metadata.Metadata; @@ -196,36 +197,42 @@ public static class Builder this.source = requireNonNull(source, "source is null"); } + @CanIgnoreReturnValue public Builder specification(ExpectedValueProvider specification) { this.specification = Optional.of(specification); return this; } + @CanIgnoreReturnValue public Builder addFunction(String outputAlias, ExpectedValueProvider functionCall) { windowFunctionMatchers.add(new AliasMatcher(Optional.of(outputAlias), new WindowFunctionMatcher(functionCall, Optional.empty(), Optional.empty()))); return this; } + @CanIgnoreReturnValue public Builder addMeasure(String outputAlias, String expression, Type type) { measures.put(outputAlias, new AbstractMap.SimpleEntry<>(expression, type)); return this; } + @CanIgnoreReturnValue public Builder frame(ExpectedValueProvider frame) { this.frame = Optional.of(frame); return this; } + @CanIgnoreReturnValue public Builder rowsPerMatch(RowsPerMatch rowsPerMatch) { this.rowsPerMatch = rowsPerMatch; return this; } + @CanIgnoreReturnValue public Builder skipTo(SkipTo.Position position, IrLabel label) { this.skipToLabel = Optional.of(label); @@ -233,36 +240,42 @@ public Builder skipTo(SkipTo.Position position, IrLabel label) return this; } + @CanIgnoreReturnValue public Builder skipTo(SkipTo.Position position) { this.skipToPosition = position; return this; } + @CanIgnoreReturnValue public Builder seek() { this.initial = false; return this; } + @CanIgnoreReturnValue public Builder pattern(IrRowPattern pattern) { this.pattern = pattern; return this; } + @CanIgnoreReturnValue public Builder addSubset(IrLabel name, Set elements) { subsets.put(name, elements); return this; } + @CanIgnoreReturnValue public Builder addVariableDefinition(IrLabel name, String expression) { this.variableDefinitionsBySql.put(name, expression); return this; } + @CanIgnoreReturnValue public Builder addVariableDefinition(IrLabel name, Expression expression) { this.variableDefinitionsByExpression.put(name, expression); From 2bfc751a915e5c84fcf012b5aff19fdf0621ead9 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Tue, 11 Oct 2022 10:32:03 +0200 Subject: [PATCH 2/3] Remove unused method --- .../plugin/hive/metastore/glue/TestHiveGlueMetastore.java | 5 ----- 1 file changed, 5 deletions(-) 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 8b84024ebdbb..d45c4eaee641 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 @@ -1450,11 +1450,6 @@ private static PartitionValues make(String... values) return new PartitionValues(Arrays.asList(values)); } - private static PartitionValues make(List values) - { - return new PartitionValues(values); - } - private PartitionValues(List values) { this.values = values; From 58bd944ce952118672228a51998a40356d535c2e Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Tue, 11 Oct 2022 10:32:36 +0200 Subject: [PATCH 3/3] Make PartitionValues test helper immutable Mutability was not intentional. --- .../plugin/hive/metastore/glue/TestHiveGlueMetastore.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 d45c4eaee641..e94935ba5141 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 @@ -110,6 +110,7 @@ import static java.lang.String.format; import static java.lang.System.currentTimeMillis; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; import static java.util.UUID.randomUUID; import static java.util.concurrent.TimeUnit.DAYS; import static org.apache.hadoop.hive.common.FileUtils.makePartName; @@ -1452,7 +1453,7 @@ private static PartitionValues make(String... values) private PartitionValues(List values) { - this.values = values; + this.values = ImmutableList.copyOf(requireNonNull(values, "values is null")); } public List getValues()