ozankabak commented on code in PR #14111:
URL: https://github.com/apache/datafusion/pull/14111#discussion_r1918023625
##########
datafusion/common/src/functional_dependencies.rs:
##########
@@ -60,6 +60,41 @@ impl Constraints {
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
+
+ /// Projects constraints using the given projection indices.
+ /// Returns None if any of the constraint columns are not included in the
projection.
+ pub fn project(&self, proj_indices: &[usize]) -> Option<Self> {
+ let projected = self
+ .inner
+ .iter()
+ .filter_map(|constraint| {
+ match constraint {
+ Constraint::PrimaryKey(indices) => {
+ let new_indices =
+ update_elements_with_matching_indices(indices,
proj_indices);
Review Comment:
What I had in mind was to swap the loop order (iterate on `proj_indices` on
the outer loop). That may enable us to use an `impl Iterator` for
`proj_indices`. We probably will need to keep the type of `entries` as a slice
because it does not have an ordering (though we can enforce that in a future
PR). Had `entries` was ordered, I think we could have also taken it in as an
`impl Iterator` -- but let's leave the latter for a future PR
--
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]