use of com.amazonaws.athena.connector.lambda.metadata.GetSplitsRequest in project aws-athena-query-federation by awslabs.
the class MetricsMetadataHandlerTest method doGetMetricSamplesSplitsEmptyMetrics.
@Test
public void doGetMetricSamplesSplitsEmptyMetrics() throws Exception {
logger.info("doGetMetricSamplesSplitsEmptyMetrics: enter");
String namespace = "NameSpace";
String invalidNamespaceFilter = "InvalidNameSpace";
int numMetrics = 10;
when(mockMetrics.listMetrics(any(ListMetricsRequest.class))).thenAnswer((InvocationOnMock invocation) -> {
List<Metric> metrics = new ArrayList<>();
for (int i = 0; i < numMetrics; i++) {
metrics.add(new Metric().withNamespace(namespace).withMetricName("metric-" + i));
}
return new ListMetricsResult().withNextToken(null).withMetrics(metrics);
});
Schema schema = SchemaBuilder.newBuilder().addIntField("partitionId").build();
Block partitions = allocator.createBlock(schema);
BlockUtils.setValue(partitions.getFieldVector("partitionId"), 1, 1);
partitions.setRowCount(1);
Map<String, ValueSet> constraintsMap = new HashMap<>();
constraintsMap.put(NAMESPACE_FIELD, EquatableValueSet.newBuilder(allocator, Types.MinorType.VARCHAR.getType(), true, false).add(invalidNamespaceFilter).build());
GetSplitsRequest originalReq = new GetSplitsRequest(identity, "queryId", "catalog_name", new TableName(defaultSchema, "metric_samples"), partitions, Collections.singletonList("partitionId"), new Constraints(constraintsMap), null);
GetSplitsRequest req = new GetSplitsRequest(originalReq, null);
logger.info("doGetMetricSamplesSplitsEmptyMetrics: req[{}]", req);
MetadataResponse rawResponse = handler.doGetSplits(allocator, req);
assertEquals(MetadataRequestType.GET_SPLITS, rawResponse.getRequestType());
GetSplitsResponse response = (GetSplitsResponse) rawResponse;
assertEquals(0, response.getSplits().size());
assertEquals(null, response.getContinuationToken());
}
Aggregations