You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "WZhuo (via GitHub)" <gi...@apache.org> on 2026/03/12 10:34:37 UTC
[PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
WZhuo opened a new pull request, #590:
URL: https://github.com/apache/iceberg-cpp/pull/590
(no comment)
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2986684167
##########
src/iceberg/manifest/manifest_list.h:
##########
@@ -272,3 +272,12 @@ ICEBERG_EXPORT inline constexpr Result<ManifestContent> ManifestContentFromStrin
}
} // namespace iceberg
+
+namespace std {
+template <>
+struct hash<iceberg::ManifestFile> {
Review Comment:
**Style / Logic Issue:** The added `std::hash<iceberg::ManifestFile>` specialization only hashes `manifest_path`. However, `ManifestFile::operator==` defaults to member-wise equality. If an `unordered_set` (like the one used in `IncrementalAppendScan::PlanFiles`) encounters two `ManifestFile` objects with the same path but slightly different metadata fields, they will have the same hash but fail equality, resulting in duplicates being inserted. In Java, `GenericManifestFile` uses *only* `manifestPath` for both `hashCode()` and `equals()`.
*Suggested fix:* Modify `ManifestFile::operator==` to only compare `manifest_path` to align with Java, or provide a custom equality functor specifically for the `unordered_set<ManifestFile>`.
##########
src/iceberg/table_scan.cc:
##########
@@ -536,20 +639,110 @@ Result<std::vector<std::shared_ptr<FileScanTask>>> DataTableScan::PlanFiles() co
return manifest_group->PlanFiles();
}
+// Friend function template for IncrementalScan that implements the shared PlanFiles
+// logic. It resolves the from/to snapshot range from the scan context and delegates
+// to the two-arg virtual PlanFiles() override in the concrete subclass.
+// Defined as a friend to access the protected two-arg PlanFiles().
+template <typename ScanTaskType>
+Result<std::vector<std::shared_ptr<ScanTaskType>>> ResolvePlanFiles(
Review Comment:
**Logic / Parity Issue:** `scan.metadata()->Snapshot()` returns a `NotFound` error if the table has no current snapshot (e.g., table is empty), rather than a successful result with `nullptr`. `ICEBERG_ASSIGN_OR_RAISE` will immediately propagate this `NotFound` error, making the `if (current_snapshot == nullptr)` check unreachable. This breaks parity with Java, which handles empty tables gracefully by returning an empty iterable.
*Suggested fix:* Check the ID directly: `if (scan.metadata()->current_snapshot_id == kInvalidSnapshotId) { return ...; }` or use `scan.snapshot()` which properly resolves to `nullptr`.
*(Note: The same issue exists on line 214 in `ToSnapshotIdInclusive`, where `ICEBERG_ASSIGN_OR_RAISE` will propagate `NotFound` before the custom error message can be triggered).*
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2963616893
##########
src/iceberg/table_scan.h:
##########
@@ -29,6 +29,7 @@
#include "iceberg/arrow_c_data.h"
#include "iceberg/result.h"
+#include "iceberg/table_metadata.h"
Review Comment:
Can we remove this? Is forward declaration enough?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#issuecomment-4127317972
Mostly look good. I will merge this after two remaining issues have been addressed.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "WZhuo (via GitHub)" <gi...@apache.org>.
WZhuo commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2964465478
##########
src/iceberg/table_scan.h:
##########
@@ -373,6 +383,26 @@ class ICEBERG_EXPORT IncrementalScan : public TableScan {
using TableScan::TableScan;
};
+// Template method implementation (must be in header for MSVC)
+template <typename ScanTaskType>
+Result<std::vector<std::shared_ptr<ScanTaskType>>>
+IncrementalScan<ScanTaskType>::PlanFiles() const {
+ if (context_.IsScanCurrentLineage()) {
+ ICEBERG_ASSIGN_OR_RAISE(auto current_snapshot, metadata_->Snapshot());
Review Comment:
If `current_snapshot` is nullptr, it indicates that the current table is empty, so we can simply return an empty task list. No need care about the `branch`.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2963633083
##########
src/iceberg/table_scan.cc:
##########
@@ -539,17 +641,75 @@ Result<std::vector<std::shared_ptr<FileScanTask>>> DataTableScan::PlanFiles() co
// IncrementalAppendScan implementation
Result<std::unique_ptr<IncrementalAppendScan>> IncrementalAppendScan::Make(
- [[maybe_unused]] std::shared_ptr<TableMetadata> metadata,
- [[maybe_unused]] std::shared_ptr<Schema> schema,
- [[maybe_unused]] std::shared_ptr<FileIO> io,
- [[maybe_unused]] internal::TableScanContext context) {
- return NotImplemented("IncrementalAppendScan is not implemented");
+ std::shared_ptr<TableMetadata> metadata, std::shared_ptr<Schema> schema,
+ std::shared_ptr<FileIO> io, internal::TableScanContext context) {
+ ICEBERG_PRECHECK(metadata != nullptr, "Table metadata cannot be null");
+ ICEBERG_PRECHECK(schema != nullptr, "Schema cannot be null");
+ ICEBERG_PRECHECK(io != nullptr, "FileIO cannot be null");
+ return std::unique_ptr<IncrementalAppendScan>(new IncrementalAppendScan(
+ std::move(metadata), std::move(schema), std::move(io), std::move(context)));
}
Result<std::vector<std::shared_ptr<FileScanTask>>> IncrementalAppendScan::PlanFiles(
std::optional<int64_t> from_snapshot_id_exclusive,
int64_t to_snapshot_id_inclusive) const {
- return NotImplemented("IncrementalAppendScan::PlanFiles is not implemented");
+ ICEBERG_ASSIGN_OR_RAISE(
+ auto ancestors_snapshots,
+ SnapshotUtil::AncestorsBetween(*metadata_, to_snapshot_id_inclusive,
+ from_snapshot_id_exclusive));
+
+ std::vector<std::shared_ptr<Snapshot>> append_snapshots;
+ std::ranges::copy_if(ancestors_snapshots, std::back_inserter(append_snapshots),
+ [](const auto& snapshot) {
+ return snapshot != nullptr &&
+ snapshot->Operation().has_value() &&
+ snapshot->Operation().value() == DataOperation::kAppend;
+ });
+ if (append_snapshots.empty()) {
+ return std::vector<std::shared_ptr<FileScanTask>>{};
+ }
+
+ std::unordered_set<int64_t> snapshot_ids;
+ std::ranges::transform(append_snapshots,
+ std::inserter(snapshot_ids, snapshot_ids.end()),
+ [](const auto& snapshot) { return snapshot->snapshot_id; });
+
+ std::vector<ManifestFile> data_manifests;
+ for (const auto& snapshot : append_snapshots) {
+ SnapshotCache snapshot_cache(snapshot.get());
+ ICEBERG_ASSIGN_OR_RAISE(auto manifests, snapshot_cache.DataManifests(io_));
+ std::ranges::copy_if(manifests, std::back_inserter(data_manifests),
Review Comment:
In Java's `BaseIncrementalAppendScan.java`, manifests from append snapshots are collected into a `Set<ManifestFile>` to prevent duplicate processing if multiple snapshots reference the same manifest. The C++ implementation pushes directly into `std::vector<ManifestFile> data_manifests`, which will cause duplicate processing if a manifest is retained across multiple append snapshots since `ManifestGroup::Make` does not deduplicate them internally.
**Suggestion:** Deduplicate `data_manifests` (e.g., by tracking seen `manifest_path`s using a `std::unordered_set<std::string>`) before passing them to `ManifestGroup::Make`.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "WZhuo (via GitHub)" <gi...@apache.org>.
WZhuo commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2964404072
##########
src/iceberg/table_scan.h:
##########
@@ -29,6 +29,7 @@
#include "iceberg/arrow_c_data.h"
#include "iceberg/result.h"
+#include "iceberg/table_metadata.h"
Review Comment:
`IncrementalScan<ScanTaskType>::PlanFiles()` method must implement in header file, it compiles error in msvc env if implement it in source file. Of course, It's better not include it, will see how to fix it.
##########
src/iceberg/table_scan.h:
##########
@@ -132,6 +133,17 @@ struct TableScanContext {
// Validate the context parameters to see if they have conflicts.
[[nodiscard]] Status Validate() const;
+
+ /// \brief Returns true if this scan is a current lineage scan, which means it does not
+ /// specify from/to snapshot IDs.
+ bool IsScanCurrentLineage() const;
Review Comment:
I made these functions members because I don't want to keep writing context.xxx inside the method bodies
##########
src/iceberg/table_scan.h:
##########
@@ -373,6 +383,26 @@ class ICEBERG_EXPORT IncrementalScan : public TableScan {
using TableScan::TableScan;
};
+// Template method implementation (must be in header for MSVC)
+template <typename ScanTaskType>
+Result<std::vector<std::shared_ptr<ScanTaskType>>>
+IncrementalScan<ScanTaskType>::PlanFiles() const {
+ if (context_.IsScanCurrentLineage()) {
+ ICEBERG_ASSIGN_OR_RAISE(auto current_snapshot, metadata_->Snapshot());
Review Comment:
If `current_snapshot` is nullptr, it indicates that the current table is empty, so we can simply return an empty task list. Don't need to worry about the `branch`.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590#discussion_r2964139049
##########
src/iceberg/table_scan.h:
##########
@@ -132,6 +133,17 @@ struct TableScanContext {
// Validate the context parameters to see if they have conflicts.
[[nodiscard]] Status Validate() const;
+
+ /// \brief Returns true if this scan is a current lineage scan, which means it does not
+ /// specify from/to snapshot IDs.
+ bool IsScanCurrentLineage() const;
Review Comment:
Can we just move these three new functions to the anonymous namespace in the table_scan.cc?
##########
src/iceberg/table_scan.h:
##########
@@ -373,6 +383,26 @@ class ICEBERG_EXPORT IncrementalScan : public TableScan {
using TableScan::TableScan;
};
+// Template method implementation (must be in header for MSVC)
+template <typename ScanTaskType>
+Result<std::vector<std::shared_ptr<ScanTaskType>>>
+IncrementalScan<ScanTaskType>::PlanFiles() const {
+ if (context_.IsScanCurrentLineage()) {
+ ICEBERG_ASSIGN_OR_RAISE(auto current_snapshot, metadata_->Snapshot());
Review Comment:
Do we need to consider if branch has been specified?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: Impl IncrementalAppendScan [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac merged PR #590:
URL: https://github.com/apache/iceberg-cpp/pull/590
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org