Skip to content

Commit

Permalink
fix column inclusion and exclusion parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sslivkoff committed Aug 1, 2023
1 parent 66c29b1 commit 1a1fc35
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions crates/freeze/src/types/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,22 @@ fn compute_used_columns(
datatype.dataset().column_types().keys().map(|k| k.to_string()).collect()
}
(_, Some(include), Some(exclude)) => {
let include_set: HashSet<_> = include.iter().collect();
let exclude_set: HashSet<_> = exclude.iter().collect();
let intersection: HashSet<_> = include_set.intersection(&exclude_set).collect();
assert!(intersection.is_empty(), "include and exclude should be non-overlapping");
include.to_vec()
let mut result: Vec<String> = default_columns.iter().map(|s| s.to_string()).collect();
let mut result_set: HashSet<String> = result.iter().cloned().collect();
let exclude_set: HashSet<String> = exclude.iter().cloned().collect();
include.iter()
.filter(|item| !exclude_set.contains(*item) && result_set.insert(item.to_string()))
.for_each(|item| result.push(item.clone()));
result
}
(_, Some(include), None) => {
let mut result: Vec<String> = default_columns.iter().map(|s| s.to_string()).collect();
let mut result_set: HashSet<String> = result.iter().cloned().collect();
include.iter()
.filter(|item| result_set.insert(item.to_string()))
.for_each(|item| result.push(item.clone()));
result
}
(_, Some(include), None) => include.to_vec(),
(_, None, Some(exclude)) => {
let exclude_set: HashSet<_> = exclude.iter().collect();
default_columns
Expand Down

0 comments on commit 1a1fc35

Please sign in to comment.