Skip to content

Commit c426aff

Browse files
authored
test: add test case for table scan planning (#492)
1 parent 31d4a4a commit c426aff

File tree

4 files changed

+680
-2
lines changed

4 files changed

+680
-2
lines changed

src/iceberg/table_scan.cc

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

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
@@ -167,7 +167,11 @@ if(ICEBERG_BUILD_BUNDLE)
167167
parquet_schema_test.cc
168168
parquet_test.cc)
169169

170-
add_iceberg_test(scan_test USE_BUNDLE SOURCES file_scan_task_test.cc)
170+
add_iceberg_test(scan_test
171+
USE_BUNDLE
172+
SOURCES
173+
file_scan_task_test.cc
174+
table_scan_test.cc)
171175

172176
add_iceberg_test(table_update_test
173177
USE_BUNDLE

0 commit comments

Comments
 (0)