kamcheungting-db commented on code in PR #1065:
URL: https://github.com/apache/iceberg-cpp/pull/1065#discussion_r4510447087
##########
src/iceberg/data/file_scan_task_reader.cc:
##########
@@ -162,6 +250,45 @@ class FileScanTaskReader::Impl {
new Impl(std::move(options), std::move(field_lookup),
std::move(delete_counter)));
}
+ // Columns that must be added to the read schema so the task's residual
filter
+ // can be evaluated, or nullopt when the residual must not be enforced. An
+ // empty vector means every referenced column is already projected.
+ Result<std::optional<std::vector<SchemaField>>> ResidualReadColumns(
+ const FileScanTask& task) const {
+ if (!apply_residuals_) {
+ return std::nullopt;
+ }
+ const auto& residual = task.residual_filter();
+ if (residual == nullptr || residual->op() == Expression::Operation::kTrue)
{
+ return std::nullopt;
+ }
+
+ // Residuals are unbound and reference the planning scan's schema: bind
them
+ // against the table schema with the scan's case sensitivity.
+ ICEBERG_ASSIGN_OR_RAISE(auto bound,
+ Binder::Bind(*table_schema_, residual,
case_sensitive_));
+ ICEBERG_ASSIGN_OR_RAISE(auto field_id_set,
+ ReferenceVisitor::GetReferencedFieldIds(bound));
Review Comment:
Nice catch:
In latest version, the original field references are collected before
binding can fold predicates away.
I have also added regression coverage for an unprojected required column and
partially folded AND/OR expressions.
--
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]