From 257a7c55d7ea258dbfb9e740decbc3f05dee13bd Mon Sep 17 00:00:00 2001 From: Guillaume Balaine Date: Wed, 12 Jan 2022 14:29:22 +0100 Subject: [PATCH] fix tests #1 --- datafusion/src/datasource/file_format/json.rs | 2 +- datafusion/src/execution/context.rs | 4 ++-- datafusion/src/logical_plan/dfschema.rs | 7 ++++--- datafusion/src/physical_plan/expressions/average.rs | 6 +++--- .../src/physical_plan/expressions/get_indexed_field.rs | 2 +- datafusion/src/physical_plan/file_format/mod.rs | 2 +- datafusion/src/scalar.rs | 8 +++++++- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/datafusion/src/datasource/file_format/json.rs b/datafusion/src/datasource/file_format/json.rs index b8853029b64a..45c3d3af1195 100644 --- a/datafusion/src/datasource/file_format/json.rs +++ b/datafusion/src/datasource/file_format/json.rs @@ -158,7 +158,7 @@ mod tests { let projection = Some(vec![0]); let exec = get_exec(&projection, 1024, None).await?; - let batches = collect(exec).await.expect("Collect batches"); + let batches = collect(exec).await?; assert_eq!(1, batches.len()); assert_eq!(1, batches[0].num_columns()); diff --git a/datafusion/src/execution/context.rs b/datafusion/src/execution/context.rs index 880f7081e462..89ea4380e1c0 100644 --- a/datafusion/src/execution/context.rs +++ b/datafusion/src/execution/context.rs @@ -1959,7 +1959,7 @@ mod tests { "+-----------------+", "| SUM(d_table.c1) |", "+-----------------+", - "| 100.000 |", + "| 100.0 |", "+-----------------+", ]; assert_eq!( @@ -1983,7 +1983,7 @@ mod tests { "+-----------------+", "| AVG(d_table.c1) |", "+-----------------+", - "| 5.0000000 |", + "| 5.0 |", "+-----------------+", ]; assert_eq!( diff --git a/datafusion/src/logical_plan/dfschema.rs b/datafusion/src/logical_plan/dfschema.rs index 368fa0e239cc..e8698b8b4f34 100644 --- a/datafusion/src/logical_plan/dfschema.rs +++ b/datafusion/src/logical_plan/dfschema.rs @@ -536,9 +536,10 @@ mod tests { fn from_qualified_schema_into_arrow_schema() -> Result<()> { let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?; let arrow_schema: Schema = schema.into(); - let expected = "Field { name: \"c0\", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }, \ - Field { name: \"c1\", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }"; - assert_eq!(expected, format!("{:?}", arrow_schema)); + let expected = + "[Field { name: \"c0\", data_type: Boolean, nullable: true, metadata: {} }, \ + Field { name: \"c1\", data_type: Boolean, nullable: true, metadata: {} }]"; + assert_eq!(expected, format!("{:?}", arrow_schema.fields)); Ok(()) } diff --git a/datafusion/src/physical_plan/expressions/average.rs b/datafusion/src/physical_plan/expressions/average.rs index 8fc6878e1f88..3d60c77728ed 100644 --- a/datafusion/src/physical_plan/expressions/average.rs +++ b/datafusion/src/physical_plan/expressions/average.rs @@ -263,7 +263,7 @@ mod tests { generic_test_op!( array, - DataType::Decimal(10, 0), + DataType::Decimal(32, 32), Avg, ScalarValue::Decimal128(Some(35000), 14, 4), DataType::Decimal(14, 4) @@ -283,7 +283,7 @@ mod tests { let array: ArrayRef = decimal_builder.as_arc(); generic_test_op!( array, - DataType::Decimal(10, 0), + DataType::Decimal(32, 32), Avg, ScalarValue::Decimal128(Some(32500), 14, 4), DataType::Decimal(14, 4) @@ -300,7 +300,7 @@ mod tests { let array: ArrayRef = decimal_builder.as_arc(); generic_test_op!( array, - DataType::Decimal(10, 0), + DataType::Decimal(32, 32), Avg, ScalarValue::Decimal128(None, 14, 4), DataType::Decimal(14, 4) diff --git a/datafusion/src/physical_plan/expressions/get_indexed_field.rs b/datafusion/src/physical_plan/expressions/get_indexed_field.rs index 033e275da25d..ba16f50127cf 100644 --- a/datafusion/src/physical_plan/expressions/get_indexed_field.rs +++ b/datafusion/src/physical_plan/expressions/get_indexed_field.rs @@ -227,7 +227,7 @@ mod tests { fn get_indexed_field_invalid_list_index() -> Result<()> { let schema = list_schema("l"); let expr = col("l", &schema).unwrap(); - get_indexed_field_test_failure(schema, expr, ScalarValue::Int8(Some(0)), "This feature is not implemented: get indexed field is only possible on lists with int64 indexes. Tried List(Field { name: \"item\", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }) with 0 index") + get_indexed_field_test_failure(schema, expr, ScalarValue::Int8(Some(0)), "This feature is not implemented: get indexed field is only possible on lists with int64 indexes. Tried List(Field { name: \"item\", data_type: Utf8, nullable: true, metadata: {} }) with 0 index") } fn build_struct( diff --git a/datafusion/src/physical_plan/file_format/mod.rs b/datafusion/src/physical_plan/file_format/mod.rs index f392b25c74be..0d372810985d 100644 --- a/datafusion/src/physical_plan/file_format/mod.rs +++ b/datafusion/src/physical_plan/file_format/mod.rs @@ -54,7 +54,7 @@ use super::{ColumnStatistics, Statistics}; lazy_static! { /// The datatype used for all partitioning columns for now pub static ref DEFAULT_PARTITION_COLUMN_DATATYPE: DataType = - DataType::Dictionary(IntegerType::UInt8, Box::new(DataType::Utf8), true); + DataType::Dictionary(IntegerType::UInt8, Box::new(DataType::Utf8), false); } /// The base configurations to provide when creating a physical plan for diff --git a/datafusion/src/scalar.rs b/datafusion/src/scalar.rs index 7550f13d8136..ea447a746cc7 100644 --- a/datafusion/src/scalar.rs +++ b/datafusion/src/scalar.rs @@ -3223,11 +3223,17 @@ mod tests { .try_push(Some(vec![ Some(vec![Some(1), Some(2), Some(3)]), Some(vec![Some(4), Some(5)]), + ])) + .unwrap(); + outer_builder + .try_push(Some(vec![ Some(vec![Some(6)]), Some(vec![Some(7), Some(8)]), - Some(vec![Some(9)]), ])) .unwrap(); + outer_builder + .try_push(Some(vec![Some(vec![Some(9)])])) + .unwrap(); let expected = outer_builder.as_box();