use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.
the class GroupAllTest method testAttributeOperationMissing.
@Test
public void testAttributeOperationMissing() {
Aggregation aggregation = makeAggregation(singletonMap(GroupOperation.OPERATIONS, null));
GroupAll groupAll = new GroupAll(aggregation);
Optional<List<BulletError>> optionalErrors = groupAll.initialize();
Assert.assertTrue(optionalErrors.isPresent());
List<BulletError> errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0), GroupOperation.REQUIRES_FIELD_OR_OPERATION_ERROR);
}
use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.
the class QuerierTest method testNonRawQueriesWithRecordWindowsAreErrors.
@Test
public void testNonRawQueriesWithRecordWindowsAreErrors() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
query.setAggregation(aggregation);
query.setWindow(WindowUtils.makeWindow(Window.Unit.RECORD, 1));
query.configure(config);
Querier querier = new Querier(new RunningQuery("", query), config);
Optional<List<BulletError>> errors = querier.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Query.ONLY_RAW_RECORD));
}
use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithoutWindowsThatAreTimedOutAreTimeBased.
@Test
public void testRawQueriesWithoutWindowsThatAreTimedOutAreTimeBased() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, 10);
config.validate();
Query query = new Query();
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.RAW);
query.setAggregation(aggregation);
query.configure(config);
RunningQuery runningQuery = spy(new RunningQuery("", query));
doAnswer(returnsElementsOf(asList(false, true))).when(runningQuery).isTimedOut();
Querier querier = new Querier(Querier.Mode.ALL, runningQuery, config);
querier.initialize();
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.shouldBuffer());
Assert.assertEquals(querier.getWindow().getClass(), Basic.class);
IntStream.range(0, 9).forEach(i -> querier.consume(RecordBox.get().getRecord()));
Assert.assertFalse(querier.isClosed());
// Now runningQuery is timed out but query is not done.
Assert.assertTrue(querier.shouldBuffer());
}
use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.
the class QuerierTest method makeCountQueryWithAllWindow.
private static RunningQuery makeCountQueryWithAllWindow(BulletConfig config, int emitInterval) {
Query query = new Query();
query.setWindow(WindowUtils.makeWindow(Window.Unit.TIME, emitInterval, Window.Unit.ALL, null));
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.GROUP);
Map<String, String> count = Collections.singletonMap(GroupOperation.OPERATION_TYPE, GroupOperation.GroupOperationType.COUNT.getName());
aggregation.setAttributes(Collections.singletonMap(GroupOperation.OPERATIONS, Collections.singletonList(count)));
query.setAggregation(aggregation);
query.configure(config);
RunningQuery runningQuery = spy(new RunningQuery("", query));
doReturn(false).when(runningQuery).isTimedOut();
return runningQuery;
}
use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.
the class QuerierTest method testMetadataDisabled.
@Test
public void testMetadataDisabled() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RESULT_METADATA_ENABLE, false);
// Should clear out the default metadata
config.validate();
Query query = new Query();
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
aggregation.setFields(singletonMap("foo", "bar"));
query.setAggregation(aggregation);
query.setWindow(WindowUtils.makeWindow(Window.Unit.TIME, 1));
query.configure(config);
Querier querier = make(Querier.Mode.PARTITION, query, config);
querier.consume(RecordBox.get().add("foo", "A").getRecord());
Assert.assertTrue(querier.getMetadata().asMap().isEmpty());
}
Aggregations