@@ -77,7 +77,7 @@ Result<Literal> LiteralCaster::CastFromInt(
7777 return Literal::Double (static_cast <double >(int_val));
7878 default :
7979 return NotSupported (" Cast from Int to {} is not implemented" ,
80- static_cast < int >(target_type_id ));
80+ target_type-> ToString ( ));
8181 }
8282}
8383
@@ -103,7 +103,7 @@ Result<Literal> LiteralCaster::CastFromLong(
103103 return Literal::Double (static_cast <double >(long_val));
104104 default :
105105 return NotSupported (" Cast from Long to {} is not supported" ,
106- static_cast < int >(target_type_id ));
106+ target_type-> ToString ( ));
107107 }
108108}
109109
@@ -117,7 +117,7 @@ Result<Literal> LiteralCaster::CastFromFloat(
117117 return Literal::Double (static_cast <double >(float_val));
118118 default :
119119 return NotSupported (" Cast from Float to {} is not supported" ,
120- static_cast < int >(target_type_id ));
120+ target_type-> ToString ( ));
121121 }
122122}
123123
@@ -175,21 +175,21 @@ Result<Literal> Literal::CastTo(const std::shared_ptr<PrimitiveType>& target_typ
175175// Template function for floating point comparison following Iceberg rules:
176176// -NaN < NaN, but all NaN values (qNaN, sNaN) are treated as equivalent within their sign
177177template <std::floating_point T>
178- std::partial_ordering iceberg_float_compare (T lhs, T rhs) {
178+ std::strong_ordering CompareFloat (T lhs, T rhs) {
179+ // If both are NaN, check their signs
179180 bool lhs_is_nan = std::isnan (lhs);
180181 bool rhs_is_nan = std::isnan (rhs);
181-
182- // If both are NaN, check their signs
183182 if (lhs_is_nan && rhs_is_nan) {
184183 bool lhs_is_negative = std::signbit (lhs);
185184 bool rhs_is_negative = std::signbit (rhs);
186185
187186 if (lhs_is_negative == rhs_is_negative) {
188187 // Same sign NaN values are equivalent (no qNaN vs sNaN distinction)
189- return std::partial_ordering ::equivalent;
188+ return std::strong_ordering ::equivalent;
190189 }
191190 // -NaN < NaN
192- return lhs_is_negative ? std::partial_ordering::less : std::partial_ordering::greater;
191+ return lhs_is_negative ? std::strong_ordering::less
192+ : std::strong_ordering::greater;
193193 }
194194
195195 // For non-NaN values, use standard strong ordering
@@ -233,14 +233,14 @@ std::partial_ordering Literal::operator<=>(const Literal& other) const {
233233 auto this_val = std::get<float >(value_);
234234 auto other_val = std::get<float >(other.value_ );
235235 // Use strong_ordering for floating point as spec requests
236- return iceberg_float_compare (this_val, other_val);
236+ return CompareFloat (this_val, other_val);
237237 }
238238
239239 case TypeId::kDouble : {
240240 auto this_val = std::get<double >(value_);
241241 auto other_val = std::get<double >(other.value_ );
242242 // Use strong_ordering for floating point as spec requests
243- return iceberg_float_compare (this_val, other_val);
243+ return CompareFloat (this_val, other_val);
244244 }
245245
246246 case TypeId::kString : {
@@ -263,10 +263,10 @@ std::partial_ordering Literal::operator<=>(const Literal& other) const {
263263
264264std::string Literal::ToString () const {
265265 if (std::holds_alternative<BelowMin>(value_)) {
266- return " BelowMin " ;
266+ return " belowMin " ;
267267 }
268268 if (std::holds_alternative<AboveMax>(value_)) {
269- return " AboveMax " ;
269+ return " aboveMax " ;
270270 }
271271
272272 switch (type_->type_id ()) {
@@ -293,7 +293,7 @@ std::string Literal::ToString() const {
293293 std::string result;
294294 result.reserve (binary_data.size () * 2 ); // 2 chars per byte
295295 for (const auto & byte : binary_data) {
296- result += std::format ( " {:02X}" , byte);
296+ std::format_to ( std::back_inserter (result), " {:02X}" , byte);
297297 }
298298 return result;
299299 }
0 commit comments