diff --git a/src/iceberg/expression/literal.cc b/src/iceberg/expression/literal.cc index e14d3def2..cbf0ab017 100644 --- a/src/iceberg/expression/literal.cc +++ b/src/iceberg/expression/literal.cc @@ -458,12 +458,8 @@ bool Comparable(TypeId lhs, TypeId rhs) { (rhs == TypeId::kInt || rhs == TypeId::kDate)) { return true; } - if ((lhs == TypeId::kTimestamp || lhs == TypeId::kTimestampTz) && - (rhs == TypeId::kTimestamp || rhs == TypeId::kTimestampTz)) { - return true; - } - return (lhs == TypeId::kTimestampNs || lhs == TypeId::kTimestampTzNs) && - (rhs == TypeId::kTimestampNs || rhs == TypeId::kTimestampTzNs); + // Java allows zoned/non-zoned timestamp comparisons; keep C++ stricter for now. + return false; } } // namespace diff --git a/src/iceberg/test/literal_test.cc b/src/iceberg/test/literal_test.cc index 86b892377..e77533828 100644 --- a/src/iceberg/test/literal_test.cc +++ b/src/iceberg/test/literal_test.cc @@ -102,10 +102,12 @@ TEST(LiteralTest, CrossTypeComparison) { EXPECT_EQ(long_literal <=> timestamp_literal, std::partial_ordering::unordered); EXPECT_EQ(timestamp_literal <=> timestamp_ns_literal, std::partial_ordering::unordered); EXPECT_EQ(int_literal <=> Literal::Date(42), std::partial_ordering::equivalent); - EXPECT_EQ(timestamp_literal <=> timestamp_tz_literal, - std::partial_ordering::equivalent); + EXPECT_EQ(timestamp_literal <=> timestamp_tz_literal, std::partial_ordering::unordered); + EXPECT_EQ(timestamp_tz_literal <=> timestamp_literal, std::partial_ordering::unordered); EXPECT_EQ(timestamp_ns_literal <=> timestamp_tz_ns_literal, - std::partial_ordering::equivalent); + std::partial_ordering::unordered); + EXPECT_EQ(timestamp_tz_ns_literal <=> timestamp_ns_literal, + std::partial_ordering::unordered); } // Overflow tests