use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.
the class FilterOperationsTest method testComparisonNestedField.
@Test
public void testComparisonNestedField() {
FilterClause clause = getFieldFilter("demographic_map.age", GREATER_THAN, "30");
// "null" is not > 30
Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
RecordBox box = RecordBox.get();
box.addMap("demographic_map", Pair.of("age", "3"));
Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
box.addMap("demographic_map", Pair.of("age", "30"));
Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
box.addMap("demographic_map", Pair.of("age", "31"));
Assert.assertTrue(FilterOperations.perform(box.getRecord(), clause));
}
use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.
the class FilterOperationsTest method testNullComparison.
@Test
public void testNullComparison() {
FilterClause clause = getFieldFilter(EQUALS);
Assert.assertTrue(FilterOperations.perform(RecordBox.get().getRecord(), clause));
clause = getFieldFilter("map_field", NOT_EQUALS, "null");
// This should add a null map_field
Assert.assertFalse(FilterOperations.perform(RecordBox.get().addMap("map_field", null, null).getRecord(), clause));
clause = getFieldFilter("map_field", EQUALS, "null");
Assert.assertTrue(FilterOperations.perform(RecordBox.get().getRecord(), clause));
}
use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.
the class FilterOperationsTest method testBadRegex.
@Test
public void testBadRegex() {
FilterClause clause = getFieldFilter("id", REGEX_LIKE, "*TEST*");
Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("id", "TEST").getRecord(), clause));
Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("id", "*TEST*").getRecord(), clause));
}
use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.
the class FilterOperationsTest method testGreaterThan.
@Test
public void testGreaterThan() {
FilterClause clause = getFieldFilter("timestamp", GREATER_THAN, "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.assertFalse(FilterOperations.perform(RecordBox.get().add("timestamp", "3").getRecord(), clause));
Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "4").getRecord(), clause));
}
use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.
the class FilterOperationsTest method testRegexLike.
@Test
public void testRegexLike() {
FilterClause clause = getFieldFilter("id", REGEX_LIKE, "1.*2", "[1-5]+0*3");
Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("id", "12").getRecord(), clause));
Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("id", "1131112").getRecord(), clause));
Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("id", "55003").getRecord(), clause));
Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("id", "55001").getRecord(), clause));
}
Aggregations