41 static constexpr int32_t kInvalidFieldId = -1;
51 SchemaField(int32_t field_id, std::string_view name, std::shared_ptr<Type> type,
52 bool optional, std::string_view doc = {},
53 std::shared_ptr<const Literal> initial_default =
nullptr,
54 std::shared_ptr<const Literal> write_default =
nullptr);
58 std::shared_ptr<Type> type, std::string_view doc = {});
61 std::shared_ptr<Type> type, std::string_view doc = {});
80 const Literal& value,
const std::shared_ptr<PrimitiveType>& target_type);
86 std::string_view
name()
const;
89 const std::shared_ptr<Type>&
type()
const;
95 std::string_view
doc()
const;
105 Status Validate()
const;
108 return lhs.Equals(rhs);
113 copy.optional_ =
false;
117 SchemaField AsOptional()
const {
119 copy.optional_ =
true;
125 bool Equals(
const SchemaField& other)
const;
129 std::shared_ptr<Type> type_;
132 std::shared_ptr<const Literal> initial_default_;
133 std::shared_ptr<const Literal> write_default_;
Literal is a literal value that is associated with a primitive type.
Definition literal.h:42
A type combined with a name.
Definition schema_field.h:39
SchemaField WithInitialDefault(std::shared_ptr< const Literal > initial_default) const
Return a copy with a new initial-default.
SchemaField WithName(std::string_view name) const
Return a copy with a new name.
const std::shared_ptr< const Literal > & write_default() const
Get the v3 write-default, or null if absent.
std::string ToString() const override
Get a user-readable string representation.
int32_t field_id() const
Get the field ID.
SchemaField WithDoc(std::string_view doc) const
Return a copy with new documentation.
SchemaField WithWriteDefault(std::shared_ptr< const Literal > write_default) const
Return a copy with a new write-default.
SchemaField WithType(std::shared_ptr< Type > type) const
Return a copy with a new type.
std::string_view name() const
Get the field name.
SchemaField(int32_t field_id, std::string_view name, std::shared_ptr< Type > type, bool optional, std::string_view doc={}, std::shared_ptr< const Literal > initial_default=nullptr, std::shared_ptr< const Literal > write_default=nullptr)
Construct a field.
static SchemaField MakeRequired(int32_t field_id, std::string_view name, std::shared_ptr< Type > type, std::string_view doc={})
Construct a required (non-null) field.
const std::shared_ptr< Type > & type() const
Get the field type.
bool optional() const
Get whether the field is optional.
static Result< Literal > CastDefaultValue(const Literal &value, const std::shared_ptr< PrimitiveType > &target_type)
Cast a default literal to a field type.
static SchemaField MakeOptional(int32_t field_id, std::string_view name, std::shared_ptr< Type > type, std::string_view doc={})
Construct an optional (nullable) field.
std::string_view doc() const
Get the field documentation.
const std::shared_ptr< const Literal > & initial_default() const
Get the v3 initial-default, or null if absent.
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.