advancedxy commented on code in PR #995:
URL: https://github.com/apache/iceberg-cpp/pull/995#discussion_r4255992147
##########
src/iceberg/expression/predicate.cc:
##########
@@ -257,30 +259,63 @@ bool StartsWith(const Literal& lhs, const Literal& rhs) {
return false;
}
+/// \brief Returns true if all ancestors of the field with the given ID are
required.
+///
+/// A required field can still produce null values if it is nested in an
optional struct,
+/// list, or map.
+Result<bool> AllAncestorsAreRequired(const Schema& schema, int32_t field_id) {
+ auto id_to_parent = IndexParents(schema);
+ auto parent_it = id_to_parent.find(field_id);
+ while (parent_it != id_to_parent.end()) {
+ ICEBERG_ASSIGN_OR_RAISE(auto parent,
schema.FindFieldById(parent_it->second));
+ if (!parent.has_value()) {
+ return InvalidSchema("Cannot find parent field {} of field {}",
parent_it->second,
Review Comment:
hmm. It's not an invalid schema error? How about invalid argument error?
--
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]