@@ -40,7 +40,7 @@ void AssertCastSucceeds(const Result<Literal>& result, TypeId expected_type_id,
4040 ASSERT_THAT (result, IsOk ());
4141 EXPECT_EQ (result->type ()->type_id (), expected_type_id);
4242 ASSERT_NO_THROW (EXPECT_EQ (std::get<T>(result->value ()), expected_value))
43- << " Value type mismatch in std::get. Expected type for TypeId "
43+ << " Type mismatch in std::get. Expected type for TypeId "
4444 << static_cast <int >(expected_type_id);
4545}
4646
@@ -105,10 +105,6 @@ TEST(LiteralTest, IntCastTo) {
105105
106106 // Cast to Date
107107 AssertCastSucceeds (int_literal.CastTo (iceberg::date ()), TypeId::kDate , 42 );
108-
109- // Cast to Decimal
110- AssertCastSucceeds (int_literal.CastTo (iceberg::decimal (10 , 2 )), TypeId::kDecimal ,
111- static_cast <int128_t >(42 ));
112108}
113109
114110// Long type tests
@@ -150,19 +146,15 @@ TEST(LiteralTest, LongCastTo) {
150146
151147 // Cast to Time
152148 AssertCastSucceeds (long_literal.CastTo (iceberg::time ()), TypeId::kTime ,
153- static_cast <int64_t >(42L ));
149+ static_cast <int64_t >(42 ));
154150
155151 // Cast to Timestamp
156152 AssertCastSucceeds (long_literal.CastTo (iceberg::timestamp ()), TypeId::kTimestamp ,
157- static_cast <int64_t >(42L ));
153+ static_cast <int64_t >(42 ));
158154
159155 // Cast to TimestampTz
160156 AssertCastSucceeds (long_literal.CastTo (iceberg::timestamp_tz ()), TypeId::kTimestampTz ,
161- static_cast <int64_t >(42L ));
162-
163- // Cast to Decimal
164- AssertCastSucceeds (long_literal.CastTo (iceberg::decimal (15 , 3 )), TypeId::kDecimal ,
165- static_cast <int128_t >(42L ));
157+ static_cast <int64_t >(42 ));
166158}
167159
168160TEST (LiteralTest, LongCastToOverflow) {
@@ -217,11 +209,6 @@ TEST(LiteralTest, FloatCastTo) {
217209 // Cast to Double
218210 AssertCastSucceeds (float_literal.CastTo (iceberg::float64 ()), TypeId::kDouble ,
219211 static_cast <double >(2 .0f ));
220-
221- // Cast to Decimal
222- auto decimal_result = float_literal.CastTo (iceberg::decimal (10 , 2 ));
223- ASSERT_THAT (decimal_result, IsOk ());
224- EXPECT_EQ (decimal_result->type ()->type_id (), TypeId::kDecimal );
225212}
226213
227214// Double type tests
@@ -251,11 +238,6 @@ TEST(LiteralTest, DoubleCastTo) {
251238
252239 // Cast to Float
253240 AssertCastSucceeds (double_literal.CastTo (iceberg::float32 ()), TypeId::kFloat , 2 .0f );
254-
255- // Cast to Decimal
256- auto decimal_result = double_literal.CastTo (iceberg::decimal (15 , 2 ));
257- ASSERT_THAT (decimal_result, IsOk ());
258- EXPECT_EQ (decimal_result->type ()->type_id (), TypeId::kDecimal );
259241}
260242
261243TEST (LiteralTest, DoubleCastToOverflow) {
@@ -274,73 +256,6 @@ TEST(LiteralTest, DoubleCastToOverflow) {
274256 EXPECT_TRUE (min_result->IsBelowMin ());
275257}
276258
277- // Decimal type tests
278- TEST (LiteralTest, DecimalBasics) {
279- // Test factory methods with different precision and scale
280- auto decimal1 = Literal::Decimal (iceberg::Decimal (12345 ), 10 , 2 );
281- auto decimal2 = Literal::Decimal (int128_t {-9876543 }, 15 , 3 );
282- auto decimal_zero = Literal::Decimal (int128_t {0 }, 5 , 1 );
283-
284- EXPECT_EQ (decimal1.type ()->type_id (), TypeId::kDecimal );
285- EXPECT_EQ (decimal2.type ()->type_id (), TypeId::kDecimal );
286- EXPECT_EQ (decimal_zero.type ()->type_id (), TypeId::kDecimal );
287-
288- // Check type properties
289- auto decimal1_type = std::static_pointer_cast<iceberg::DecimalType>(decimal1.type ());
290- EXPECT_EQ (decimal1_type->precision (), 10 );
291- EXPECT_EQ (decimal1_type->scale (), 2 );
292-
293- auto decimal2_type = std::static_pointer_cast<iceberg::DecimalType>(decimal2.type ());
294- EXPECT_EQ (decimal2_type->precision (), 15 );
295- EXPECT_EQ (decimal2_type->scale (), 3 );
296- }
297-
298- TEST (LiteralTest, DecimalToString) {
299- // Test ToString for different decimal values with specific expected formats
300- auto decimal_pos = Literal::Decimal (int128_t {12345 }, 10 , 2 ); // 123.45
301- auto decimal_neg = Literal::Decimal (int128_t {-9876 }, 8 , 3 ); // -9.876
302- auto decimal_zero = Literal::Decimal (int128_t {0 }, 5 , 1 ); // 0.0
303- auto decimal_no_scale = Literal::Decimal (int128_t {42 }, 5 , 0 ); // 42
304-
305- // Test expected decimal formatting
306- EXPECT_EQ (decimal_pos.ToString (), " 123.45" );
307- EXPECT_EQ (decimal_neg.ToString (), " -9.876" );
308- EXPECT_EQ (decimal_zero.ToString (), " 0.0" );
309- EXPECT_EQ (decimal_no_scale.ToString (), " 42" );
310- }
311-
312- TEST (LiteralTest, DecimalComparison) {
313- auto decimal1 = Literal::Decimal (int128_t {1000 }, 10 , 2 );
314- auto decimal2 = Literal::Decimal (int128_t {2000 }, 10 , 2 );
315- auto decimal3 = Literal::Decimal (int128_t {1000 }, 10 , 2 );
316- auto decimal_neg = Literal::Decimal (int128_t {-1000 }, 10 , 2 );
317-
318- EXPECT_EQ (decimal1 <=> decimal3, std::partial_ordering::equivalent);
319- EXPECT_EQ (decimal1 <=> decimal2, std::partial_ordering::less);
320- EXPECT_EQ (decimal2 <=> decimal1, std::partial_ordering::greater);
321- EXPECT_EQ (decimal_neg <=> decimal1, std::partial_ordering::less);
322- }
323-
324- TEST (LiteralTest, DecimalMaxPrecisionAndScale) {
325- // Test with maximum precision and scale values
326- auto max_decimal = Literal::Decimal (int128_t {1 }, 38 , 38 );
327-
328- EXPECT_EQ (max_decimal.type ()->type_id (), TypeId::kDecimal );
329- auto decimal_type = std::static_pointer_cast<iceberg::DecimalType>(max_decimal.type ());
330- EXPECT_EQ (decimal_type->precision (), 38 );
331- EXPECT_EQ (decimal_type->scale (), 38 );
332- }
333-
334- TEST (LiteralTest, DecimalZeroScale) {
335- // Test with zero scale (integer)
336- auto int_decimal = Literal::Decimal (int128_t {12345 }, 10 , 0 );
337-
338- EXPECT_EQ (int_decimal.type ()->type_id (), TypeId::kDecimal );
339- auto decimal_type = std::static_pointer_cast<iceberg::DecimalType>(int_decimal.type ());
340- EXPECT_EQ (decimal_type->precision (), 10 );
341- EXPECT_EQ (decimal_type->scale (), 0 );
342- }
343-
344259// String type tests
345260TEST (LiteralTest, StringBasics) {
346261 auto string_literal = Literal::String (" hello world" );
@@ -363,20 +278,6 @@ TEST(LiteralTest, StringComparison) {
363278 EXPECT_EQ (string2 <=> string1, std::partial_ordering::greater);
364279}
365280
366- TEST (LiteralTest, StringCastTo) {
367- auto string_literal = Literal::String (" 123.456" );
368-
369- // Cast to Decimal
370- auto decimal_result = string_literal.CastTo (iceberg::decimal (10 , 3 ));
371- ASSERT_THAT (decimal_result, IsOk ());
372- EXPECT_EQ (decimal_result->type ()->type_id (), TypeId::kDecimal );
373-
374- // Invalid string should fail
375- auto invalid_string = Literal::String (" not_a_number" );
376- EXPECT_THAT (invalid_string.CastTo (iceberg::decimal (10 , 2 )),
377- IsError (ErrorKind::kInvalidArgument ));
378- }
379-
380281// Binary type tests
381282TEST (LiteralTest, BinaryBasics) {
382283 std::vector<uint8_t > data = {0x01 , 0x02 , 0x03 , 0xFF };
@@ -551,38 +452,23 @@ TEST(LiteralTest, TimestampTzComparison) {
551452TEST (LiteralTest, CrossTypeComparison) {
552453 auto int_literal = Literal::Int (42 );
553454 auto string_literal = Literal::String (" 42" );
554- auto decimal_literal = Literal::Decimal (int128_t {42 }, 10 , 2 );
555455
556456 // Different types should return unordered
557457 EXPECT_EQ (int_literal <=> string_literal, std::partial_ordering::unordered);
558- EXPECT_EQ (decimal_literal <=> int_literal, std::partial_ordering::unordered);
559458}
560459
561460// Same type cast tests
562461TEST (LiteralTest, SameTypeCast) {
563462 auto int_literal = Literal::Int (42 );
564- auto decimal_literal = Literal::Decimal (int128_t {12345 }, 10 , 2 );
565-
566- auto int_same_type_result = int_literal.CastTo (iceberg::int32 ());
567- ASSERT_THAT (int_same_type_result, IsOk ());
568- EXPECT_EQ (int_same_type_result->type ()->type_id (), TypeId::kInt );
569- EXPECT_EQ (int_same_type_result->ToString (), " 42" );
570463
571- auto decimal_same_type_result = decimal_literal.CastTo (iceberg::decimal (10 , 2 ));
572- ASSERT_THAT (decimal_same_type_result, IsOk ());
573- EXPECT_EQ (decimal_same_type_result->type ()->type_id (), TypeId::kDecimal );
464+ AssertCastSucceeds (int_literal.CastTo (iceberg::int32 ()), TypeId::kInt , 42 );
574465}
575466
576467// Special value tests
577468TEST (LiteralTest, SpecialValues) {
578469 auto int_literal = Literal::Int (42 );
579- auto decimal_literal = Literal::Decimal (int128_t {12345 }, 10 , 2 );
580-
581470 EXPECT_FALSE (int_literal.IsAboveMax ());
582471 EXPECT_FALSE (int_literal.IsBelowMin ());
583- EXPECT_FALSE (decimal_literal.IsAboveMax ());
584- EXPECT_FALSE (decimal_literal.IsBelowMin ());
585- EXPECT_FALSE (decimal_literal.IsNull ());
586472}
587473
588474// Float special values tests
0 commit comments