2727namespace iceberg {
2828
2929SchemaField::SchemaField (int32_t field_id, std::string name, std::shared_ptr<Type> type,
30- bool optional)
30+ bool optional, std::string doc )
3131 : field_id_(field_id),
3232 name_ (std::move(name)),
3333 type_(std::move(type)),
34- optional_(optional) {}
34+ optional_(optional),
35+ doc_(std::move(doc)) {}
3536
3637SchemaField SchemaField::MakeOptional (int32_t field_id, std::string name,
37- std::shared_ptr<Type> type) {
38- return SchemaField ( field_id, std::move (name), std::move (type), true ) ;
38+ std::shared_ptr<Type> type, std::string doc ) {
39+ return { field_id, std::move (name), std::move (type), true , std::move (doc)} ;
3940}
4041
4142SchemaField SchemaField::MakeRequired (int32_t field_id, std::string name,
42- std::shared_ptr<Type> type) {
43- return SchemaField ( field_id, std::move (name), std::move (type), false ) ;
43+ std::shared_ptr<Type> type, std::string doc ) {
44+ return { field_id, std::move (name), std::move (type), false , std::move (doc)} ;
4445}
4546
4647int32_t SchemaField::field_id () const { return field_id_; }
@@ -51,9 +52,13 @@ const std::shared_ptr<Type>& SchemaField::type() const { return type_; }
5152
5253bool SchemaField::optional () const { return optional_; }
5354
55+ std::string_view SchemaField::doc () const { return doc_; }
56+
5457std::string SchemaField::ToString () const {
55- return std::format (" {} ({}): {} ({})" , name_, field_id_, *type_,
56- optional_ ? " optional" : " required" );
58+ std::string result = std::format (" {} ({}): {} ({}){}" , name_, field_id_, *type_,
59+ optional_ ? " optional" : " required" ,
60+ !doc_.empty () ? std::format (" - {}" , doc_) : " " );
61+ return result;
5762}
5863
5964bool SchemaField::Equals (const SchemaField& other) const {
0 commit comments