23
23
import io .trino .plugin .base .metrics .LongCount ;
24
24
import io .trino .spi .QueryId ;
25
25
import io .trino .spi .metrics .Count ;
26
- import io .trino .spi .metrics .Metric ;
27
26
import io .trino .spi .metrics .Metrics ;
28
27
import io .trino .testing .BaseConnectorTest ;
29
28
import io .trino .testing .DistributedQueryRunner ;
40
39
import org .testng .annotations .Test ;
41
40
42
41
import java .util .List ;
43
- import java .util .Map ;
44
42
45
43
import static com .google .common .collect .ImmutableList .toImmutableList ;
46
44
import static io .trino .SystemSessionProperties .ENABLE_LARGE_DYNAMIC_FILTERS ;
@@ -152,22 +150,22 @@ public void testSelect()
152
150
@ Test
153
151
public void testCustomMetricsScanFilter ()
154
152
{
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 );
159
157
}
160
158
161
159
@ Test
162
160
public void testCustomMetricsScanOnly ()
163
161
{
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 );
168
166
}
169
167
170
- private Map < String , Metric > collectCustomMetrics (String sql )
168
+ private Metrics collectCustomMetrics (String sql )
171
169
{
172
170
DistributedQueryRunner runner = (DistributedQueryRunner ) getQueryRunner ();
173
171
ResultWithQueryId <MaterializedResult > result = runner .executeWithQueryId (getSession (), sql );
@@ -179,8 +177,7 @@ private Map<String, Metric> collectCustomMetrics(String sql)
179
177
.getOperatorSummaries ()
180
178
.stream ()
181
179
.map (OperatorStats ::getMetrics )
182
- .reduce (Metrics .EMPTY , Metrics ::mergeWith )
183
- .getMetrics ();
180
+ .reduce (Metrics .EMPTY , Metrics ::mergeWith );
184
181
}
185
182
186
183
@ Test (timeOut = 30_000 )
0 commit comments