This is an automated email from the ASF dual-hosted git repository.

wgtmac pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 41f32f8f fix: disallow zoned and non-zoned literal comparisons (#676)
41f32f8f is described below

commit 41f32f8f1592e374bd7445687178a5f66bb8f2cc
Author: Junwang Zhao <[email protected]>
AuthorDate: Sun May 24 14:49:43 2026 +0800

    fix: disallow zoned and non-zoned literal comparisons (#676)
---
 src/iceberg/expression/literal.cc | 8 ++------
 src/iceberg/test/literal_test.cc  | 8 +++++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/iceberg/expression/literal.cc 
b/src/iceberg/expression/literal.cc
index e14d3def..cbf0ab01 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 86b89237..e7753382 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

Reply via email to