use of com.yahoo.bullet.common.BulletConfig 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.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testBadAggregation.
@Test
public void testBadAggregation() {
Querier querier = new Querier("", "{'aggregation': {'type': 'COUNT DISTINCT'}}", new BulletConfig());
Optional<List<BulletError>> errors = querier.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get().size(), 1);
Assert.assertEquals(errors.get().get(0), SketchingStrategy.REQUIRES_FIELD_ERROR);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithTimeWindowsAreNotChanged.
@Test
public void testRawQueriesWithTimeWindowsAreNotChanged() {
BulletConfig config = new BulletConfig();
Query query = new Query();
query.setWindow(WindowUtils.makeWindow(Window.Unit.TIME, Integer.MAX_VALUE));
query.configure(config);
Querier querier = make(Querier.Mode.PARTITION, query, config);
Assert.assertFalse(querier.isClosed());
Assert.assertTrue(querier.shouldBuffer());
querier.consume(RecordBox.get().getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertEquals(querier.getWindow().getClass(), Tumbling.class);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method make.
private static Querier make(Querier.Mode mode, Query query) {
BulletConfig config = new BulletConfig();
query.configure(config);
return make(mode, query, config);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testReceiveTimestampNoProjection.
@Test
public void testReceiveTimestampNoProjection() {
Long start = System.currentTimeMillis();
Query query = new Query();
query.setProjection(null);
query.setWindow(WindowUtils.makeReactiveWindow());
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RECORD_INJECT_TIMESTAMP, true);
config.validate();
query.configure(config);
Querier querier = make(Querier.Mode.ALL, query, config);
BulletRecord input = RecordBox.get().add("field", "foo").add("mid", "123").getRecord();
querier.consume(input);
Assert.assertTrue(querier.isClosed());
List<BulletRecord> records = querier.getRecords();
Assert.assertEquals(records.size(), 1);
BulletRecord actual = records.get(0);
Long end = System.currentTimeMillis();
Assert.assertEquals(size(actual), 3);
Assert.assertEquals(actual.get("field"), "foo");
Assert.assertEquals(actual.get("mid"), "123");
Long recordedTimestamp = (Long) actual.get(BulletConfig.DEFAULT_RECORD_INJECT_TIMESTAMP_KEY);
Assert.assertTrue(recordedTimestamp >= start);
Assert.assertTrue(recordedTimestamp <= end);
}
Aggregations