Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
liurenjie1024 committed Aug 9, 2023
1 parent 79805ad commit cd2e320
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 63 deletions.
5 changes: 0 additions & 5 deletions crates/iceberg/src/spec/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use ::serde::de::{MapAccess, Visitor};
use serde::de::{Error, IntoDeserializer};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::cell::OnceCell;
use std::slice::Iter;
use std::sync::Arc;
use std::{collections::HashMap, fmt, ops::Index};

Expand Down Expand Up @@ -309,10 +308,6 @@ impl StructType {
.get(&field_id)
.copied()
}
/// Returns an iteratorr over the struct fields
pub fn iter(&self) -> Iter<NestedField> {
self.fields.iter()
}

/// Get fields.
pub fn fields(&self) -> &[NestedFieldRef] {
Expand Down
79 changes: 21 additions & 58 deletions crates/iceberg/src/spec/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ impl Literal {
},
Type::Struct(schema) => {
if let JsonValue::Object(mut object) = value {
Ok(Some(Literal::Struct(Struct::from_iter(schema.iter().map(
|field| {
Ok(Some(Literal::Struct(Struct::from_iter(
schema.fields().iter().map(|field| {
(
field.id,
object.remove(&field.id.to_string()).and_then(|value| {
Expand All @@ -423,8 +423,8 @@ impl Literal {
}),
field.name.clone(),
)
},
)))))
}),
))))
} else {
Err(Error::new(
crate::ErrorKind::DataInvalid,
Expand Down Expand Up @@ -796,33 +796,9 @@ mod tests {
(3, None, "address".to_string()),
])),
&Type::Struct(StructType::new(vec![
NestedField {
id: 1,
name: "id".to_string(),
required: true,
field_type: Box::new(Type::Primitive(PrimitiveType::Int)),
doc: None,
initial_default: None,
write_default: None,
},
NestedField {
id: 2,
name: "name".to_string(),
required: false,
field_type: Box::new(Type::Primitive(PrimitiveType::String)),
doc: None,
initial_default: None,
write_default: None,
},
NestedField {
id: 3,
name: "address".to_string(),
required: false,
field_type: Box::new(Type::Primitive(PrimitiveType::String)),
doc: None,
initial_default: None,
write_default: None,
},
NestedField::required(1, "id", Type::Primitive(PrimitiveType::Int)).into(),
NestedField::optional(2, "name", Type::Primitive(PrimitiveType::String)).into(),
NestedField::optional(3, "address", Type::Primitive(PrimitiveType::String)).into(),
])),
);
}
Expand All @@ -840,15 +816,12 @@ mod tests {
None,
]),
&Type::List(ListType {
element_field: NestedField {
id: 0,
name: "".to_string(),
required: true,
field_type: Box::new(Type::Primitive(PrimitiveType::Int)),
doc: None,
initial_default: None,
write_default: None,
},
element_field: NestedField::list_element(
0,
Type::Primitive(PrimitiveType::Int),
true,
)
.into(),
}),
);
}
Expand All @@ -874,24 +847,14 @@ mod tests {
),
])),
&Type::Map(MapType {
key_field: NestedField {
id: 0,
name: "key".to_string(),
required: true,
field_type: Box::new(Type::Primitive(PrimitiveType::String)),
doc: None,
initial_default: None,
write_default: None,
},
value_field: NestedField {
id: 1,
name: "value".to_string(),
required: true,
field_type: Box::new(Type::Primitive(PrimitiveType::Int)),
doc: None,
initial_default: None,
write_default: None,
},
key_field: NestedField::map_key_element(0, Type::Primitive(PrimitiveType::String))
.into(),
value_field: NestedField::map_value_element(
1,
Type::Primitive(PrimitiveType::Int),
true,
)
.into(),
}),
);
}
Expand Down

0 comments on commit cd2e320

Please sign in to comment.