2929#include " iceberg/table.h"
3030#include " iceberg/table_metadata.h"
3131#include " iceberg/table_scan.h"
32+ #include " iceberg/type_fwd.h"
3233
3334namespace iceberg {
3435
35- // / Forward declarations
36- class FileIO ;
36+ // / \brief The type of metadata table
37+ enum class MetadataTableType {
38+ kSnapshots ,
39+ kHistory ,
40+ };
3741
3842// / \brief Base class for Iceberg metadata tables
3943// /
4044// / Metadata tables expose table metadata as queryable tables with schemas and scan
4145// / support. They provide read-only access to metadata.
42- class ICEBERG_EXPORT BaseMetadataTable : public Table {
46+ class ICEBERG_EXPORT MetadataTable : public StaticTable {
4347 public:
4448 // / \brief Returns the identifier of this table
45- const TableIdentifier& name () const { return identifier_; }
49+ const TableIdentifier& name () const override { return identifier_; }
50+
51+ virtual MetadataTableType type () const noexcept = 0;
4652
4753 // / \brief Returns the UUID of the table
4854 const std::string& uuid () const { return uuid_; }
@@ -137,32 +143,10 @@ class ICEBERG_EXPORT BaseMetadataTable : public Table {
137143 // / filter data.
138144 Result<std::unique_ptr<TableScanBuilder>> NewScan () const ;
139145
140- // / \brief Creating transactions is not supported in metadata tables.
141- Result<std::shared_ptr<Transaction>> NewTransaction () override ;
142-
143- // / \brief Updating partition specs is not supported in metadata tables.
144- Result<std::shared_ptr<UpdatePartitionSpec>> NewUpdatePartitionSpec () override ;
145-
146- // / \brief Updating table properties is not supported in metadata tables.
147- Result<std::shared_ptr<UpdateProperties>> NewUpdateProperties () override ;
148-
149- // / \brief Updating sort orders is not supported in metadata tables.
150- Result<std::shared_ptr<UpdateSortOrder>> NewUpdateSortOrder () override ;
151-
152- // / \brief Updating schemas is not supported in metadata tables.
153- Result<std::shared_ptr<UpdateSchema>> NewUpdateSchema () override ;
154-
155- // / \brief Expiring snapshots is not supported in metadata tables.
156- Result<std::shared_ptr<ExpireSnapshots>> NewExpireSnapshots () override ;
157-
158- // / \brief Updating table location is not supported in metadata tables.
159- Result<std::shared_ptr<UpdateLocation>> NewUpdateLocation () override ;
160-
161146 protected:
162- BaseMetadataTable (std::shared_ptr<Table> source_table, TableIdentifier identifier,
163- std::shared_ptr<Schema> schema);
147+ explicit MetadataTable (std::shared_ptr<Table> source_table, TableIdentifier identifier);
164148
165- virtual ~BaseMetadataTable ();
149+ ~MetadataTable ();
166150
167151 std::shared_ptr<Table> source_table_;
168152 std::string uuid_;
@@ -177,4 +161,31 @@ class ICEBERG_EXPORT BaseMetadataTable : public Table {
177161 {partition_spec->spec_id (), partition_spec}};
178162};
179163
164+ // / \brief Metadata table factory and inspector
165+ // /
166+ // / MetadataTable provides factory methods to create specific metadata tables for
167+ // / inspecting table metadata. Each metadata table exposes a different aspect of the
168+ // / table's metadata as a scannable Iceberg table.
169+ // /
170+ // / Usage:
171+ // / auto snapshots = ICEBERG_TRY(MetadataTable::GetSnapshotsTable(table));
172+ // / auto scan = ICEBERG_TRY(snapshots->NewScan());
173+ // / // ... scan and read snapshot data
174+ class ICEBERG_EXPORT MetadataTableFactory {
175+ 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::shared_ptr<SnapshotsTable>> GetSnapshotsTable (
181+ std::shared_ptr<Table> table);
182+
183+ // / \brief Create a HistoryTable from a table
184+ // /
185+ // / \param table The source table
186+ // / \return A HistoryTable exposing snapshot history or error status
187+ static Result<std::shared_ptr<HistoryTable>> GetHistoryTable (
188+ std::shared_ptr<Table> table);
189+ };
190+
180191} // namespace iceberg
0 commit comments