Skip to content

Commit bc924f4

Browse files
committed
test: add test case for table scan
1 parent e5eb6e0 commit bc924f4

File tree

4 files changed

+1192
-2
lines changed

4 files changed

+1192
-2
lines changed

src/iceberg/table_scan.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ const std::shared_ptr<TableMetadata>& TableScan::metadata() const { return metad
384384
Result<std::shared_ptr<Snapshot>> TableScan::snapshot() const {
385385
auto snapshot_id = context_.snapshot_id ? context_.snapshot_id.value()
386386
: metadata_->current_snapshot_id;
387+
if (snapshot_id == kInvalidSnapshotId) {
388+
return std::shared_ptr<Snapshot>{nullptr};
389+
}
387390
return metadata_->SnapshotById(snapshot_id);
388391
}
389392

src/iceberg/table_scan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class ICEBERG_EXPORT TableScan {
275275
/// \brief Returns the table metadata being scanned.
276276
const std::shared_ptr<TableMetadata>& metadata() const;
277277

278-
/// \brief Returns the snapshot to scan.
278+
/// \brief Returns the snapshot to scan. If there is no snapshot, returns nullptr.
279279
Result<std::shared_ptr<Snapshot>> snapshot() const;
280280

281281
/// \brief Returns the projected schema for the scan.

src/iceberg/test/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ if(ICEBERG_BUILD_BUNDLE)
162162
parquet_schema_test.cc
163163
parquet_test.cc)
164164

165-
add_iceberg_test(scan_test USE_BUNDLE SOURCES file_scan_task_test.cc)
165+
add_iceberg_test(scan_test
166+
USE_BUNDLE
167+
SOURCES
168+
file_scan_task_test.cc
169+
table_scan_test.cc)
166170

167171
add_iceberg_test(table_update_test
168172
USE_BUNDLE

0 commit comments

Comments
 (0)