Skip to content

Commit 1f896ea

Browse files
rzeyde-varadafindepi
authored andcommitted
Don't use raw Metric type outside of Metrics class
1 parent f5fd024 commit 1f896ea

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/metrics/TestMetrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testMergeCount()
3838
"b", new LongCount(3),
3939
"c", new LongCount(4)));
4040
Metrics merged = merge(m1, m2);
41-
Map<String, Metric> expectedMap = ImmutableMap.of(
41+
Map<String, Metric<?>> expectedMap = ImmutableMap.of(
4242
"a", new LongCount(1),
4343
"b", new LongCount(5),
4444
"c", new LongCount(4));

plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import io.trino.plugin.base.metrics.LongCount;
2424
import io.trino.spi.QueryId;
2525
import io.trino.spi.metrics.Count;
26-
import io.trino.spi.metrics.Metric;
2726
import io.trino.spi.metrics.Metrics;
2827
import io.trino.testing.BaseConnectorTest;
2928
import io.trino.testing.DistributedQueryRunner;
@@ -40,7 +39,6 @@
4039
import org.testng.annotations.Test;
4140

4241
import java.util.List;
43-
import java.util.Map;
4442

4543
import static com.google.common.collect.ImmutableList.toImmutableList;
4644
import static io.trino.SystemSessionProperties.ENABLE_LARGE_DYNAMIC_FILTERS;
@@ -152,22 +150,22 @@ public void testSelect()
152150
@Test
153151
public void testCustomMetricsScanFilter()
154152
{
155-
Map<String, Metric> metrics = collectCustomMetrics("SELECT partkey FROM part WHERE partkey % 1000 > 0");
156-
assertThat(metrics.get("rows")).isEqualTo(new LongCount(PART_COUNT));
157-
assertThat(metrics.get("started")).isEqualTo(metrics.get("finished"));
158-
assertThat(((Count) metrics.get("finished")).getTotal()).isGreaterThan(0);
153+
Metrics metrics = collectCustomMetrics("SELECT partkey FROM part WHERE partkey % 1000 > 0");
154+
assertThat(metrics.getMetrics().get("rows")).isEqualTo(new LongCount(PART_COUNT));
155+
assertThat(metrics.getMetrics().get("started")).isEqualTo(metrics.getMetrics().get("finished"));
156+
assertThat(((Count) metrics.getMetrics().get("finished")).getTotal()).isGreaterThan(0);
159157
}
160158

161159
@Test
162160
public void testCustomMetricsScanOnly()
163161
{
164-
Map<String, Metric> metrics = collectCustomMetrics("SELECT partkey FROM part");
165-
assertThat(metrics.get("rows")).isEqualTo(new LongCount(PART_COUNT));
166-
assertThat(metrics.get("started")).isEqualTo(metrics.get("finished"));
167-
assertThat(((Count) metrics.get("finished")).getTotal()).isGreaterThan(0);
162+
Metrics metrics = collectCustomMetrics("SELECT partkey FROM part");
163+
assertThat(metrics.getMetrics().get("rows")).isEqualTo(new LongCount(PART_COUNT));
164+
assertThat(metrics.getMetrics().get("started")).isEqualTo(metrics.getMetrics().get("finished"));
165+
assertThat(((Count) metrics.getMetrics().get("finished")).getTotal()).isGreaterThan(0);
168166
}
169167

170-
private Map<String, Metric> collectCustomMetrics(String sql)
168+
private Metrics collectCustomMetrics(String sql)
171169
{
172170
DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
173171
ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(getSession(), sql);
@@ -179,8 +177,7 @@ private Map<String, Metric> collectCustomMetrics(String sql)
179177
.getOperatorSummaries()
180178
.stream()
181179
.map(OperatorStats::getMetrics)
182-
.reduce(Metrics.EMPTY, Metrics::mergeWith)
183-
.getMetrics();
180+
.reduce(Metrics.EMPTY, Metrics::mergeWith);
184181
}
185182

186183
@Test(timeOut = 30_000)

0 commit comments

Comments
 (0)