35#include "iceberg/expression/literal.h"
36#include "iceberg/result.h"
46using Scalar = std::variant<std::monostate,
54 std::shared_ptr<StructLike>,
55 std::shared_ptr<ArrayLike>,
56 std::shared_ptr<MapLike>>;
59Result<Scalar> LiteralToScalar(
const Literal& literal);
68 virtual Result<Scalar>
GetField(
size_t pos)
const = 0;
84 virtual size_t size()
const = 0;
94 virtual Result<Scalar>
GetKey(
size_t pos)
const = 0;
98 virtual Result<Scalar>
GetValue(
size_t pos)
const = 0;
101 virtual size_t size()
const = 0;
108 std::span<const size_t> position_path);
112 return accessor_(struct_like);
119 Result<Literal> GetLiteral(
const StructLike& struct_like)
const;
128 std::shared_ptr<Type> type_;
129 std::function<Result<Scalar>(
const StructLike&)> accessor_;
130 std::vector<size_t> position_path_;
An immutable array-like wrapper.
Definition struct_like.h:75
virtual Result< Scalar > GetElement(size_t pos) const =0
Get the array element at the given position.
virtual size_t size() const =0
Get the number of elements in the array.
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:39
An immutable map-like wrapper.
Definition struct_like.h:88
virtual size_t size() const =0
Get the number of entries in the map.
virtual Result< Scalar > GetValue(size_t pos) const =0
Get the value at the given position.
virtual Result< Scalar > GetKey(size_t pos) const =0
Get the key at the given position.
An accessor for a struct-like object.
Definition struct_like.h:105
const std::vector< size_t > & position_path() const
Get the position path of the value that this accessor bounded to.
Definition struct_like.h:125
const Type & type() const
Get the type of the value that this accessor is bound to.
Definition struct_like.h:122
Result< Scalar > Get(const StructLike &struct_like) const
Get the scalar value at the given position.
Definition struct_like.h:111
An immutable struct-like wrapper.
Definition struct_like.h:62
virtual Result< Scalar > GetField(size_t pos) const =0
Get the field value at the given position.
virtual size_t num_fields() const =0
Get the number of fields in the struct.
Interface for a data type for a field.
Definition type.h:44
128-bit fixed-point decimal numbers. Adapted from Apache Arrow with only Decimal128 support....
std::variant< std::monostate, bool, int32_t, int64_t, float, double, std::string_view, Decimal, std::shared_ptr< StructLike >, std::shared_ptr< ArrayLike >, std::shared_ptr< MapLike > > Scalar
A scalar value depending on its data type.
Definition struct_like.h:56