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));
}
Aggregations