48 bool operator==(
const BelowMin&)
const =
default;
49 std::strong_ordering operator<=>(
const BelowMin&)
const =
default;
56 bool operator==(
const AboveMax&)
const =
default;
57 std::strong_ordering operator<=>(
const AboveMax&)
const =
default;
59 using Value = std::variant<std::monostate,
73 static Literal Int(int32_t value);
74 static Literal Date(int32_t value);
75 static Literal Long(int64_t value);
76 static Literal Time(int64_t value);
77 static Literal Timestamp(int64_t value);
78 static Literal TimestampTz(int64_t value);
79 static Literal TimestampNs(int64_t value);
80 static Literal TimestampTzNs(int64_t value);
81 static Literal Float(
float value);
82 static Literal Double(
double value);
83 static Literal String(std::string value);
85 static Literal Binary(std::vector<uint8_t> value);
86 static Literal Fixed(std::vector<uint8_t> value);
94 return {Value{std::monostate{}}, std::move(type)};
102 std::shared_ptr<PrimitiveType> type);
111 const std::shared_ptr<PrimitiveType>&
type()
const;
114 const Value&
value()
const {
return value_; }
136 bool operator==(
const Literal& other)
const;
169 Literal(Value value, std::shared_ptr<PrimitiveType> type);
172 friend class LiteralCaster;
175 std::shared_ptr<PrimitiveType> type_;
180 std::size_t operator()(
const Literal::Value& value)
const noexcept;
184 std::size_t operator()(
const Literal& value)
const noexcept {
189template <TypeId type_
id>
191 using ValueType = void;
194#define DEFINE_LITERAL_TRAIT(TYPE_ID, VALUE_TYPE) \
196 struct LiteralTraits<TypeId::TYPE_ID> { \
197 using ValueType = VALUE_TYPE; \
200DEFINE_LITERAL_TRAIT(kBoolean,
bool)
201DEFINE_LITERAL_TRAIT(kInt, int32_t)
202DEFINE_LITERAL_TRAIT(kDate, int32_t)
203DEFINE_LITERAL_TRAIT(kLong, int64_t)
204DEFINE_LITERAL_TRAIT(kTime, int64_t)
205DEFINE_LITERAL_TRAIT(kTimestamp, int64_t)
206DEFINE_LITERAL_TRAIT(kTimestampTz, int64_t)
207DEFINE_LITERAL_TRAIT(kTimestampNs, int64_t)
208DEFINE_LITERAL_TRAIT(kTimestampTzNs, int64_t)
209DEFINE_LITERAL_TRAIT(kFloat,
float)
210DEFINE_LITERAL_TRAIT(kDouble,
double)
211DEFINE_LITERAL_TRAIT(kDecimal,
Decimal)
212DEFINE_LITERAL_TRAIT(kString, std::string)
213DEFINE_LITERAL_TRAIT(kUuid,
Uuid)
214DEFINE_LITERAL_TRAIT(kBinary, std::vector<uint8_t>)
215DEFINE_LITERAL_TRAIT(kFixed, std::vector<uint8_t>)
217#undef DEFINE_LITERAL_TRAIT
Conversion utilities for primitive types.
Definition conversions.h:35
Represents 128-bit fixed-point decimal numbers. The max decimal precision that can be safely represen...
Definition decimal.h:46
Literal is a literal value that is associated with a primitive type.
Definition literal.h:42
std::string ToString() const override
Get a user-readable string representation.
static Literal Null(std::shared_ptr< PrimitiveType > type)
Create a literal representing a null value.
Definition literal.h:93
const Value & value() const
Get the literal value.
Definition literal.h:114
Result< Literal > CastTo(const std::shared_ptr< PrimitiveType > &target_type) const
Converts this literal to a literal of the given type.
Result< std::vector< uint8_t > > Serialize() const
Perform single-value serialization.
bool IsNaN() const
Check if this literal is NaN.
static Literal Decimal(int128_t value, int32_t precision, int32_t scale)
Create a decimal literal.
const std::shared_ptr< PrimitiveType > & type() const
Get the literal type.
static Result< Literal > Deserialize(std::span< const uint8_t > data, std::shared_ptr< PrimitiveType > type)
Restore a literal from single-value serialization.
bool IsNull() const
Check if this literal is null.
std::partial_ordering operator<=>(const Literal &other) const
Compare two literals of the same primitive type.
static Literal Boolean(bool value)
Factory methods for primitive types.
128-bit fixed-point decimal numbers. Adapted from Apache Arrow with only Decimal128 support....
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
Hash function for Literal to facilitate use in unordered containers.
Definition literal.h:179
Sentinel value to indicate that the literal value is above the valid range of a specific primitive ty...
Definition literal.h:55
Sentinel value to indicate that the literal value is below the valid range of a specific primitive ty...
Definition literal.h:47
UUID (Universally Unique Identifier) representation.