use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class HavingTest method testHaving.
@Test
public void testHaving() {
Having having = new Having(new ValueExpression(true));
Assert.assertEquals(having.getExpression(), new ValueExpression(true));
Assert.assertEquals(having.getType(), PostAggregationType.HAVING);
Assert.assertEquals(having.toString(), "{type: HAVING, expression: {value: true, type: BOOLEAN}}");
Assert.assertTrue(having.getPostStrategy() instanceof HavingStrategy);
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class FilterTest method testFilterMatch.
@Test
public void testFilterMatch() {
Filter filter = new Filter(new BinaryExpression(new FieldExpression("abc"), new ValueExpression(0), Operation.GREATER_THAN));
BulletRecord recordA = RecordBox.get().add("abc", 1).getRecord();
BulletRecord recordB = RecordBox.get().add("abc", 0).getRecord();
BulletRecord recordC = RecordBox.get().getRecord();
Assert.assertTrue(filter.match(recordA));
Assert.assertFalse(filter.match(recordB));
Assert.assertFalse(filter.match(recordC));
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class QueryManagerTest method getQuery.
@SafeVarargs
private static Query getQuery(Pair<String, Serializable>... equalities) {
BinaryExpression expression = null;
if (equalities != null && equalities.length > 0) {
if (equalities.length == 1) {
expression = new BinaryExpression(new FieldExpression(equalities[0].getLeft()), new ValueExpression(equalities[0].getRight()), Operation.EQUALS);
expression.setType(Type.BOOLEAN);
expression.getLeft().setType(expression.getRight().getType());
} else {
expression = Arrays.stream(equalities).reduce(null, (a, b) -> {
BinaryExpression equals = new BinaryExpression(new FieldExpression(b.getLeft()), new ValueExpression(b.getRight()), Operation.EQUALS);
equals.setType(Type.BOOLEAN);
equals.getLeft().setType(equals.getRight().getType());
if (a == null) {
return equals;
}
BinaryExpression and = new BinaryExpression(a, equals, Operation.AND);
and.setType(Type.BOOLEAN);
return and;
}, (left, right) -> {
BinaryExpression and = new BinaryExpression(left, right, Operation.AND);
and.setType(Type.BOOLEAN);
return and;
});
}
}
Query query = new Query(new Projection(), expression, new Raw(null), null, new Window(), null);
query.configure(new BulletConfig());
return query;
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class ProjectionTest method testProjectionNoCopy.
@Test
public void testProjectionNoCopy() {
Projection projection = new Projection(Arrays.asList(new Field("foo", new ValueExpression(5))), false);
Assert.assertEquals(projection.getFields(), Collections.singletonList(new Field("foo", new ValueExpression(5))));
Assert.assertEquals(projection.getType(), Projection.Type.NO_COPY);
Assert.assertEquals(projection.toString(), "{fields: [{name: foo, value: {value: 5, type: INTEGER}}], type: NO_COPY}");
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class QuerierTest method testLogicFilterAnd.
@Test
public void testLogicFilterAnd() {
// legacy test
Expression filter = new BinaryExpression(new BinaryExpression(new FieldExpression("field"), new ValueExpression("abc"), Operation.EQUALS), new BinaryExpression(new FieldExpression("id"), new ValueExpression("1"), Operation.EQUALS), Operation.AND);
Query query = new Query(new Projection(), filter, new Raw(null), null, new Window(), null);
Querier querier = make(Querier.Mode.PARTITION, query);
querier.consume(RecordBox.get().add("field", "abc").add("id", "2").getRecord());
Assert.assertFalse(querier.hasNewData());
querier.consume(RecordBox.get().add("field", "abc").add("id", "1").getRecord());
Assert.assertTrue(querier.hasNewData());
}
Aggregations