Skip to content

Commit a16cfc3

Browse files
committed
add test and remove decimal
1 parent 4a3420b commit a16cfc3

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

src/iceberg/expression/literal.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,6 @@ Result<std::vector<uint8_t>> LiteralSerializer::ToBytes(const Literal& literal)
570570
return result;
571571
}
572572

573-
case TypeId::kDecimal: {
574-
// Stores unscaled value as two's-complement big-endian binary
575-
const auto& decimal_bytes = std::get<std::array<uint8_t, 16>>(value);
576-
WriteBigEndian16(result, decimal_bytes);
577-
return result;
578-
}
579-
580573
default:
581574
return NotImplemented("Serialization for type {} is not supported",
582575
literal.type()->ToString());

test/literal_test.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,14 +616,6 @@ TEST(LiteralSerializationTest, FixedUuidDecimal) {
616616
auto uuid_bytes = uuid_result->Serialize();
617617
ASSERT_TRUE(uuid_bytes.has_value());
618618
EXPECT_EQ(*uuid_bytes, uuid_data);
619-
620-
// Decimal type
621-
std::vector<uint8_t> decimal_data(16, 0x99);
622-
auto decimal_result = Literal::Deserialize(decimal_data, decimal(10, 2));
623-
ASSERT_TRUE(decimal_result.has_value());
624-
auto decimal_bytes = decimal_result->Serialize();
625-
ASSERT_TRUE(decimal_bytes.has_value());
626-
EXPECT_EQ(*decimal_bytes, decimal_data);
627619
}
628620

629621
} // namespace iceberg

test/manifest_reader_test.cc

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,34 @@ class ManifestReaderV1Test : public TempFileTestBase {
5959
"order_ts_hour=2021-01-26-00/"
6060
"00000-2-d5ae78b7-4449-45ec-adb7-c0e9c0bdb714-0-00004.parquet"};
6161
std::vector<int64_t> partitions = {447696, 473976, 465192, 447672};
62+
63+
// TODO(Li Feiyang): The Decimal type and its serialization logic are not yet fully
64+
// implemented
65+
// to support variable-length encoding as required by the Iceberg specification.
66+
// Using Literal::Binary as a temporary substitute to represent the raw bytes
67+
// for the decimal values.
6268
std::vector<std::map<int32_t, std::vector<uint8_t>>> bounds = {
63-
{{1, {0xd2, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
64-
{2, {'.', 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
65-
{3, {0x12, 0xe2}},
66-
{4, {0xc0, 'y', 0xe7, 0x98, 0xd6, 0xb9, 0x05, 0x00}}},
67-
{{1, {0xd2, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
68-
{2, {'.', 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
69-
{3, {0x12, 0xe3}},
70-
{4, {0xc0, 0x19, '#', '=', 0xe2, 0x0f, 0x06, 0x00}}},
71-
{{1, {'{', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
72-
{2, {0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
73-
{3, {0x0e, '"'}},
74-
{4, {0xc0, 0xd9, '7', 0x93, 0x1f, 0xf3, 0x05, 0x00}}},
75-
{{1, {'{', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
76-
{2, {0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
77-
{3, {0x0e, '!'}},
78-
{4, {0xc0, 0x19, 0x10, '{', 0xc2, 0xb9, 0x05, 0x00}}},
69+
{{1, iceberg::Literal::Long(1234).Serialize().value()},
70+
{2, iceberg::Literal::Long(5678).Serialize().value()},
71+
{3, iceberg::Literal::Binary({0x12, 0xe2}).Serialize().value()},
72+
73+
{4, iceberg::Literal::Timestamp(1611706223000000LL).Serialize().value()}},
74+
{{1, iceberg::Literal::Long(1234).Serialize().value()},
75+
{2, iceberg::Literal::Long(5678).Serialize().value()},
76+
{3, iceberg::Literal::Binary({0x12, 0xe3}).Serialize().value()},
77+
78+
{4, iceberg::Literal::Timestamp(1706314223000000LL).Serialize().value()}},
79+
{{1, iceberg::Literal::Long(123).Serialize().value()},
80+
{2, iceberg::Literal::Long(456).Serialize().value()},
81+
{3, iceberg::Literal::Binary({0x0e, 0x22}).Serialize().value()},
82+
83+
{4, iceberg::Literal::Timestamp(1674691823000000LL).Serialize().value()}},
84+
{{1, iceberg::Literal::Long(123).Serialize().value()},
85+
{2, iceberg::Literal::Long(456).Serialize().value()},
86+
{3, iceberg::Literal::Binary({0x0e, 0x21}).Serialize().value()},
87+
{4, iceberg::Literal::Timestamp(1611619823000000LL).Serialize().value()}},
7988
};
89+
8090
for (int i = 0; i < 4; ++i) {
8191
ManifestEntry entry;
8292
entry.status = ManifestStatus::kAdded;
@@ -143,16 +153,16 @@ class ManifestReaderV2Test : public TempFileTestBase {
143153
std::vector<int64_t> record_counts = {4};
144154

145155
std::vector<std::map<int32_t, std::vector<uint8_t>>> lower_bounds = {
146-
{{1, {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
147-
{2, {'r', 'e', 'c', 'o', 'r', 'd', '_', 'f', 'o', 'u', 'r'}},
148-
{3, {'d', 'a', 't', 'a', '_', 'c', 'o', 'n', 't', 'e', 'n', 't', '_', '1'}},
149-
{4, {0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xdc, 0x5e, 0x40}}}};
156+
{{1, iceberg::Literal::Long(1).Serialize().value()},
157+
{2, iceberg::Literal::String("record_four").Serialize().value()},
158+
{3, iceberg::Literal::String("data_content_1").Serialize().value()},
159+
{4, iceberg::Literal::Double(123.45).Serialize().value()}}};
150160

151161
std::vector<std::map<int32_t, std::vector<uint8_t>>> upper_bounds = {
152-
{{1, {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
153-
{2, {'r', 'e', 'c', 'o', 'r', 'd', '_', 't', 'w', 'o'}},
154-
{3, {'d', 'a', 't', 'a', '_', 'c', 'o', 'n', 't', 'e', 'n', 't', '_', '4'}},
155-
{4, {0x14, 0xae, 0x47, 0xe1, 0x7a, 0x8c, 0x7c, 0x40}}}};
162+
{{1, iceberg::Literal::Long(4).Serialize().value()},
163+
{2, iceberg::Literal::String("record_two").Serialize().value()},
164+
{3, iceberg::Literal::String("data_content_4").Serialize().value()},
165+
{4, iceberg::Literal::Double(456.78).Serialize().value()}}};
156166

157167
manifest_entries.emplace_back(
158168
ManifestEntry{.status = ManifestStatus::kAdded,

0 commit comments

Comments
 (0)