Skip to content

Commit bbc59b0

Browse files
committed
support fixed
1 parent e187322 commit bbc59b0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/iceberg/expression/literal.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ std::partial_ordering Literal::operator<=>(const Literal& other) const {
255255
return this_val <=> other_val;
256256
}
257257

258+
case TypeId::kFixed: {
259+
// Fixed types can only be compared if they have the same length
260+
auto& this_fixed_type = static_cast<const FixedType&>(*type_);
261+
auto& other_fixed_type = static_cast<const FixedType&>(*other.type_);
262+
263+
if (this_fixed_type.length() != other_fixed_type.length()) {
264+
return std::partial_ordering::unordered;
265+
}
266+
267+
auto& this_val = std::get<std::vector<uint8_t>>(value_);
268+
auto& other_val = std::get<std::vector<uint8_t>>(other.value_);
269+
return this_val <=> other_val;
270+
}
271+
258272
default:
259273
// For unsupported types, return unordered
260274
return std::partial_ordering::unordered;

src/iceberg/test/literal_test.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,27 @@ INSTANTIATE_TEST_SUITE_P(
492492
binary()},
493493
LiteralRoundTripParam{"BinarySingleByte", {42}, Literal::Binary({42}), binary()},
494494

495+
// Fixed type
496+
LiteralRoundTripParam{"FixedLength4",
497+
{0x01, 0x02, 0x03, 0x04},
498+
Literal::Fixed({0x01, 0x02, 0x03, 0x04}, 4),
499+
fixed(4)},
500+
LiteralRoundTripParam{
501+
"FixedLength8",
502+
{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11},
503+
Literal::Fixed({0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11}, 8),
504+
fixed(8)},
505+
LiteralRoundTripParam{
506+
"FixedLength16",
507+
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
508+
0x0D, 0x0E, 0x0F},
509+
Literal::Fixed({0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
510+
0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
511+
16),
512+
fixed(16)},
513+
LiteralRoundTripParam{
514+
"FixedSingleByte", {0xFF}, Literal::Fixed({0xFF}, 1), fixed(1)},
515+
495516
// Temporal types
496517
LiteralRoundTripParam{"DateEpoch", {0, 0, 0, 0}, Literal::Date(0), date()},
497518
LiteralRoundTripParam{"DateNextDay", {1, 0, 0, 0}, Literal::Date(1), date()},

0 commit comments

Comments
 (0)