Search in sources :

Example 11 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testLtMissingColumn.

@Test
public void testLtMissingColumn() throws Exception {
    BinaryColumn b = binaryColumn("missing_column");
    assertTrue("Should drop block for any non-null query", canDrop(lt(b, Binary.fromString("any")), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Example 12 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testEqMissingColumn.

@Test
public void testEqMissingColumn() throws Exception {
    BinaryColumn b = binaryColumn("missing_column");
    assertTrue("Should drop block for non-null query", canDrop(eq(b, Binary.fromString("any")), ccmd, dictionaries));
    assertFalse("Should not drop block null query", canDrop(eq(b, null), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Example 13 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testNotEqMissingColumn.

@Test
public void testNotEqMissingColumn() throws Exception {
    BinaryColumn b = binaryColumn("missing_column");
    assertFalse("Should not drop block for non-null query", canDrop(notEq(b, Binary.fromString("any")), ccmd, dictionaries));
    assertTrue("Should not drop block null query", canDrop(notEq(b, null), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Example 14 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testEqBinary.

@Test
public void testEqBinary() throws Exception {
    BinaryColumn b = binaryColumn("binary_field");
    FilterPredicate pred = eq(b, Binary.fromString("c"));
    assertFalse("Should not drop block for lower case letters", canDrop(pred, ccmd, dictionaries));
    assertTrue("Should drop block for upper case letters", canDrop(eq(b, Binary.fromString("A")), ccmd, dictionaries));
    assertFalse("Should not drop block for null", canDrop(eq(b, null), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Example 15 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class TestRecordLevelFilters method testComplex.

@Test
public void testComplex() throws Exception {
    BinaryColumn name = binaryColumn("name");
    DoubleColumn lon = doubleColumn("location.lon");
    DoubleColumn lat = doubleColumn("location.lat");
    FilterPredicate pred = or(and(gt(lon, 150.0), notEq(lat, null)), eq(name, Binary.fromString("alice")));
    List<Group> found = PhoneBookWriter.readFile(phonebookFile, FilterCompat.get(pred));
    assertFilter(found, new UserFilter() {

        @Override
        public boolean keep(User u) {
            String name = u.getName();
            Double lat = null;
            Double lon = null;
            if (u.getLocation() != null) {
                lat = u.getLocation().getLat();
                lon = u.getLocation().getLon();
            }
            return (lon != null && lon > 150.0 && lat != null) || "alice".equals(name);
        }
    });
}
Also used : Group(org.apache.parquet.example.data.Group) DoubleColumn(org.apache.parquet.filter2.predicate.Operators.DoubleColumn) User(org.apache.parquet.filter2.recordlevel.PhoneBookWriter.User) BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Aggregations

BinaryColumn (org.apache.parquet.filter2.predicate.Operators.BinaryColumn)15 Test (org.junit.Test)15 FilterPredicate (org.apache.parquet.filter2.predicate.FilterPredicate)7 Group (org.apache.parquet.example.data.Group)4 User (org.apache.parquet.filter2.recordlevel.PhoneBookWriter.User)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 DoubleColumn (org.apache.parquet.filter2.predicate.Operators.DoubleColumn)1