wgtmac commented on code in PR #758:
URL: https://github.com/apache/iceberg-cpp/pull/758#discussion_r3486381973
##########
src/iceberg/table_scan.cc:
##########
@@ -239,24 +239,17 @@ TableScanBuilder<ScanType>&
TableScanBuilder<ScanType>::CaseSensitive(
template <typename ScanType>
TableScanBuilder<ScanType>& TableScanBuilder<ScanType>::IncludeColumnStats() {
context_.return_column_stats = true;
+ context_.columns_to_keep_stats.clear();
+ requested_column_stats_.reset();
return *this;
}
template <typename ScanType>
TableScanBuilder<ScanType>& TableScanBuilder<ScanType>::IncludeColumnStats(
const std::vector<std::string>& requested_columns) {
context_.return_column_stats = true;
- context_.columns_to_keep_stats.clear();
- context_.columns_to_keep_stats.reserve(requested_columns.size());
-
- ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto schema_ref, ResolveSnapshotSchema());
- const auto& schema = schema_ref.get();
- for (const auto& column_name : requested_columns) {
- ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto field,
schema->FindFieldByName(column_name));
- if (field.has_value()) {
- context_.columns_to_keep_stats.insert(field.value().get().field_id());
- }
- }
+ requested_column_stats_ = requested_columns;
+ ICEBERG_BUILDER_RETURN_IF_ERROR(ResolveColumnStatsSelection());
Review Comment:
Could we avoid eager schema resolution here? If
`IncludeColumnStats(requested_columns)` only stores the requested names, and
`Build()` resolves them against the final snapshot schema, then we don't need
to remember to call `InvalidateSnapshotSchema()` in every snapshot/ref setter.
That seems simpler and less error-prone.
--
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]