Literal is a literal value that is associated with a primitive type.
More...
#include <literal.h>
|
| struct | AboveMax |
| | Sentinel value to indicate that the literal value is above the valid range of a specific primitive type. It can happen when casting a literal to a narrower primitive type. More...
|
| |
| struct | BelowMin |
| | Sentinel value to indicate that the literal value is below the valid range of a specific primitive type. It can happen when casting a literal to a narrower primitive type. More...
|
| |
|
|
using | Value = std::variant< std::monostate, bool, int32_t, int64_t, float, double, std::string, std::vector< uint8_t >, ::iceberg::Decimal, Uuid, BelowMin, AboveMax > |
| |
|
| Result< std::vector< uint8_t > > | Serialize () const |
| | Perform single-value serialization.
|
| |
|
const std::shared_ptr< PrimitiveType > & | type () const |
| | Get the literal type.
|
| |
|
const Value & | value () const |
| | Get the literal value.
|
| |
| Result< Literal > | CastTo (const std::shared_ptr< PrimitiveType > &target_type) const |
| | Converts this literal to a literal of the given type.
|
| |
|
bool | operator== (const Literal &other) const |
| |
| std::partial_ordering | operator<=> (const Literal &other) const |
| | Compare two literals of the same primitive type.
|
| |
| bool | IsAboveMax () const |
| |
| bool | IsBelowMin () const |
| |
| bool | IsNull () const |
| | Check if this literal is null.
|
| |
| bool | IsNaN () const |
| | Check if this literal is NaN.
|
| |
| std::string | ToString () const override |
| | Get a user-readable string representation.
|
| |
|
|
class | Conversions |
| |
|
class | LiteralCaster |
| |
Literal is a literal value that is associated with a primitive type.
◆ CastTo()
| Result< Literal > iceberg::Literal::CastTo |
( |
const std::shared_ptr< PrimitiveType > & |
target_type | ) |
const |
Converts this literal to a literal of the given type.
When a predicate is bound to a concrete data column, literals are converted to match the bound column's type. This conversion process is more narrow than a cast and is only intended for cases where substituting one type is a common mistake (e.g. 34 instead of 34L) or where this API avoids requiring a concrete class (e.g., dates).
If conversion to a target type is not supported, this method returns an error.
This method may return BelowMin or AboveMax when the target type is not as wide as the original type. These values indicate that the containing predicate can be simplified. For example, std::numeric_limits<int>::max()+1 converted to an int will result in AboveMax and can simplify a < std::numeric_limits<int>::max()+1 to always true.
- Parameters
-
- Returns
- A Result containing a literal of the given type or an error if conversion was not valid
◆ Decimal()
| Literal iceberg::Literal::Decimal |
( |
int128_t |
value, |
|
|
int32_t |
precision, |
|
|
int32_t |
scale |
|
) |
| |
|
static |
Create a decimal literal.
- Parameters
-
| value | The unscaled 128-bit integer value. |
◆ Deserialize()
| Result< Literal > iceberg::Literal::Deserialize |
( |
std::span< const uint8_t > |
data, |
|
|
std::shared_ptr< PrimitiveType > |
type |
|
) |
| |
|
static |
Restore a literal from single-value serialization.
See this spec for reference.
◆ IsAboveMax()
| bool iceberg::Literal::IsAboveMax |
( |
| ) |
const |
Check if this literal represents a value above the maximum allowed value for its type. This occurs when casting from a wider type to a narrower type and the value exceeds the target type's maximum.
- Returns
- true if this literal represents an AboveMax value, false otherwise
◆ IsBelowMin()
| bool iceberg::Literal::IsBelowMin |
( |
| ) |
const |
Check if this literal represents a value below the minimum allowed value for its type. This occurs when casting from a wider type to a narrower type and the value is less than the target type's minimum.
- Returns
- true if this literal represents a BelowMin value, false otherwise
◆ IsNaN()
| bool iceberg::Literal::IsNaN |
( |
| ) |
const |
Check if this literal is NaN.
- Returns
- true if this literal is NaN, false otherwise
◆ IsNull()
| bool iceberg::Literal::IsNull |
( |
| ) |
const |
Check if this literal is null.
- Returns
- true if this literal is null, false otherwise
◆ operator<=>()
| std::partial_ordering iceberg::Literal::operator<=> |
( |
const Literal & |
other | ) |
const |
Compare two literals of the same primitive type.
- Parameters
-
| other | The other literal to compare with. |
- Returns
- The comparison result as std::partial_ordering. If either side is AboveMax, BelowMin or Null, the result is unordered. Note: This comparison cannot be used for sorting literals if any literal is AboveMax, BelowMin or Null.
◆ Serialize()
| Result< std::vector< uint8_t > > iceberg::Literal::Serialize |
( |
| ) |
const |
Perform single-value serialization.
See this spec for reference.
◆ ToString()
| std::string iceberg::Literal::ToString |
( |
| ) |
const |
|
overridevirtual |
The documentation for this class was generated from the following files:
- iceberg/expression/literal.h
- iceberg/expression/literal.cc