WZhuo commented on code in PR #801:
URL: https://github.com/apache/iceberg-cpp/pull/801#discussion_r3689086691


##########
src/iceberg/test/snapshots_table_test.cc:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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 <memory>
+#include <utility>
+
+#include <arrow/array.h>
+#include <arrow/c/bridge.h>
+#include <arrow/record_batch.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "iceberg/inspect/metadata_table.h"
+#include "iceberg/schema.h"
+#include "iceberg/schema_field.h"
+#include "iceberg/test/matchers.h"
+#include "iceberg/test/metadata_table_test_base.h"
+#include "iceberg/type.h"
+
+namespace iceberg {
+namespace {
+
+std::shared_ptr<Schema> MakeSnapshotsSchema() {
+  return std::make_shared<Schema>(std::vector<SchemaField>{
+      SchemaField::MakeRequired(1, "committed_at", timestamp_tz()),
+      SchemaField::MakeRequired(2, "snapshot_id", int64()),
+      SchemaField::MakeOptional(3, "parent_id", int64()),
+      SchemaField::MakeOptional(4, "operation", string()),
+      SchemaField::MakeOptional(5, "manifest_list", string()),
+      SchemaField::MakeOptional(
+          6, "summary",
+          std::make_shared<MapType>(SchemaField::MakeRequired(7, "key", 
string()),
+                                    SchemaField::MakeRequired(8, "value", 
string())))});
+}
+
+}  // namespace
+
+class SnapshotsTableTest : public MetadataTableTestBase {
+ protected:
+  void SetUp() override {
+    MetadataTableTestBase::SetUp();
+
+    auto [snap1, snap2] = MakeTestSnapshots();
+    snap1_ = snap1;
+    snap2_ = snap2;
+
+    ICEBERG_UNWRAP_OR_FAIL(
+        table_, MakeTableWithSnapshots({snap1, snap2}, 
/*current_snapshot_id=*/2));
+
+    ICEBERG_UNWRAP_OR_FAIL(snapshots_table_,
+                           MetadataTable::Make(table_, 
MetadataTable::Kind::kSnapshots));
+  }
+
+  std::shared_ptr<Table> table_;
+  std::shared_ptr<Snapshot> snap1_;
+  std::shared_ptr<Snapshot> snap2_;
+  std::unique_ptr<MetadataTable> snapshots_table_;

Review Comment:
   Fixed. The unused snapshot members and the shadowing fixture table were 
removed; the test now uses `MetadataTableTestBase::table_`.



##########
src/iceberg/inspect/metadata_table.cc:
##########
@@ -35,6 +35,23 @@ MetadataTable::MetadataTable(std::shared_ptr<Table> 
source_table,
 
 MetadataTable::~MetadataTable() = default;
 
+bool MetadataTable::supports_time_travel() const noexcept {
+  // Time travel is supported for tables that read from a single snapshot's
+  // manifests. Tables that scan all snapshots or return in-memory history do
+  // not.
+  switch (kind()) {
+    case Kind::kSnapshots:
+    case Kind::kHistory:
+      return false;
+  }
+  return false;
+}

Review Comment:
   Fixed. `MetadataTable::supports_time_travel()` returns false, while 
`TimeTravelMetadataTable` overrides it to return true. The comments now match 
this capability split.



-- 
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]

Reply via email to