wgtmac commented on code in PR #607: URL: https://github.com/apache/iceberg-cpp/pull/607#discussion_r3027005814
########## src/iceberg/inspect/metadata_table_factory.h: ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +class HistoryTable; Review Comment: Add them to `iceberg/type_fwd.h` and include it here. ########## src/iceberg/inspect/metadata_table_factory.h: ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +class HistoryTable; +class SnapshotsTable; +class Table; + +/// \brief Metadata table factory and inspector +/// +/// MetadataTable provides factory methods to create specific metadata tables for +/// inspecting table metadata. Each metadata table exposes a different aspect of the +/// table's metadata as a scannable Iceberg table. +/// +/// Usage: +/// auto snapshots = ICEBERG_TRY(MetadataTable::GetSnapshotsTable(table)); +/// auto scan = ICEBERG_TRY(snapshots->NewScan()); +/// // ... scan and read snapshot data +class ICEBERG_EXPORT MetadataTableFactory { Review Comment: Let's introduce an enum MetadataTableType as well. Each MetadataTable instance should also add a function to return this type. ########## src/iceberg/inspect/snapshots_table.h: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +/// \brief Snapshots metadata table +/// +/// Exposes all snapshots in the table as rows with columns: +/// - committed_at (timestamp) +/// - snapshot_id (long) +/// - parent_id (long) +/// - manifest_list (string) +/// - summary (map<string, string>) +class ICEBERG_EXPORT SnapshotsTable : public BaseMetadataTable { + public: + /// \brief Create a SnapshotsTable from table metadata + /// + /// \param[in] table The source table + /// \return A SnapshotsTable instance or error status + static Result<std::shared_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); + + ~SnapshotsTable() override; + + private: + SnapshotsTable(std::shared_ptr<Table> table); + + std::shared_ptr<Schema> CreateSchema(); + + TableIdentifier CreateName(const TableIdentifier& source_name); Review Comment: ditto ########## src/iceberg/inspect/snapshots_table.h: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +/// \brief Snapshots metadata table +/// +/// Exposes all snapshots in the table as rows with columns: +/// - committed_at (timestamp) +/// - snapshot_id (long) +/// - parent_id (long) +/// - manifest_list (string) +/// - summary (map<string, string>) +class ICEBERG_EXPORT SnapshotsTable : public BaseMetadataTable { + public: + /// \brief Create a SnapshotsTable from table metadata + /// + /// \param[in] table The source table + /// \return A SnapshotsTable instance or error status + static Result<std::shared_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); + + ~SnapshotsTable() override; + + private: + SnapshotsTable(std::shared_ptr<Table> table); + + std::shared_ptr<Schema> CreateSchema(); Review Comment: This does not have to be a member function. ########## src/iceberg/CMakeLists.txt: ########## @@ -44,6 +42,9 @@ set(ICEBERG_SOURCES expression/term.cc file_reader.cc file_writer.cc + inspect/history_table.cc Review Comment: Add them to meson.build as well. ########## src/iceberg/inspect/metadata_table.h: ########## @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> +#include <string> + +#include "iceberg/iceberg_export.h" +#include "iceberg/location_provider.h" +#include "iceberg/result.h" +#include "iceberg/sort_order.h" +#include "iceberg/table.h" +#include "iceberg/table_metadata.h" +#include "iceberg/table_scan.h" + +namespace iceberg { + +/// Forward declarations +class FileIO; + +/// \brief Base class for Iceberg metadata tables +/// +/// Metadata tables expose table metadata as queryable tables with schemas and scan +/// support. They provide read-only access to metadata. +class ICEBERG_EXPORT BaseMetadataTable : public Table { Review Comment: Let's inherit `StaticTable` to make it read-only. What do you think if we simply name it as `MetadataTable`? BTW, it seems that `StaticTable` misses some overrides of update functions (this can be a separate PR to fix). ########## src/iceberg/inspect/metadata_table_factory.h: ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +class HistoryTable; +class SnapshotsTable; +class Table; + +/// \brief Metadata table factory and inspector +/// +/// MetadataTable provides factory methods to create specific metadata tables for +/// inspecting table metadata. Each metadata table exposes a different aspect of the +/// table's metadata as a scannable Iceberg table. +/// +/// Usage: +/// auto snapshots = ICEBERG_TRY(MetadataTable::GetSnapshotsTable(table)); +/// auto scan = ICEBERG_TRY(snapshots->NewScan()); +/// // ... scan and read snapshot data +class ICEBERG_EXPORT MetadataTableFactory { Review Comment: By convention, we don't add a new file for the factory. Consider moving them to metadata_table.h/cc. ########## src/iceberg/inspect/metadata_table.h: ########## @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> +#include <string> + +#include "iceberg/iceberg_export.h" +#include "iceberg/location_provider.h" +#include "iceberg/result.h" +#include "iceberg/sort_order.h" +#include "iceberg/table.h" +#include "iceberg/table_metadata.h" +#include "iceberg/table_scan.h" + +namespace iceberg { + +/// Forward declarations +class FileIO; + +/// \brief Base class for Iceberg metadata tables +/// +/// Metadata tables expose table metadata as queryable tables with schemas and scan +/// support. They provide read-only access to metadata. +class ICEBERG_EXPORT BaseMetadataTable : public Table { + public: + /// \brief Returns the identifier of this table + const TableIdentifier& name() const { return identifier_; } Review Comment: Functions like these shadow those defined by base class. We may need to make them virtual to support overrides. ########## src/iceberg/CMakeLists.txt: ########## @@ -59,12 +60,12 @@ set(ICEBERG_SOURCES manifest/v2_metadata.cc manifest/v3_metadata.cc metadata_columns.cc + inspect/metadata_table.cc Review Comment: Let's sort them alphabetically. ########## src/iceberg/inspect/snapshots_table.h: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +/// \brief Snapshots metadata table +/// +/// Exposes all snapshots in the table as rows with columns: +/// - committed_at (timestamp) +/// - snapshot_id (long) +/// - parent_id (long) +/// - manifest_list (string) +/// - summary (map<string, string>) +class ICEBERG_EXPORT SnapshotsTable : public BaseMetadataTable { + public: + /// \brief Create a SnapshotsTable from table metadata + /// + /// \param[in] table The source table + /// \return A SnapshotsTable instance or error status + static Result<std::shared_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); Review Comment: ```suggestion static Result<std::unique_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); ``` ########## src/iceberg/inspect/history_table.cc: ########## @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "iceberg/inspect/history_table.h" + +#include <memory> +#include <utility> + +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/schema.h" +#include "iceberg/schema_field.h" +#include "iceberg/table_identifier.h" +#include "iceberg/type.h" + +namespace iceberg { + +HistoryTable::HistoryTable(std::shared_ptr<Table> table) + : BaseMetadataTable(table, CreateName(table->name()), CreateSchema()) {} + +HistoryTable::~HistoryTable() = default; + +std::shared_ptr<Schema> HistoryTable::CreateSchema() { + return std::make_shared<Schema>( + std::vector<SchemaField>{ + SchemaField::MakeRequired(1, "made_current_at", int64()), Review Comment: ```suggestion SchemaField::MakeRequired(1, "made_current_at", timestamptz()), ``` ########## src/iceberg/inspect/metadata_table.cc: ########## @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "iceberg/inspect/metadata_table.h" + +#include <memory> +#include <string> +#include <utility> + +#include "iceberg/file_io.h" +#include "iceberg/schema.h" +#include "iceberg/schema_field.h" +#include "iceberg/table_identifier.h" +#include "iceberg/table_metadata.h" +#include "iceberg/table_scan.h" +#include "iceberg/type.h" +#include "iceberg/util/uuid.h" + +namespace iceberg { + +BaseMetadataTable::BaseMetadataTable(std::shared_ptr<Table> source_table, + TableIdentifier identifier, + std::shared_ptr<Schema> schema) + : Table(identifier, source_table->metadata(), + std::string(source_table->metadata_file_location()), source_table->io(), + source_table->catalog()), + source_table_(std::move(source_table)), + schema_(schema) { + uuid_ = Uuid::GenerateV4().ToString(); + schemas_[schema->schema_id()] = schema; +} + +BaseMetadataTable::~BaseMetadataTable() = default; + +Status BaseMetadataTable::Refresh() { + return NotSupported("Cannot refresh a metadata table"); Review Comment: This can be supported by refreshing the base table. ########## src/iceberg/inspect/metadata_table.h: ########## @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> +#include <string> + +#include "iceberg/iceberg_export.h" +#include "iceberg/location_provider.h" +#include "iceberg/result.h" +#include "iceberg/sort_order.h" +#include "iceberg/table.h" +#include "iceberg/table_metadata.h" +#include "iceberg/table_scan.h" + +namespace iceberg { + +/// Forward declarations +class FileIO; + +/// \brief Base class for Iceberg metadata tables +/// +/// Metadata tables expose table metadata as queryable tables with schemas and scan +/// support. They provide read-only access to metadata. +class ICEBERG_EXPORT BaseMetadataTable : public Table { + public: + /// \brief Returns the identifier of this table + const TableIdentifier& name() const { return identifier_; } + + /// \brief Returns the UUID of the table + const std::string& uuid() const { return uuid_; } + + /// \brief Returns the schema for this table, return NotFoundError if not found + Result<std::shared_ptr<Schema>> schema() const { return schema_; } + + /// \brief Returns a map of schema for this table + Result< + std::reference_wrapper<const std::unordered_map<int32_t, std::shared_ptr<Schema>>>> + schemas() const { + return schemas_; + } + + /// \brief Returns the partition spec for this table, return NotFoundError if not found + Result<std::shared_ptr<PartitionSpec>> spec() const { return partition_spec; }; + + /// \brief Returns a map of partition specs for this table + Result<std::reference_wrapper< + const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>>> + specs() const { + return partition_specs_; + } + + /// \brief Returns the sort order for this table, return NotFoundError if not found + Result<std::shared_ptr<SortOrder>> sort_order() const { return sort_order_; } + + /// \brief Returns a map of sort order IDs to sort orders for this table + Result<std::reference_wrapper< + const std::unordered_map<int32_t, std::shared_ptr<SortOrder>>>> + sort_orders() const { + return sort_orders_; + } + + /// \brief Returns the properties of this table + const TableProperties& properties() const { return properties_; } + + /// \brief Returns the table's metadata file location + std::string_view metadata_file_location() const { + return source_table_->metadata_file_location(); + } + + /// \brief Returns the table's base location + std::string_view location() const { return source_table_->location(); } + + /// \brief Returns the time when this table was last updated + TimePointMs last_updated_ms() const { return source_table_->last_updated_ms(); } + + /// \brief Returns the table's current snapshot, return NotFoundError if not found + Result<std::shared_ptr<Snapshot>> current_snapshot() const { + return source_table_->current_snapshot(); + } + + /// \brief Get the snapshot of this table with the given id + /// + /// \param snapshot_id the ID of the snapshot to get + /// \return the Snapshot with the given id, return NotFoundError if not found + Result<std::shared_ptr<Snapshot>> SnapshotById(int64_t snapshot_id) const { + return source_table_->SnapshotById(snapshot_id); + } + + /// \brief Get the snapshots of this table + const std::vector<std::shared_ptr<Snapshot>>& snapshots() const { + return source_table_->snapshots(); + } + + /// \brief Get the snapshot history of this table + const std::vector<SnapshotLogEntry>& history() const { + return source_table_->history(); + } + + /// \brief Returns the current metadata for this table + const std::shared_ptr<TableMetadata>& metadata() const { + // TODO: or should we return an empty TableMetadata? + return source_table_->metadata(); + } + + /// \brief Returns the catalog that this table belongs to + const std::shared_ptr<Catalog>& catalog() const { return source_table_->catalog(); } + + /// \brief Returns a LocationProvider for this table + Result<std::unique_ptr<LocationProvider>> location_provider() const { + return source_table_->location_provider(); + } + + /// \brief Refreshing is not supported in metadata tables. + Status Refresh() override; + + /// \brief Create a new table scan builder for this table + /// + /// Once a table scan builder is created, it can be refined to project columns and + /// filter data. + Result<std::unique_ptr<TableScanBuilder>> NewScan() const; + + /// \brief Creating transactions is not supported in metadata tables. + Result<std::shared_ptr<Transaction>> NewTransaction() override; Review Comment: Same as above comment. Let's remove these functions by inheriting `StaticTable`. ########## src/iceberg/inspect/snapshots_table.h: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +/// \brief Snapshots metadata table +/// +/// Exposes all snapshots in the table as rows with columns: +/// - committed_at (timestamp) +/// - snapshot_id (long) +/// - parent_id (long) +/// - manifest_list (string) +/// - summary (map<string, string>) +class ICEBERG_EXPORT SnapshotsTable : public BaseMetadataTable { + public: + /// \brief Create a SnapshotsTable from table metadata + /// + /// \param[in] table The source table + /// \return A SnapshotsTable instance or error status + static Result<std::shared_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); Review Comment: It is better to return unique_ptr unless unrealistic. ########## src/iceberg/inspect/snapshots_table.h: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include "iceberg/iceberg_export.h" +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/result.h" +#include "iceberg/table.h" + +namespace iceberg { + +/// \brief Snapshots metadata table +/// +/// Exposes all snapshots in the table as rows with columns: +/// - committed_at (timestamp) +/// - snapshot_id (long) +/// - parent_id (long) +/// - manifest_list (string) +/// - summary (map<string, string>) +class ICEBERG_EXPORT SnapshotsTable : public BaseMetadataTable { + public: + /// \brief Create a SnapshotsTable from table metadata + /// + /// \param[in] table The source table + /// \return A SnapshotsTable instance or error status + static Result<std::shared_ptr<SnapshotsTable>> Make(std::shared_ptr<Table> table); + + ~SnapshotsTable() override; + + private: + SnapshotsTable(std::shared_ptr<Table> table); Review Comment: ```suggestion explicit SnapshotsTable(std::shared_ptr<Table> table); ``` ########## src/iceberg/inspect/snapshots_table.cc: ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "iceberg/inspect/snapshots_table.h" + +#include <memory> +#include <utility> + +#include "iceberg/inspect/metadata_table.h" +#include "iceberg/schema.h" +#include "iceberg/schema_field.h" +#include "iceberg/table_identifier.h" +#include "iceberg/type.h" + +namespace iceberg { + +SnapshotsTable::SnapshotsTable(std::shared_ptr<Table> table) + : BaseMetadataTable(table, CreateName(table->name()), CreateSchema()) {} + +SnapshotsTable::~SnapshotsTable() = default; + +std::shared_ptr<Schema> SnapshotsTable::CreateSchema() { + return std::make_shared<Schema>( + std::vector<SchemaField>{SchemaField::MakeRequired(1, "committed_at", int64()), + SchemaField::MakeOptional(2, "snapshot_id", int64()), Review Comment: Let's make sure the schema definition is consistent with the Java implementation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
