Search in sources :

Example 1 with Not

use of org.apache.iceberg.expressions.Not in project iceberg by apache.

the class TestHiveIcebergFilterFactory method testNotEqualsOperand.

@Test
public void testNotEqualsOperand() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startNot().equals("salary", PredicateLeaf.Type.LONG, 3000L).end().build();
    Not expected = (Not) Expressions.not(Expressions.equal("salary", 3000L));
    Not actual = (Not) HiveIcebergFilterFactory.generateFilterExpression(arg);
    UnboundPredicate childExpressionActual = (UnboundPredicate) actual.child();
    UnboundPredicate childExpressionExpected = Expressions.equal("salary", 3000L);
    assertEquals(actual.op(), expected.op());
    assertEquals(actual.child().op(), expected.child().op());
    assertEquals(childExpressionActual.ref().name(), childExpressionExpected.ref().name());
    assertEquals(childExpressionActual.literal(), childExpressionExpected.literal());
}
Also used : Not(org.apache.iceberg.expressions.Not) UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Test(org.junit.Test)

Example 2 with Not

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

the class TestHiveIcebergFilterFactory method testNotEqualsOperand.

@Test
public void testNotEqualsOperand() {
    SearchArgument.Builder builder = SearchArgumentFactory.newBuilder();
    SearchArgument arg = builder.startNot().equals("salary", PredicateLeaf.Type.LONG, 3000L).end().build();
    Not expected = (Not) Expressions.not(Expressions.equal("salary", 3000L));
    Not actual = (Not) HiveIcebergFilterFactory.generateFilterExpression(arg);
    UnboundPredicate childExpressionActual = (UnboundPredicate) actual.child();
    UnboundPredicate childExpressionExpected = Expressions.equal("salary", 3000L);
    assertEquals(actual.op(), expected.op());
    assertEquals(actual.child().op(), expected.child().op());
    assertEquals(childExpressionActual.ref().name(), childExpressionExpected.ref().name());
    assertEquals(childExpressionActual.literal(), childExpressionExpected.literal());
}
Also used : Not(org.apache.iceberg.expressions.Not) UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) Test(org.junit.Test)

Example 3 with Not

use of org.apache.iceberg.expressions.Not in project iceberg by apache.

the class TestFlinkFilters method testNot.

@Test
public void testNot() {
    Expression expr = resolve(ApiExpressionUtils.unresolvedCall(BuiltInFunctionDefinitions.NOT, Expressions.$("field1").isEqual(Expressions.lit(1))));
    Optional<org.apache.iceberg.expressions.Expression> actual = FlinkFilters.convert(expr);
    Assert.assertTrue("Conversion should succeed", actual.isPresent());
    Not not = (Not) actual.get();
    Not expected = (Not) org.apache.iceberg.expressions.Expressions.not(org.apache.iceberg.expressions.Expressions.equal("field1", 1));
    Assert.assertEquals("Predicate operation should match", expected.op(), not.op());
    assertPredicatesMatch(expected.child(), not.child());
}
Also used : Not(org.apache.iceberg.expressions.Not) UnresolvedReferenceExpression(org.apache.flink.table.expressions.UnresolvedReferenceExpression) CallExpression(org.apache.flink.table.expressions.CallExpression) Expression(org.apache.flink.table.expressions.Expression) UnresolvedCallExpression(org.apache.flink.table.expressions.UnresolvedCallExpression) ResolvedExpression(org.apache.flink.table.expressions.ResolvedExpression) FieldReferenceExpression(org.apache.flink.table.expressions.FieldReferenceExpression) ValueLiteralExpression(org.apache.flink.table.expressions.ValueLiteralExpression) Test(org.junit.Test)

Aggregations

Not (org.apache.iceberg.expressions.Not)3 Test (org.junit.Test)3 SearchArgument (org.apache.hadoop.hive.ql.io.sarg.SearchArgument)2 UnboundPredicate (org.apache.iceberg.expressions.UnboundPredicate)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