use of org.apache.parquet.filter2.predicate.FilterPredicate in project hive by apache.
the class TestParquetFilterPredicate method testFilterFloatColumn.
@Test
public void testFilterFloatColumn() throws Exception {
SearchArgument sarg = SearchArgumentFactory.newBuilder().startAnd().lessThan("x", PredicateLeaf.Type.LONG, 22L).lessThan("x1", PredicateLeaf.Type.LONG, 22L).lessThanEquals("y", PredicateLeaf.Type.STRING, new HiveChar("hi", 10).toString()).equals("z", PredicateLeaf.Type.FLOAT, Double.valueOf(0.22)).equals("z1", PredicateLeaf.Type.FLOAT, Double.valueOf(0.22)).end().build();
MessageType schema = MessageTypeParser.parseMessageType("message test {" + " required int32 x; required int32 x1;" + " required binary y; required float z; required float z1;}");
Map<String, TypeInfo> columnTypes = new HashMap<>();
columnTypes.put("x", TypeInfoFactory.getPrimitiveTypeInfo("int"));
columnTypes.put("x1", TypeInfoFactory.getPrimitiveTypeInfo("int"));
columnTypes.put("y", TypeInfoFactory.getCharTypeInfo(10));
columnTypes.put("z", TypeInfoFactory.getPrimitiveTypeInfo("float"));
columnTypes.put("z1", TypeInfoFactory.getPrimitiveTypeInfo("float"));
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema, columnTypes);
String expected = "and(and(and(and(lt(x, 22), lt(x1, 22))," + " lteq(y, Binary{\"hi\"})), eq(z, " + "0.22)), eq(z1, 0.22))";
assertEquals(expected, p.toString());
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project hive by apache.
the class TestParquetFilterPredicate method testFilterVarCharColumn.
@Test
public void testFilterVarCharColumn() throws Exception {
SearchArgument sarg = SearchArgumentFactory.newBuilder().startAnd().lessThan("a", PredicateLeaf.Type.STRING, new HiveVarchar("apple", 10).toString()).lessThanEquals("b", PredicateLeaf.Type.STRING, new HiveVarchar("pear", 10).toString()).equals("c", PredicateLeaf.Type.STRING, new HiveVarchar("orange", 10).toString()).nullSafeEquals("d", PredicateLeaf.Type.STRING, new HiveVarchar("pineapple", 9).toString()).in("e", PredicateLeaf.Type.STRING, new HiveVarchar("cherry", 10).toString(), new HiveVarchar("orange", 10).toString()).between("f", PredicateLeaf.Type.STRING, new HiveVarchar("apple", 10).toString(), new HiveVarchar("pear", 10).toString()).isNull("g", PredicateLeaf.Type.STRING).end().build();
MessageType schema = MessageTypeParser.parseMessageType("message test {" + " required binary a; required binary b;" + " required binary c; required binary d;" + " required binary e; required binary f;" + " required binary g;}");
Map<String, TypeInfo> columnTypes = new HashMap<>();
columnTypes.put("a", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("b", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("c", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("d", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("e", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("f", TypeInfoFactory.getVarcharTypeInfo(10));
columnTypes.put("g", TypeInfoFactory.getVarcharTypeInfo(10));
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema, columnTypes);
String expected = "and(and(and(and(and(and(" + "lt(a, Binary{\"apple\"}), " + "lteq(b, Binary{\"pear\"})), " + "eq(c, Binary{\"orange\"})), " + "eq(d, Binary{\"pineapple\"})), " + "or(eq(e, Binary{\"cherry\"}), eq(e, Binary{\"orange\"}))), " + "and(lteq(f, Binary{\"pear\"}), not(lt(f, Binary{\"apple\"})))), " + "eq(g, null))";
assertEquals(expected, p.toString());
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project hive by apache.
the class TestParquetFilterPredicate method testFilterFloatColumns.
@Test
public void testFilterFloatColumns() {
MessageType schema = MessageTypeParser.parseMessageType("message test { required float a; required int32 b; }");
SearchArgument sarg = SearchArgumentFactory.newBuilder().startNot().startOr().isNull("a", PredicateLeaf.Type.FLOAT).between("a", PredicateLeaf.Type.FLOAT, 10.2, 20.3).in("b", PredicateLeaf.Type.LONG, 1L, 2L, 3L).end().end().build();
Map<String, TypeInfo> columnTypes = new HashMap<>();
columnTypes.put("a", TypeInfoFactory.getPrimitiveTypeInfo("float"));
columnTypes.put("b", TypeInfoFactory.getPrimitiveTypeInfo("int"));
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema, columnTypes);
String expected = "and(and(not(eq(a, null)), not(and(lteq(a, 20.3), not(lt(a, 10.2))))), not(or(or(eq(b, 1), eq(b, 2)), eq(b, 3))))";
assertEquals(expected, p.toString());
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project hive by apache.
the class TestParquetFilterPredicate method testFilterColumnsThatDoNoExistOnSchema.
@Test
public void testFilterColumnsThatDoNoExistOnSchema() {
MessageType schema = MessageTypeParser.parseMessageType("message test { required int32 a; required binary stinger; }");
SearchArgument sarg = SearchArgumentFactory.newBuilder().startNot().startOr().isNull("a", PredicateLeaf.Type.LONG).between("y", PredicateLeaf.Type.LONG, 10L, // Column will be removed from filter
20L).in("z", PredicateLeaf.Type.LONG, 1L, 2L, // Column will be removed from filter
3L).nullSafeEquals("stinger", PredicateLeaf.Type.STRING, "stinger").end().end().build();
Map<String, TypeInfo> columnTypes = new HashMap<>();
columnTypes.put("a", TypeInfoFactory.getPrimitiveTypeInfo("int"));
columnTypes.put("y", TypeInfoFactory.getPrimitiveTypeInfo("int"));
columnTypes.put("z", TypeInfoFactory.getPrimitiveTypeInfo("int"));
columnTypes.put("stinger", TypeInfoFactory.getPrimitiveTypeInfo("string"));
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema, columnTypes);
String expected = "and(not(eq(a, null)), not(eq(stinger, Binary{\"stinger\"})))";
assertEquals(expected, p.toString());
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project hive by apache.
the class TestParquetFilterPredicate method testFilterCharColumnGreaterThan.
@Test
public void testFilterCharColumnGreaterThan() throws Exception {
SearchArgument sarg = SearchArgumentFactory.newBuilder().startNot().lessThanEquals("a", PredicateLeaf.Type.STRING, new HiveChar("apple", 10).toString()).end().build();
MessageType schema = MessageTypeParser.parseMessageType("message test {required binary a;}");
Map<String, TypeInfo> columnTypes = new HashMap<>();
columnTypes.put("a", TypeInfoFactory.getCharTypeInfo(10));
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema, columnTypes);
String expected = "not(lteq(a, Binary{\"apple\"}))";
assertEquals(expected, p.toString());
}
Aggregations