Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import org.apache.iceberg.expressions.Bound;
import org.apache.iceberg.expressions.BoundPredicate;
import org.apache.iceberg.expressions.BoundReference;
import org.apache.iceberg.expressions.Expression;
import org.apache.iceberg.expressions.ExpressionVisitors;
import org.apache.iceberg.expressions.Literal;
Expand Down Expand Up @@ -270,7 +271,8 @@ public <T> Action notStartsWith(Bound<T> expr, Literal<T> lit) {

@Override
public <T> Action predicate(BoundPredicate<T> pred) {
if (UNSUPPORTED_TYPES.contains(pred.ref().type().typeId())) {
if (UNSUPPORTED_TYPES.contains(pred.ref().type().typeId())
|| !(pred.term() instanceof BoundReference)) {
// Cannot push down predicates for types which cannot be represented in PredicateLeaf.Type, so
// return
// TruthValue.YES_NO_NULL which signifies that this predicate cannot help with filtering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static org.apache.iceberg.expressions.Expressions.notIn;
import static org.apache.iceberg.expressions.Expressions.notNaN;
import static org.apache.iceberg.expressions.Expressions.notNull;
import static org.apache.iceberg.expressions.Expressions.year;
import static org.apache.iceberg.types.Types.NestedField.optional;
import static org.apache.iceberg.types.Types.NestedField.required;

Expand Down Expand Up @@ -476,4 +477,19 @@ public void testModifiedComplexSchemaNameMapping() {
SearchArgument actual = ExpressionToSearchArgument.convert(boundFilter, readSchema);
Assertions.assertThat(actual.toString()).isEqualTo(expected.toString());
}

@Test
public void testExpressionContainsNonReferenceTerm() {
Schema schema = new Schema(required(1, "ts", Types.TimestampType.withoutZone()));

// all operations for these types should resolve to YES_NO_NULL
Expression expr = equal(year("ts"), 10);
Expression boundFilter = Binder.bind(schema.asStruct(), expr, true);
SearchArgument expected =
SearchArgumentFactory.newBuilder().literal(TruthValue.YES_NO_NULL).build();

SearchArgument actual =
ExpressionToSearchArgument.convert(boundFilter, ORCSchemaUtil.convert(schema));
Assertions.assertThat(actual.toString()).isEqualTo(expected.toString());
}
}