use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class QuerierTest method testLogicFilterOr.
@Test
public void testLogicFilterOr() {
// 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.OR);
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.assertTrue(querier.hasNewData());
querier.consume(RecordBox.get().add("field", "abc").add("id", "1").getRecord());
Assert.assertTrue(querier.hasNewData());
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class QuerierTest method testFiltering.
@Test
public void testFiltering() {
Expression filter = new BinaryExpression(new FieldExpression("field"), new ListExpression(Arrays.asList(new ValueExpression("foo"), new ValueExpression("bar"))), Operation.EQUALS_ANY);
Window window = WindowUtils.makeSlidingWindow(1);
Query query = new Query(new Projection(), filter, new Raw(null), null, window, null);
Querier querier = make(Querier.Mode.PARTITION, query);
querier.consume(RecordBox.get().add("field", "foo").getRecord());
Assert.assertTrue(querier.isClosed());
querier.reset();
querier.consume(RecordBox.get().add("field", "bar").getRecord());
Assert.assertTrue(querier.isClosed());
querier.reset();
querier.consume(RecordBox.get().add("field", "baz").getRecord());
Assert.assertFalse(querier.isClosed());
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class ListEvaluatorTest method testConstructor.
@Test
public void testConstructor() {
ListExpression expression = new ListExpression(Arrays.asList(new ValueExpression(1), new ValueExpression(2)));
expression.setType(Type.INTEGER_LIST);
ListEvaluator evaluator = new ListEvaluator(expression);
Assert.assertTrue(evaluator.evaluators.get(0) instanceof ValueEvaluator);
Assert.assertTrue(evaluator.evaluators.get(1) instanceof ValueEvaluator);
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), new TypedObject(Type.INTEGER_LIST, new ArrayList<>(Arrays.asList(1, 2))));
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class ComputationTest method testComputation.
@Test
public void testComputation() {
Computation computation = new Computation(Collections.singletonList(new Field("abc", new ValueExpression(1))));
Assert.assertEquals(computation.getFields(), Collections.singletonList(new Field("abc", new ValueExpression(1))));
Assert.assertEquals(computation.getType(), PostAggregationType.COMPUTATION);
Assert.assertEquals(computation.toString(), "{type: COMPUTATION, fields: [{name: abc, value: {value: 1, type: INTEGER}}]}");
Assert.assertTrue(computation.getPostStrategy() instanceof ComputationStrategy);
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class FieldTest method testEquals.
@Test
public void testEquals() {
Field fieldA = new Field("abc", new ValueExpression(5));
Field fieldB = new Field("def", new ValueExpression(5));
Field fieldC = new Field("abc", new ValueExpression(1));
Field fieldD = new Field("abc", new ValueExpression(5));
Assert.assertEquals(fieldA, fieldA);
Assert.assertNotEquals(fieldA, fieldB);
Assert.assertNotEquals(fieldA, fieldC);
Assert.assertEquals(fieldA, fieldD);
// coverage
Assert.assertFalse(fieldA.equals(0));
}
Aggregations