From 69e0a9d82d07ece1da4e26a33827717317afa73e Mon Sep 17 00:00:00 2001 From: Jonas Dedden Date: Wed, 20 Nov 2024 21:37:44 +0100 Subject: [PATCH] Use `Row::new` also in internal tests. Signed-off-by: Jonas Dedden --- parquet/src/record/api.rs | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/parquet/src/record/api.rs b/parquet/src/record/api.rs index 938411744d4..3541d45603a 100644 --- a/parquet/src/record/api.rs +++ b/parquet/src/record/api.rs @@ -1386,7 +1386,7 @@ mod tests { ("z".to_string(), Field::Float(3.1)), ("a".to_string(), Field::Str("abc".to_string())), ]; - let row = Field::Group(Row{fields}); + let row = Field::Group(Row::new(fields)); assert_eq!(format!("{row}"), "{x: null, Y: 2, z: 3.1, a: \"abc\"}"); let row = Field::ListInternal(make_list(vec![ @@ -1431,12 +1431,12 @@ mod tests { assert!(Field::Decimal(Decimal::from_i32(4, 8, 2)).is_primitive()); // complex types - assert!(!Field::Group(Row{fields: vec![ + assert!(!Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), ("z".to_string(), Field::Float(3.1)), ("a".to_string(), Field::Str("abc".to_string())) - ]}) + ])) .is_primitive()); assert!(!Field::ListInternal(make_list(vec![ @@ -1458,7 +1458,7 @@ mod tests { #[test] fn test_row_primitive_field_fmt() { // Primitives types - let row = Row{fields: vec![ + let row = Row::new(vec![ ("00".to_string(), Field::Null), ("01".to_string(), Field::Bool(false)), ("02".to_string(), Field::Byte(3)), @@ -1481,7 +1481,7 @@ mod tests { ("16".to_string(), Field::TimestampMicros(1262391174000000)), ("17".to_string(), Field::Decimal(Decimal::from_i32(4, 7, 2))), ("18".to_string(), Field::Float16(f16::PI)), - ]}; + ]); assert_eq!("null", format!("{}", row.fmt(0))); assert_eq!("false", format!("{}", row.fmt(1))); @@ -1513,13 +1513,13 @@ mod tests { #[test] fn test_row_complex_field_fmt() { // Complex types - let row = Row{fields: vec![ + let row = Row::new(vec![ ( "00".to_string(), - Field::Group(Row{fields: vec![ + Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}), + ])), ), ( "01".to_string(), @@ -1538,7 +1538,7 @@ mod tests { (Field::Int(3), Field::Float(2.3)), ])), ), - ]}; + ]); assert_eq!("{x: null, Y: 2}", format!("{}", row.fmt(0))); assert_eq!("[2, 1, null, 12]", format!("{}", row.fmt(1))); @@ -1548,7 +1548,7 @@ mod tests { #[test] fn test_row_primitive_accessors() { // primitives - let row = Row{fields: vec![ + let row = Row::new(vec![ ("a".to_string(), Field::Null), ("b".to_string(), Field::Bool(false)), ("c".to_string(), Field::Byte(3)), @@ -1568,7 +1568,7 @@ mod tests { ), ("o".to_string(), Field::Decimal(Decimal::from_i32(4, 7, 2))), ("p".to_string(), Field::Float16(f16::from_f32(9.1))), - ]}; + ]); assert!(!row.get_bool(1).unwrap()); assert_eq!(3, row.get_byte(2).unwrap()); @@ -1590,7 +1590,7 @@ mod tests { #[test] fn test_row_primitive_invalid_accessors() { // primitives - let row = Row{fields: vec![ + let row = Row::new(vec![ ("a".to_string(), Field::Null), ("b".to_string(), Field::Bool(false)), ("c".to_string(), Field::Byte(3)), @@ -1610,7 +1610,7 @@ mod tests { ), ("o".to_string(), Field::Decimal(Decimal::from_i32(4, 7, 2))), ("p".to_string(), Field::Float16(f16::from_f32(9.1))), - ]}; + ]); for i in 0..row.len() { assert!(row.get_group(i).is_err()); @@ -1619,13 +1619,13 @@ mod tests { #[test] fn test_row_complex_accessors() { - let row = Row{fields: vec![ + let row = Row::new(vec![ ( "a".to_string(), - Field::Group(Row{fields: vec![ + Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}), + ])), ), ( "b".to_string(), @@ -1644,7 +1644,7 @@ mod tests { (Field::Int(3), Field::Float(2.3)), ])), ), - ]}; + ]); assert_eq!(2, row.get_group(0).unwrap().len()); assert_eq!(4, row.get_list(1).unwrap().len()); @@ -1653,13 +1653,13 @@ mod tests { #[test] fn test_row_complex_invalid_accessors() { - let row = Row{fields: vec![ + let row = Row::new(vec![ ( "a".to_string(), - Field::Group(Row{fields: vec![ + Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}), + ])), ), ( "b".to_string(), @@ -1678,7 +1678,7 @@ mod tests { (Field::Int(3), Field::Float(2.3)), ])), ), - ]}; + ]); assert_eq!( row.get_float(0).unwrap_err().to_string(), @@ -1802,10 +1802,10 @@ mod tests { #[test] fn test_list_complex_accessors() { - let list = make_list(vec![Field::Group(Row{fields: vec![ + let list = make_list(vec![Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]})]); + ]))]); assert_eq!(2, list.get_group(0).unwrap().len()); let list = make_list(vec![Field::ListInternal(make_list(vec![ @@ -1826,10 +1826,10 @@ mod tests { #[test] fn test_list_complex_invalid_accessors() { - let list = make_list(vec![Field::Group(Row{fields: vec![ + let list = make_list(vec![Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]})]); + ]))]); assert_eq!( list.get_float(0).unwrap_err().to_string(), "Parquet error: Cannot access Group as Float" @@ -1961,7 +1961,7 @@ mod tests { ("Y".to_string(), Field::Double(2.2)), ("Z".to_string(), Field::Str("abc".to_string())), ]; - let row = Field::Group(Row{fields}); + let row = Field::Group(Row::new(fields)); assert_eq!( row.to_json_value(), serde_json::json!({"X": 1, "Y": 2.2, "Z": "abc"}) @@ -1995,13 +1995,13 @@ mod api_tests { #[test] fn test_field_visibility() { - let row = Row{fields: vec![( + let row = Row::new(vec![( "a".to_string(), - Field::Group(Row{fields: vec![ + Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}), - )]}; + ])), + )]); match row.get_column_iter().next() { Some(column) => { @@ -2009,10 +2009,10 @@ mod api_tests { match column.1 { Field::Group(r) => { assert_eq!( - &Row{fields: vec![ + &Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}, + ]), r ); } @@ -2027,10 +2027,10 @@ mod api_tests { fn test_list_element_access() { let expected = vec![ Field::Int(1), - Field::Group(Row{fields: vec![ + Field::Group(Row::new(vec![ ("x".to_string(), Field::Null), ("Y".to_string(), Field::Int(2)), - ]}), + ])), ]; let list = make_list(expected.clone());