Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
desmondcheongzx committed Oct 15, 2024
1 parent c670812 commit f3ba7b1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/daft-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ impl Schema {
let self_keys: HashSet<&String> = HashSet::from_iter(self.fields.keys());
let other_keys: HashSet<&String> = HashSet::from_iter(other.fields.keys());
if self_keys.is_disjoint(&other_keys) {
let mut fields = IndexMap::new();
for (k, v) in self.fields.iter().chain(other.fields.iter()) {
fields.insert(k.clone(), v.clone());
}
let fields = self
.fields
.iter()
.chain(other.fields.iter())
.map(|(k, v)| (k.clone(), v.clone())) // Convert references to owned values
.collect();
Ok(Self { fields })
} else {
Err(DaftError::ValueError(
Expand All @@ -121,10 +123,12 @@ impl Schema {
/// Takes the non-distinct union of two schemas. If there are overlapping keys, then we take the
/// corresponding field from one of the two schemas.
pub fn non_distinct_union(&self, other: &Self) -> Self {
let mut fields = IndexMap::new();
for (k, v) in self.fields.iter().chain(other.fields.iter()) {
fields.insert(k.clone(), v.clone());
}
let fields = self
.fields
.iter()
.chain(other.fields.iter())
.map(|(k, v)| (k.clone(), v.clone())) // Convert references to owned values
.collect();
Self { fields }
}

Expand Down

0 comments on commit f3ba7b1

Please sign in to comment.