Search in sources :

Example 6 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testLessThan.

@Test
public void testLessThan() {
    FilterClause clause = getFieldFilter("timestamp", LESS_THAN, "3");
    // "NULL" is not > 3
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "2").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("timestamp", "3").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("timestamp", "4").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 7 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testFilterMissingFields.

@Test
public void testFilterMissingFields() {
    FilterClause clause = new FilterClause();
    clause.setOperation(EQUALS);
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    clause.setField("field");
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("field", "foo").getRecord(), clause));
    clause.setValues(singletonList("bar"));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", "foo").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 8 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testNullInValues.

@Test
public void testNullInValues() {
    FilterClause clause = getFieldFilter(EQUALS, null, "foo", null);
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("field", "foo").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", "bar").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().addNull("field").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", Type.NULL_EXPRESSION).getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 9 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testFilterDefaultsWithOperation.

@Test
public void testFilterDefaultsWithOperation() {
    FilterClause clause = new FilterClause();
    // With non-empty values, filter always returns true
    clause.setOperation(EQUALS);
    clause.setValues(emptyList());
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 10 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testGreaterThanEquals.

@Test
public void testGreaterThanEquals() {
    FilterClause clause = getFieldFilter("timestamp", GREATER_EQUALS, "3");
    // "NULL" is not >= 3
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("timestamp", "2").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "3").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "4").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Aggregations

FilterClause (com.yahoo.bullet.parsing.FilterClause)18 Test (org.testng.annotations.Test)17 RecordBox (com.yahoo.bullet.result.RecordBox)3 Utilities.extractTypedObject (com.yahoo.bullet.common.Utilities.extractTypedObject)1 Clause (com.yahoo.bullet.parsing.Clause)1 LogicalClause (com.yahoo.bullet.parsing.LogicalClause)1 TypedObject (com.yahoo.bullet.typesystem.TypedObject)1