Search in sources :

Example 11 with UnboundPredicate

use of org.apache.iceberg.expressions.UnboundPredicate in project hive by apache.

the class TestHiveIcebergFilterFactory method testEqualsOperand.

@Test
public void testEqualsOperand() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startAnd().equals("salary", PredicateLeaf.Type.LONG, 3000L).end().build();
    UnboundPredicate expected = Expressions.equal("salary", 3000L);
    UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg);
    assertPredicatesMatch(expected, actual);
}
Also used : UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Test(org.junit.Test)

Example 12 with UnboundPredicate

use of org.apache.iceberg.expressions.UnboundPredicate in project hive by apache.

the class TestHiveIcebergFilterFactory method testFloatType.

@Test
public void testFloatType() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startAnd().equals("float", PredicateLeaf.Type.FLOAT, 1200D).end().build();
    UnboundPredicate expected = Expressions.equal("float", 1200D);
    UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg);
    assertPredicatesMatch(expected, actual);
}
Also used : UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Test(org.junit.Test)

Example 13 with UnboundPredicate

use of org.apache.iceberg.expressions.UnboundPredicate in project hive by apache.

the class TestHiveIcebergFilterFactory method testDateType.

@Test
public void testDateType() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    Date gmtDate = Date.valueOf(LocalDate.of(2015, 11, 12));
    SearchArgument arg = builder.startAnd().equals("date", PredicateLeaf.Type.DATE, gmtDate).end().build();
    UnboundPredicate expected = Expressions.equal("date", Literal.of("2015-11-12").to(Types.DateType.get()).value());
    UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg);
    assertPredicatesMatch(expected, actual);
}
Also used : UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Date(java.sql.Date) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 14 with UnboundPredicate

use of org.apache.iceberg.expressions.UnboundPredicate in project hive by apache.

the class TestHiveIcebergFilterFactory method testStringType.

@Test
public void testStringType() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startAnd().equals("string", PredicateLeaf.Type.STRING, "Joe").end().build();
    UnboundPredicate expected = Expressions.equal("string", "Joe");
    UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg);
    assertPredicatesMatch(expected, actual);
}
Also used : UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Test(org.junit.Test)

Example 15 with UnboundPredicate

use of org.apache.iceberg.expressions.UnboundPredicate in project hive by apache.

the class TestHiveIcebergFilterFactory method testTimestampType.

@Test
public void testTimestampType() {
    Literal<Long> timestampLiteral = Literal.of("2012-10-02T05:16:17.123456").to(Types.TimestampType.withoutZone());
    long timestampMicros = timestampLiteral.value();
    Timestamp ts = Timestamp.from(DateTimeUtil.timestampFromMicros(timestampMicros).toInstant(ZoneOffset.UTC));
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startAnd().equals("timestamp", PredicateLeaf.Type.TIMESTAMP, ts).end().build();
    UnboundPredicate expected = Expressions.equal("timestamp", timestampMicros);
    UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg);
    assertPredicatesMatch(expected, actual);
}
Also used : UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Aggregations

UnboundPredicate (org.apache.iceberg.expressions.UnboundPredicate)32 Test (org.junit.Test)31 SearchArgument (org.apache.hadoop.hive.ql.io.sarg.SearchArgument)26 PartitionSpec (org.apache.iceberg.PartitionSpec)5 Expression (org.apache.iceberg.expressions.Expression)4 BigDecimal (java.math.BigDecimal)2 Date (java.sql.Date)2 Timestamp (java.sql.Timestamp)2 LocalDate (java.time.LocalDate)2 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)2 Not (org.apache.iceberg.expressions.Not)2 CallExpression (org.apache.flink.table.expressions.CallExpression)1 Expression (org.apache.flink.table.expressions.Expression)1 FieldReferenceExpression (org.apache.flink.table.expressions.FieldReferenceExpression)1 ResolvedExpression (org.apache.flink.table.expressions.ResolvedExpression)1 UnresolvedCallExpression (org.apache.flink.table.expressions.UnresolvedCallExpression)1 UnresolvedReferenceExpression (org.apache.flink.table.expressions.UnresolvedReferenceExpression)1 ValueLiteralExpression (org.apache.flink.table.expressions.ValueLiteralExpression)1 Schema (org.apache.iceberg.Schema)1 BoundLiteralPredicate (org.apache.iceberg.expressions.BoundLiteralPredicate)1