@@ -45,47 +45,8 @@ enum class MetadataTableType {
4545// / support. They provide read-only access to metadata.
4646class ICEBERG_EXPORT MetadataTable : public StaticTable {
4747 public:
48- // / \brief Returns the identifier of this table
49- const TableIdentifier& name () const override { return identifier_; }
50-
5148 virtual MetadataTableType type () const noexcept = 0;
5249
53- // / \brief Returns the UUID of the table
54- const std::string& uuid () const { return uuid_; }
55-
56- // / \brief Returns the schema for this table, return NotFoundError if not found
57- Result<std::shared_ptr<Schema>> schema () const { return schema_; }
58-
59- // / \brief Returns a map of schema for this table
60- Result<
61- std::reference_wrapper<const std::unordered_map<int32_t , std::shared_ptr<Schema>>>>
62- schemas () const {
63- return schemas_;
64- }
65-
66- // / \brief Returns the partition spec for this table, return NotFoundError if not found
67- Result<std::shared_ptr<PartitionSpec>> spec () const { return partition_spec; };
68-
69- // / \brief Returns a map of partition specs for this table
70- Result<std::reference_wrapper<
71- const std::unordered_map<int32_t , std::shared_ptr<PartitionSpec>>>>
72- specs () const {
73- return partition_specs_;
74- }
75-
76- // / \brief Returns the sort order for this table, return NotFoundError if not found
77- Result<std::shared_ptr<SortOrder>> sort_order () const { return sort_order_; }
78-
79- // / \brief Returns a map of sort order IDs to sort orders for this table
80- Result<std::reference_wrapper<
81- const std::unordered_map<int32_t , std::shared_ptr<SortOrder>>>>
82- sort_orders () const {
83- return sort_orders_;
84- }
85-
86- // / \brief Returns the properties of this table
87- const TableProperties& properties () const { return properties_; }
88-
8950 // / \brief Returns the table's metadata file location
9051 std::string_view metadata_file_location () const {
9152 return source_table_->metadata_file_location ();
@@ -120,12 +81,6 @@ class ICEBERG_EXPORT MetadataTable : public StaticTable {
12081 return source_table_->history ();
12182 }
12283
123- // / \brief Returns the current metadata for this table
124- const std::shared_ptr<TableMetadata>& metadata () const {
125- // TODO: or should we return an empty TableMetadata?
126- return source_table_->metadata ();
127- }
128-
12984 // / \brief Returns the catalog that this table belongs to
13085 const std::shared_ptr<Catalog>& catalog () const { return source_table_->catalog (); }
13186
@@ -141,24 +96,23 @@ class ICEBERG_EXPORT MetadataTable : public StaticTable {
14196 // /
14297 // / Once a table scan builder is created, it can be refined to project columns and
14398 // / filter data.
144- Result<std::unique_ptr<TableScanBuilder>> NewScan () const ;
99+ Result<std::unique_ptr<TableScanBuilder>> NewScan () const override ;
100+
101+ ~MetadataTable ();
145102
146103 protected:
147104 explicit MetadataTable (std::shared_ptr<Table> source_table, TableIdentifier identifier);
148105
149- ~MetadataTable ();
106+ // / \brief Returns the schema for this metadata table
107+ // /
108+ // / Subclasses override this method to provide their custom schema during
109+ // / MetadataTable construction. The returned schema is used to initialize
110+ // / the underlying TableMetadata.
111+ // /
112+ // / \return The schema for this metadata table, or nullptr for default schema
113+ virtual std::shared_ptr<Schema> GetSchema () const { return nullptr ; }
150114
151115 std::shared_ptr<Table> source_table_;
152- std::string uuid_;
153- std::shared_ptr<Schema> schema_;
154- std::unordered_map<int32_t , std::shared_ptr<Schema>> schemas_;
155- TableProperties properties_ = TableProperties();
156- const std::shared_ptr<SortOrder> sort_order_ = SortOrder::Unsorted();
157- const std::unordered_map<int32_t , std::shared_ptr<SortOrder>> sort_orders_ = {
158- {sort_order_->order_id (), sort_order_}};
159- const std::shared_ptr<PartitionSpec> partition_spec = PartitionSpec::Unpartitioned();
160- const std::unordered_map<int32_t , std::shared_ptr<PartitionSpec>> partition_specs_ = {
161- {partition_spec->spec_id (), partition_spec}};
162116};
163117
164118// / \brief Metadata table factory and inspector
@@ -168,24 +122,20 @@ class ICEBERG_EXPORT MetadataTable : public StaticTable {
168122// / table's metadata as a scannable Iceberg table.
169123// /
170124// / Usage:
171- // / auto snapshots = ICEBERG_TRY(MetadataTable::GetSnapshotsTable(table));
172- // / auto scan = ICEBERG_TRY(snapshots->NewScan());
173- // / // ... scan and read snapshot data
125+ // / auto metadata_table = ICEBERG_TRY(
126+ // / MetadataTableFactory::CreateMetadataTable(
127+ // / table, MetadataTableType::kSnapshots));
128+ // / auto scan = ICEBERG_TRY(metadata_table->NewScan());
129+ // / // ... scan and read metadata table data
174130class ICEBERG_EXPORT MetadataTableFactory {
175131 public:
176- // / \brief Create a SnapshotsTable from a table
177- // /
178- // / \param table The source table
179- // / \return A SnapshotsTable exposing all snapshots or error status
180- static Result<std::unique_ptr<SnapshotsTable>> GetSnapshotsTable (
181- std::shared_ptr<Table> table);
182-
183- // / \brief Create a HistoryTable from a table
132+ // / \brief Create a metadata table from a table
184133 // /
185134 // / \param table The source table
186- // / \return A HistoryTable exposing snapshot history or error status
187- static Result<std::unique_ptr<HistoryTable>> GetHistoryTable (
188- std::shared_ptr<Table> table);
135+ // / \param type The metadata table type to create
136+ // / \return A MetadataTable instance or error status
137+ static Result<std::unique_ptr<MetadataTable>> CreateMetadataTable (
138+ std::shared_ptr<Table> table, MetadataTableType type);
189139};
190140
191141} // namespace iceberg
0 commit comments