Search in sources :

Example 11 with FilterClause

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));
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 12 with FilterClause

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));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 13 with FilterClause

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));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 14 with FilterClause

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));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 15 with FilterClause

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));
}
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