zhjwpku commented on code in PR #1157:
URL: https://github.com/apache/iceberg-cpp/pull/1157#discussion_r4720623788
##########
src/iceberg/expression/aggregate.cc:
##########
@@ -56,17 +57,46 @@ class SingleValueStructLike : public StructLike {
Literal literal_;
};
-Result<Literal> EvaluateBoundTerm(const BoundTerm& term,
- const std::optional<std::vector<uint8_t>>&
bound) {
- auto ptype = GetPrimitiveType(term);
- if (!bound.has_value()) {
- SingleValueStructLike data(Literal::Null(ptype));
- return term.Evaluate(data);
+// A disengaged optional means the file metrics cannot determine the extremum.
+Result<std::optional<Literal>> EvaluateFileExtremum(const BoundAggregate&
aggregate,
+ const DataFile& file) {
+ const auto& term = *aggregate.term();
+ const auto ref = term.reference();
+ const auto id = ref->field().field_id();
+ const auto& bounds = aggregate.op() == Expression::Operation::kMax ?
file.upper_bounds
+ :
file.lower_bounds;
+ if (auto it = bounds.find(id); it != bounds.end()) {
+ ICEBERG_ASSIGN_OR_RAISE(
+ auto bound, internal::DeserializeBound(it->second,
GetPrimitiveType(*ref)));
+ if (bound) {
+ if (term.kind() == Term::Kind::kReference) {
+ return bound;
+ }
+ SingleValueStructLike data(std::move(*bound));
+ return term.Evaluate(data);
Review Comment:
MIN/MAX now use file bounds only for column references and order-preserving
transforms. I added a regression test using the two timestamps from Appendix B.
--
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]