Search in sources :

Example 1 with BoundLiteralPredicate

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

the class TestFlinkFilters method matchLiteral.

@SuppressWarnings("unchecked")
private <T> void matchLiteral(String fieldName, Object flinkLiteral, T icebergLiteral) {
    Expression expr = resolve(Expressions.$(fieldName).isEqual(Expressions.lit(flinkLiteral)));
    Optional<org.apache.iceberg.expressions.Expression> actual = FlinkFilters.convert(expr);
    Assert.assertTrue("Conversion should succeed", actual.isPresent());
    org.apache.iceberg.expressions.Expression expression = actual.get();
    Assertions.assertThat(expression).as("The expression should be a UnboundPredicate").isInstanceOf(UnboundPredicate.class);
    UnboundPredicate<T> unboundPredicate = (UnboundPredicate<T>) expression;
    org.apache.iceberg.expressions.Expression expression1 = unboundPredicate.bind(FlinkSchemaUtil.convert(TABLE_SCHEMA).asStruct(), false);
    Assertions.assertThat(expression1).as("The expression should be a BoundLiteralPredicate").isInstanceOf(BoundLiteralPredicate.class);
    BoundLiteralPredicate<T> predicate = (BoundLiteralPredicate<T>) expression1;
    Assert.assertTrue("Should match the  literal", predicate.test(icebergLiteral));
}
Also used : 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) UnboundPredicate(org.apache.iceberg.expressions.UnboundPredicate) BoundLiteralPredicate(org.apache.iceberg.expressions.BoundLiteralPredicate)

Aggregations

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 BoundLiteralPredicate (org.apache.iceberg.expressions.BoundLiteralPredicate)1 UnboundPredicate (org.apache.iceberg.expressions.UnboundPredicate)1