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 @@ -149,8 +149,7 @@ public UnboundPredicate<T> projectStrict(String name, BoundPredicate<T> predicat
if (predicate.isUnaryPredicate()) {
return Expressions.predicate(predicate.op(), name);
} else if (predicate.isLiteralPredicate()) {
return Expressions.predicate(
predicate.op(), name, predicate.asLiteralPredicate().literal().value());
return Expressions.predicate(predicate.op(), name, predicate.asLiteralPredicate().literal());
} else if (predicate.isSetPredicate()) {
return Expressions.predicate(predicate.op(), name, predicate.asSetPredicate().literalSet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.expressions.Binder;
import org.apache.iceberg.expressions.BoundPredicate;
import org.apache.iceberg.expressions.Expression;
import org.apache.iceberg.expressions.Expressions;
Expand Down Expand Up @@ -90,6 +91,28 @@ public void testIdentityProjection() {
}
}

@Test
public void testTimestampNanosIdentityProjection() {
org.apache.iceberg.Schema schema =
new org.apache.iceberg.Schema(
Comment on lines +96 to +97
Copy link
Contributor

@ebyhr ebyhr Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The package org.apache.iceberg looks redundant as this class already imports Schema.

Types.NestedField.required(1, "id", Types.LongType.get()),
Types.NestedField.optional(2, "ts", Types.TimestampNanoType.withoutZone()));

PartitionSpec spec = PartitionSpec.builderFor(schema).identity("ts").build();

Expression expr = Expressions.equal("ts", "2022-07-26T12:13:14.123456789");
Expression projected = Projections.inclusive(spec).project(expr);

Expression bound = Binder.bind(schema.asStruct(), projected, false);

assertThat(bound).isInstanceOf(BoundPredicate.class);
BoundPredicate<?> boundPredicate = (BoundPredicate<?>) bound;
assertThat(boundPredicate.isLiteralPredicate()).isTrue();
assertThat(boundPredicate.asLiteralPredicate().literal().value())
.as("Should bind to the correct value")
.isEqualTo(1658837594123456789L);
}

@Test
public void testCaseInsensitiveIdentityProjection() {
List<UnboundPredicate<?>> predicates =
Expand Down