diff --git a/datafusion/optimizer/Cargo.toml b/datafusion/optimizer/Cargo.toml index f497f2ec8602..861715b351a6 100644 --- a/datafusion/optimizer/Cargo.toml +++ b/datafusion/optimizer/Cargo.toml @@ -33,9 +33,8 @@ name = "datafusion_optimizer" path = "src/lib.rs" [features] -array_expressions = ["datafusion-functions-array"] crypto_expressions = ["datafusion-physical-expr/crypto_expressions"] -default = ["unicode_expressions", "crypto_expressions", "regex_expressions", "array_expressions"] +default = ["unicode_expressions", "crypto_expressions", "regex_expressions"] regex_expressions = ["datafusion-physical-expr/regex_expressions"] unicode_expressions = ["datafusion-physical-expr/unicode_expressions"] @@ -45,7 +44,6 @@ async-trait = { workspace = true } chrono = { workspace = true } datafusion-common = { workspace = true, default-features = true } datafusion-expr = { workspace = true } -datafusion-functions-array = { workspace = true, optional = true } datafusion-physical-expr = { workspace = true } hashbrown = { version = "0.14", features = ["raw"] } itertools = { workspace = true } diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs index fabeba439370..f8dcf460a469 100644 --- a/datafusion/optimizer/src/analyzer/type_coercion.rs +++ b/datafusion/optimizer/src/analyzer/type_coercion.rs @@ -759,12 +759,11 @@ mod test { use std::sync::{Arc, OnceLock}; use crate::analyzer::type_coercion::{ - cast_expr, coerce_case_expression, TypeCoercion, TypeCoercionRewriter, + coerce_case_expression, TypeCoercion, TypeCoercionRewriter, }; use crate::test::assert_analyzed_plan_eq; - use arrow::array::{FixedSizeListArray, Int32Array}; - use arrow::datatypes::{DataType, Field, TimeUnit}; + use arrow::datatypes::{DataType, TimeUnit}; use datafusion_common::tree_node::{TransformedResult, TreeNode}; use datafusion_common::{DFField, DFSchema, DFSchemaRef, Result, ScalarValue}; use datafusion_expr::expr::{self, InSubquery, Like, ScalarFunction}; @@ -776,7 +775,6 @@ mod test { LogicalPlan, Operator, ScalarUDF, ScalarUDFImpl, Signature, SimpleAggregateUDF, Subquery, Volatility, }; - use datafusion_functions_array::expr_fn::make_array; use datafusion_physical_expr::expressions::AvgAccumulator; fn empty() -> Arc { @@ -1257,51 +1255,6 @@ mod test { Ok(()) } - #[test] - fn test_casting_for_fixed_size_list() -> Result<()> { - let val = lit(ScalarValue::FixedSizeList(Arc::new( - FixedSizeListArray::new( - Arc::new(Field::new("item", DataType::Int32, true)), - 3, - Arc::new(Int32Array::from(vec![1, 2, 3])), - None, - ), - ))); - let expr = make_array(vec![val.clone()]); - let schema = Arc::new(DFSchema::new_with_metadata( - vec![DFField::new_unqualified( - "item", - DataType::FixedSizeList( - Arc::new(Field::new("a", DataType::Int32, true)), - 3, - ), - true, - )], - std::collections::HashMap::new(), - )?); - let mut rewriter = TypeCoercionRewriter { schema }; - let result = expr.rewrite(&mut rewriter).data()?; - - let schema = Arc::new(DFSchema::new_with_metadata( - vec![DFField::new_unqualified( - "item", - DataType::List(Arc::new(Field::new("a", DataType::Int32, true))), - true, - )], - std::collections::HashMap::new(), - )?); - let expected_casted_expr = cast_expr( - &val, - &DataType::List(Arc::new(Field::new("item", DataType::Int32, true))), - &schema, - )?; - - let expected = make_array(vec![expected_casted_expr]); - - assert_eq!(result, expected); - Ok(()) - } - #[test] fn test_type_coercion_rewrite() -> Result<()> { // gt diff --git a/datafusion/sqllogictest/test_files/array.slt b/datafusion/sqllogictest/test_files/array.slt index b729e5c10f3d..ad979a316709 100644 --- a/datafusion/sqllogictest/test_files/array.slt +++ b/datafusion/sqllogictest/test_files/array.slt @@ -6025,12 +6025,25 @@ select make_array(arrow_cast(f0, 'List(Int64)')) from fixed_size_list_array [[1, 2]] [[3, 4]] +query T +select arrow_typeof(make_array(arrow_cast(f0, 'List(Int64)'))) from fixed_size_list_array +---- +List(Field { name: "item", data_type: List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) +List(Field { name: "item", data_type: List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) + query ? select make_array(f0) from fixed_size_list_array ---- [[1, 2]] [[3, 4]] +query T +select arrow_typeof(make_array(f0)) from fixed_size_list_array +---- +List(Field { name: "item", data_type: List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) +List(Field { name: "item", data_type: List(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) + + query ? select array_concat(column1, [7]) from arrays_values_v2; ----