2121
2222#include < format>
2323#include < regex>
24+ #include < utility>
2425
2526#include " iceberg/transform_function.h"
2627#include " iceberg/type.h"
@@ -130,16 +131,29 @@ bool Transform::PreservesOrder() const {
130131 case TransformType::kVoid :
131132 case TransformType::kBucket :
132133 return false ;
133- default :
134+ case TransformType::kIdentity :
135+ case TransformType::kTruncate :
136+ case TransformType::kYear :
137+ case TransformType::kMonth :
138+ case TransformType::kDay :
139+ case TransformType::kHour :
134140 return true ;
135141 }
142+ std::unreachable ();
136143}
137144
138145bool Transform::SatisfiesOrderOf (const Transform& other) const {
139146 auto other_type = other.transform_type ();
140147 switch (transform_type_) {
141148 case TransformType::kIdentity :
149+ // ordering by value is the same as long as the other preserves order
142150 return other.PreservesOrder ();
151+ case TransformType::kTruncate : {
152+ if (other_type != TransformType::kTruncate ) {
153+ return false ;
154+ }
155+ return std::get<int32_t >(param_) >= std::get<int32_t >(other.param_ );
156+ }
143157 case TransformType::kHour :
144158 return other_type == TransformType::kHour || other_type == TransformType::kDay ||
145159 other_type == TransformType::kMonth || other_type == TransformType::kYear ;
@@ -148,9 +162,13 @@ bool Transform::SatisfiesOrderOf(const Transform& other) const {
148162 other_type == TransformType::kYear ;
149163 case TransformType::kMonth :
150164 return other_type == TransformType::kMonth || other_type == TransformType::kYear ;
151- default :
165+ case TransformType::kYear :
166+ case TransformType::kBucket :
167+ case TransformType::kUnknown :
168+ case TransformType::kVoid :
152169 return *this == other;
153170 }
171+ std::unreachable ();
154172}
155173
156174bool TransformFunction::Equals (const TransformFunction& other) const {
0 commit comments