Skip to content

Commit 5b7f140

Browse files
committed
address feedback
1 parent 7e5f060 commit 5b7f140

2 files changed

Lines changed: 21 additions & 59 deletions

File tree

src/iceberg/table_scan.cc

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,15 @@ Result<ArrowArrayStream> MakeArrowArrayStream(std::unique_ptr<Reader> reader) {
156156
namespace internal {
157157

158158
Status TableScanContext::Validate() const {
159-
if (!columns_to_keep_stats.empty() && !return_column_stats) {
160-
return InvalidArgument(
161-
"Cannot select columns to keep stats when column stats are not returned");
162-
}
163-
if (projected_schema != nullptr && !selected_columns.empty()) {
164-
return InvalidArgument(
165-
"Cannot set projection schema and selected columns at the same time");
166-
}
167-
if (snapshot_id.has_value() &&
168-
(from_snapshot_id.has_value() || to_snapshot_id.has_value())) {
169-
return InvalidArgument("Cannot mix snapshot scan and incremental scan");
170-
}
171-
if (min_rows_requested.has_value() && min_rows_requested.value() < 0) {
172-
return InvalidArgument("Min rows requested cannot be negative");
173-
}
159+
ICEBERG_CHECK(columns_to_keep_stats.empty() || return_column_stats,
160+
"Cannot select columns to keep stats when column stats are not returned");
161+
ICEBERG_CHECK(projected_schema == nullptr || selected_columns.empty(),
162+
"Cannot set projection schema and selected columns at the same time");
163+
ICEBERG_CHECK(!snapshot_id.has_value() ||
164+
(!from_snapshot_id.has_value() && !to_snapshot_id.has_value()),
165+
"Cannot mix snapshot scan and incremental scan");
166+
ICEBERG_CHECK(!min_rows_requested.has_value() || min_rows_requested.value() >= 0,
167+
"Min rows requested cannot be negative");
174168
return {};
175169
}
176170

@@ -320,23 +314,13 @@ TableScanBuilder& TableScanBuilder::AsOfTime(int64_t timestamp_millis) {
320314
return UseSnapshot(snapshot_id);
321315
}
322316

323-
TableScanBuilder& TableScanBuilder::FromSnapshotInclusive(
324-
[[maybe_unused]] int64_t from_snapshot_id) {
325-
return AddError(NotImplemented("Incremental scan is not implemented"));
326-
}
327-
328-
TableScanBuilder& TableScanBuilder::FromSnapshotInclusive(
329-
[[maybe_unused]] const std::string& ref) {
330-
return AddError(NotImplemented("Incremental scan is not implemented"));
331-
}
332-
333-
TableScanBuilder& TableScanBuilder::FromSnapshotExclusive(
334-
[[maybe_unused]] int64_t from_snapshot_id) {
317+
TableScanBuilder& TableScanBuilder::FromSnapshot(
318+
[[maybe_unused]] int64_t from_snapshot_id, [[maybe_unused]] bool inclusive) {
335319
return AddError(NotImplemented("Incremental scan is not implemented"));
336320
}
337321

338-
TableScanBuilder& TableScanBuilder::FromSnapshotExclusive(
339-
[[maybe_unused]] const std::string& ref) {
322+
TableScanBuilder& TableScanBuilder::FromSnapshot([[maybe_unused]] const std::string& ref,
323+
[[maybe_unused]] bool inclusive) {
340324
return AddError(NotImplemented("Incremental scan is not implemented"));
341325
}
342326

src/iceberg/table_scan.h

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -204,49 +204,27 @@ class ICEBERG_EXPORT TableScanBuilder : public ErrorCollector {
204204
/// travel is attempted on a tag
205205
TableScanBuilder& AsOfTime(int64_t timestamp_millis);
206206

207-
/// \brief Instructs this scan to look for changes starting from a particular snapshot
208-
/// (inclusive).
209-
///
210-
/// If the start snapshot is not configured, it defaults to the oldest ancestor of the
211-
/// end snapshot (inclusive).
212-
///
213-
/// \param from_snapshot_id the start snapshot ID (inclusive)
214-
/// \note InvalidArgument will be returned if the start snapshot is not an ancestor of
215-
/// the end snapshot
216-
TableScanBuilder& FromSnapshotInclusive(int64_t from_snapshot_id);
217-
218-
/// \brief Instructs this scan to look for changes starting from a particular snapshot
219-
/// (inclusive).
220-
///
221-
/// If the start snapshot is not configured, it defaults to the oldest ancestor of the
222-
/// end snapshot (inclusive).
223-
///
224-
/// \param ref the start ref name that points to a particular snapshot ID (inclusive)
225-
/// \note InvalidArgument will be returned if the start snapshot is not an ancestor of
226-
/// the end snapshot
227-
TableScanBuilder& FromSnapshotInclusive(const std::string& ref);
228-
229-
/// \brief Instructs this scan to look for changes starting from a particular snapshot
230-
/// (exclusive).
207+
/// \brief Instructs this scan to look for changes starting from a particular snapshot.
231208
///
232209
/// If the start snapshot is not configured, it defaults to the oldest ancestor of the
233210
/// end snapshot (inclusive).
234211
///
235-
/// \param from_snapshot_id the start snapshot ID (exclusive)
212+
/// \param from_snapshot_id the start snapshot ID
213+
/// \param inclusive whether the start snapshot is inclusive, default is false
236214
/// \note InvalidArgument will be returned if the start snapshot is not an ancestor of
237215
/// the end snapshot
238-
TableScanBuilder& FromSnapshotExclusive(int64_t from_snapshot_id);
216+
TableScanBuilder& FromSnapshot(int64_t from_snapshot_id, bool inclusive = false);
239217

240-
/// \brief Instructs this scan to look for changes starting from a particular snapshot
241-
/// (exclusive).
218+
/// \brief Instructs this scan to look for changes starting from a particular snapshot.
242219
///
243220
/// If the start snapshot is not configured, it defaults to the oldest ancestor of the
244221
/// end snapshot (inclusive).
245222
///
246-
/// \param ref the start ref name that points to a particular snapshot ID (exclusive)
223+
/// \param ref the start ref name that points to a particular snapshot ID
224+
/// \param inclusive whether the start snapshot is inclusive, default is false
247225
/// \note InvalidArgument will be returned if the start snapshot is not an ancestor of
248226
/// the end snapshot
249-
TableScanBuilder& FromSnapshotExclusive(const std::string& ref);
227+
TableScanBuilder& FromSnapshot(const std::string& ref, bool inclusive = false);
250228

251229
/// \brief Instructs this scan to look for changes up to a particular snapshot
252230
/// (inclusive).

0 commit comments

Comments
 (0)