Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-thiel committed Aug 30, 2024
1 parent 32bc103 commit c88a6ef
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
74 changes: 37 additions & 37 deletions crates/catalog/glue/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,82 +229,82 @@ mod tests {
fn test_schema_with_simple_fields() -> Result<()> {
let record = r#"{
"type": "struct",
"schema-id": 1,
"schema-id": 0,
"fields": [
{
"id": 1,
"id": 0,
"name": "c1",
"required": true,
"type": "boolean"
},
{
"id": 2,
"id": 1,
"name": "c2",
"required": true,
"type": "int"
},
{
"id": 3,
"id": 2,
"name": "c3",
"required": true,
"type": "long"
},
{
"id": 4,
"id": 3,
"name": "c4",
"required": true,
"type": "float"
},
{
"id": 5,
"id": 4,
"name": "c5",
"required": true,
"type": "double"
},
{
"id": 6,
"id": 5,
"name": "c6",
"required": true,
"type": "decimal(2,2)"
},
{
"id": 7,
"id": 6,
"name": "c7",
"required": true,
"type": "date"
},
{
"id": 8,
"id": 7,
"name": "c8",
"required": true,
"type": "time"
},
{
"id": 9,
"id": 8,
"name": "c9",
"required": true,
"type": "timestamp"
},
{
"id": 10,
"id": 9,
"name": "c10",
"required": true,
"type": "string"
},
{
"id": 11,
"id": 10,
"name": "c11",
"required": true,
"type": "uuid"
},
{
"id": 12,
"id": 11,
"name": "c12",
"required": true,
"type": "fixed[4]"
},
{
"id": 13,
"id": 12,
"name": "c13",
"required": true,
"type": "binary"
Expand All @@ -318,19 +318,19 @@ mod tests {
let result = GlueSchemaBuilder::from_iceberg(&metadata)?.build();

let expected = vec![
create_column("c1", "boolean", "1")?,
create_column("c2", "int", "2")?,
create_column("c3", "bigint", "3")?,
create_column("c4", "float", "4")?,
create_column("c5", "double", "5")?,
create_column("c6", "decimal(2,2)", "6")?,
create_column("c7", "date", "7")?,
create_column("c8", "string", "8")?,
create_column("c9", "timestamp", "9")?,
create_column("c10", "string", "10")?,
create_column("c11", "string", "11")?,
create_column("c12", "binary", "12")?,
create_column("c13", "binary", "13")?,
create_column("c1", "boolean", "0")?,
create_column("c2", "int", "1")?,
create_column("c3", "bigint", "2")?,
create_column("c4", "float", "3")?,
create_column("c5", "double", "4")?,
create_column("c6", "decimal(2,2)", "5")?,
create_column("c7", "date", "6")?,
create_column("c8", "string", "7")?,
create_column("c9", "timestamp", "8")?,
create_column("c10", "string", "9")?,
create_column("c11", "string", "10")?,
create_column("c12", "binary", "11")?,
create_column("c13", "binary", "12")?,
];

assert_eq!(result, expected);
Expand All @@ -345,7 +345,7 @@ mod tests {
"schema-id": 1,
"fields": [
{
"id": 1,
"id": 0,
"name": "person",
"required": true,
"type": {
Expand Down Expand Up @@ -377,7 +377,7 @@ mod tests {
let expected = vec![create_column(
"person",
"struct<name:string, age:int>",
"1",
"0",
)?];

assert_eq!(result, expected);
Expand All @@ -393,7 +393,7 @@ mod tests {
"type": "struct",
"fields": [
{
"id": 1,
"id": 0,
"name": "location",
"required": true,
"type": {
Expand Down Expand Up @@ -431,7 +431,7 @@ mod tests {
let expected = vec![create_column(
"location",
"array<struct<latitude:float, longitude:float>>",
"1",
"0",
)?];

assert_eq!(result, expected);
Expand All @@ -447,20 +447,20 @@ mod tests {
"type": "struct",
"fields": [
{
"id": 1,
"id": 0,
"name": "quux",
"required": true,
"type": {
"type": "map",
"key-id": 2,
"key-id": 1,
"key": "string",
"value-id": 3,
"value-id": 2,
"value-required": true,
"value": {
"type": "map",
"key-id": 4,
"key-id": 3,
"key": "string",
"value-id": 5,
"value-id": 4,
"value-required": true,
"value": "int"
}
Expand All @@ -475,7 +475,7 @@ mod tests {

let result = GlueSchemaBuilder::from_iceberg(&metadata)?.build();

let expected = vec![create_column("quux", "map<string,map<string,int>>", "1")?];
let expected = vec![create_column("quux", "map<string,map<string,int>>", "0")?];

assert_eq!(result, expected);

Expand Down
6 changes: 3 additions & 3 deletions crates/catalog/glue/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ mod tests {
let metadata_location = create_metadata_location(location.clone(), 0)?;
let properties = HashMap::new();
let schema = Schema::builder()
.with_schema_id(1)
.with_schema_id(0)
.with_fields(vec![NestedField::required(
1,
0,
"foo",
Type::Primitive(PrimitiveType::Int),
)
Expand All @@ -347,7 +347,7 @@ mod tests {
let metadata = create_metadata(schema)?;

let parameters = HashMap::from([
(ICEBERG_FIELD_ID.to_string(), "1".to_string()),
(ICEBERG_FIELD_ID.to_string(), "0".to_string()),
(ICEBERG_FIELD_OPTIONAL.to_string(), "true".to_string()),
(ICEBERG_FIELD_CURRENT.to_string(), "true".to_string()),
]);
Expand Down
2 changes: 1 addition & 1 deletion crates/catalog/memory/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ mod tests {
fn simple_table_schema() -> Schema {
Schema::builder()
.with_fields(vec![NestedField::required(
1,
0,
"foo",
Type::Primitive(PrimitiveType::Int),
)
Expand Down
1 change: 0 additions & 1 deletion crates/iceberg/src/spec/table_metadata_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ impl TableMetadataBuilder {
// Thus, replaying the changes, would lead to a different result if a schema is added twice in unfavorable
// conditions.
// Here we do it differently, but a check from a Java maintainer would be nice.

if self.last_added_schema_id != Some(new_schema_id) {
self.changes.push(TableUpdate::AddSchema {
last_column_id: Some(self.metadata.last_column_id),
Expand Down

0 comments on commit c88a6ef

Please sign in to comment.