use of org.apache.hadoop.hive.ql.io.sarg.SearchArgument in project hive by apache.
the class TestParquetRecordReaderWrapper method testBuilderComplexTypes.
/**
* Check the converted filter predicate is null if unsupported types are included
* @throws Exception
*/
@Test
public void testBuilderComplexTypes() throws Exception {
SearchArgument sarg = SearchArgumentFactory.newBuilder().startAnd().lessThan("x", PredicateLeaf.Type.DATE, Date.valueOf("1970-1-11")).lessThanEquals("y", PredicateLeaf.Type.STRING, new HiveChar("hi", 10).toString()).equals("z", PredicateLeaf.Type.DECIMAL, new HiveDecimalWritable("1.0")).end().build();
MessageType schema = MessageTypeParser.parseMessageType("message test {" + " required int32 x; required binary y; required binary z;}");
assertEquals(null, ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema));
sarg = SearchArgumentFactory.newBuilder().startNot().startOr().isNull("x", PredicateLeaf.Type.LONG).between("y", PredicateLeaf.Type.DECIMAL, new HiveDecimalWritable("10"), new HiveDecimalWritable("20.0")).in("z", PredicateLeaf.Type.LONG, 1L, 2L, 3L).nullSafeEquals("a", PredicateLeaf.Type.STRING, new HiveVarchar("stinger", 100).toString()).end().end().build();
schema = MessageTypeParser.parseMessageType("message test {" + " optional int32 x; required binary y; required int32 z;" + " optional binary a;}");
assertEquals(null, ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema));
}
use of org.apache.hadoop.hive.ql.io.sarg.SearchArgument in project hive by apache.
the class TestParquetRecordReaderWrapper method testBuilderComplexTypes2.
/**
* Check the converted filter predicate is null if unsupported types are included
* @throws Exception
*/
@Test
public void testBuilderComplexTypes2() throws Exception {
SearchArgument sarg = SearchArgumentFactory.newBuilder().startAnd().lessThan("x", PredicateLeaf.Type.DATE, Date.valueOf("2005-3-12")).lessThanEquals("y", PredicateLeaf.Type.STRING, new HiveChar("hi", 10).toString()).equals("z", PredicateLeaf.Type.DECIMAL, new HiveDecimalWritable("1.0")).end().build();
MessageType schema = MessageTypeParser.parseMessageType("message test {" + " required int32 x; required binary y; required binary z;}");
assertEquals(null, ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema));
sarg = SearchArgumentFactory.newBuilder().startNot().startOr().isNull("x", PredicateLeaf.Type.LONG).between("y", PredicateLeaf.Type.DECIMAL, new HiveDecimalWritable("10"), new HiveDecimalWritable("20.0")).in("z", PredicateLeaf.Type.LONG, 1L, 2L, 3L).nullSafeEquals("a", PredicateLeaf.Type.STRING, new HiveVarchar("stinger", 100).toString()).end().end().build();
schema = MessageTypeParser.parseMessageType("message test {" + " optional int32 x; required binary y; required int32 z;" + " optional binary a;}");
assertEquals(null, ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema));
}
use of org.apache.hadoop.hive.ql.io.sarg.SearchArgument 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("a", PredicateLeaf.Type.STRING, "stinger").end().end().build();
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema);
String expected = "and(not(eq(a, null)), not(eq(a, Binary{\"stinger\"})))";
assertEquals(expected, p.toString());
}
use of org.apache.hadoop.hive.ql.io.sarg.SearchArgument 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();
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema);
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.hadoop.hive.ql.io.sarg.SearchArgument in project hive by apache.
the class TestParquetFilterPredicate method testFilterBetween.
@Test
public void testFilterBetween() {
MessageType schema = MessageTypeParser.parseMessageType("message test { required int32 bCol; }");
SearchArgument sarg = SearchArgumentFactory.newBuilder().between("bCol", PredicateLeaf.Type.LONG, 1L, 5L).build();
FilterPredicate p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema);
String expected = "and(lteq(bCol, 5), not(lt(bCol, 1)))";
assertEquals(expected, p.toString());
sarg = SearchArgumentFactory.newBuilder().between("bCol", PredicateLeaf.Type.LONG, 5L, 1L).build();
p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema);
expected = "and(lteq(bCol, 1), not(lt(bCol, 5)))";
assertEquals(expected, p.toString());
sarg = SearchArgumentFactory.newBuilder().between("bCol", PredicateLeaf.Type.LONG, 1L, 1L).build();
p = ParquetFilterPredicateConverter.toFilterPredicate(sarg, schema);
expected = "and(lteq(bCol, 1), not(lt(bCol, 1)))";
assertEquals(expected, p.toString());
}
Aggregations