2727#include " paimon/common/types/data_field.h"
2828#include " paimon/common/utils/jsonizable.h"
2929#include " paimon/result.h"
30+ #include " paimon/schema/schema.h"
3031#include " rapidjson/allocators.h"
3132#include " rapidjson/document.h"
3233#include " rapidjson/rapidjson.h"
@@ -35,7 +36,7 @@ struct ArrowSchema;
3536
3637namespace paimon {
3738// / Schema of a table, including schemaId and fieldId.
38- class TableSchema : public Jsonizable <TableSchema> {
39+ class TableSchema : public Schema , public Jsonizable <TableSchema> {
3940 public:
4041 static constexpr int64_t FIRST_SCHEMA_ID = 0 ;
4142 static constexpr int32_t PAIMON_07_VERSION = 1 ;
@@ -57,28 +58,35 @@ class TableSchema : public Jsonizable<TableSchema> {
5758
5859 bool operator ==(const TableSchema& other) const ;
5960
60- std::vector<std::string> FieldNames () const ;
61- int64_t Id () const {
61+ Result<std::unique_ptr<::ArrowSchema>> GetArrowSchema () const override ;
62+
63+ Result<std::string> GetJsonSchema () const override {
64+ return ToJsonString ();
65+ }
66+
67+ std::vector<std::string> FieldNames () const override ;
68+
69+ int64_t Id () const override {
6270 return id_;
6371 }
64- const std::vector<std::string>& PrimaryKeys () const {
72+ const std::vector<std::string>& PrimaryKeys () const override {
6573 return primary_keys_;
6674 }
67- const std::vector<std::string>& PartitionKeys () const {
75+ const std::vector<std::string>& PartitionKeys () const override {
6876 return partition_keys_;
6977 }
7078
71- const std::vector<std::string>& BucketKeys () const {
79+ const std::vector<std::string>& BucketKeys () const override {
7280 return bucket_keys_;
7381 }
7482
75- int32_t NumBuckets () const {
83+ int32_t NumBuckets () const override {
7684 return num_bucket_;
7785 }
78- int32_t HighestFieldId () const {
86+ int32_t HighestFieldId () const override {
7987 return highest_field_id_;
8088 }
81- const std::map<std::string, std::string>& Options () const {
89+ const std::map<std::string, std::string>& Options () const override {
8290 return options_;
8391 }
8492 const std::vector<DataField>& Fields () const {
@@ -92,7 +100,7 @@ class TableSchema : public Jsonizable<TableSchema> {
92100 Result<std::vector<DataField>> GetFields (const std::vector<std::string>& field_names) const ;
93101 Result<std::vector<std::string>> TrimmedPrimaryKeys () const ;
94102
95- std::optional<std::string> Comment () const {
103+ std::optional<std::string> Comment () const override {
96104 return comment_;
97105 }
98106
@@ -130,7 +138,7 @@ class TableSchema : public Jsonizable<TableSchema> {
130138 std::vector<std::string> partition_keys_;
131139 std::vector<std::string> primary_keys_;
132140 std::vector<std::string> bucket_keys_;
133- int32_t num_bucket_;
141+ int32_t num_bucket_ = - 1 ;
134142 std::map<std::string, std::string> options_;
135143 std::optional<std::string> comment_;
136144 int64_t time_millis_ = -1 ;
0 commit comments