@@ -88,12 +88,33 @@ class ICEBERG_EXPORT PrimitiveLiteral {
8888 // / Get the Iceberg Type of the literal
8989 const std::shared_ptr<PrimitiveType>& type () const ;
9090
91- // / Cast the literal to a specific type
91+ // / Converts this literal to a literal of the given type.
92+ // /
93+ // / When a predicate is bound to a concrete data column, literals are converted to match
94+ // / the bound column's type. This conversion process is more narrow than a cast and is
95+ // / only intended for cases where substituting one type is a common mistake (e.g. 34
96+ // / instead of 34L) or where this API avoids requiring a concrete class (e.g., dates).
97+ // /
98+ // / If conversion to a target type is not supported, this method returns an error.
99+ // /
100+ // / This method may return BelowMin or AboveMax when the target type is not as wide as
101+ // / the original type. These values indicate that the containing predicate can be
102+ // / simplified. For example, Integer.MAX_VALUE+1 converted to an int will result in
103+ // / AboveMax and can simplify a < Integer.MAX_VALUE+1 to always true.
104+ // /
105+ // / @param target_type A primitive PrimitiveType
106+ // / @return A Result containing a literal of the given type or an error if conversion
107+ // / was not valid
92108 Result<PrimitiveLiteral> CastTo (
93109 const std::shared_ptr<PrimitiveType>& target_type) const ;
94110
111+ // / Compare two PrimitiveLiterals. Both literals must have the same type
112+ // / and should not be AboveMax or BelowMin.
95113 std::partial_ordering operator <=>(const PrimitiveLiteral& other) const ;
96114
115+ bool isAboveMax () const ;
116+ bool isBelowMin () const ;
117+
97118 std::string ToString () const ;
98119
99120 private:
0 commit comments