@@ -33,11 +33,12 @@ use datafusion_expr::{
33
33
34
34
use crate :: function:: functions_nested_utils:: make_scalar_function;
35
35
36
+ const ARRAY_FIELD_DEFAULT_NAME : & ' static str = "element" ;
37
+
36
38
#[ derive( Debug ) ]
37
39
pub struct SparkArray {
38
40
signature : Signature ,
39
41
aliases : Vec < String > ,
40
- name : String ,
41
42
}
42
43
43
44
impl Default for SparkArray {
@@ -47,29 +48,15 @@ impl Default for SparkArray {
47
48
}
48
49
49
50
impl SparkArray {
50
- pub const ARRAY_FIELD_DEFAULT_NAME : & ' static str = "element" ;
51
-
52
51
pub fn new ( ) -> Self {
53
52
Self {
54
53
signature : Signature :: one_of (
55
54
vec ! [ TypeSignature :: UserDefined , TypeSignature :: Nullary ] ,
56
55
Volatility :: Immutable ,
57
56
) ,
58
57
aliases : vec ! [ String :: from( "spark_make_array" ) ] ,
59
- name : Self :: ARRAY_FIELD_DEFAULT_NAME . to_string ( ) ,
60
- }
61
- }
62
-
63
- pub fn with_list_field_name ( name : impl Into < String > ) -> Self {
64
- Self {
65
- name : name. into ( ) ,
66
- ..Self :: new ( )
67
58
}
68
59
}
69
-
70
- pub fn name ( & self ) -> & String {
71
- & self . name
72
- }
73
60
}
74
61
75
62
impl ScalarUDFImpl for SparkArray {
@@ -116,7 +103,11 @@ impl ScalarUDFImpl for SparkArray {
116
103
. cloned ( )
117
104
. collect :: < Vec < _ > > ( ) ;
118
105
let return_type = self . return_type ( & data_types) ?;
119
- Ok ( Arc :: new ( Field :: new ( self . name ( ) , return_type, false ) ) )
106
+ Ok ( Arc :: new ( Field :: new (
107
+ ARRAY_FIELD_DEFAULT_NAME ,
108
+ return_type,
109
+ false ,
110
+ ) ) )
120
111
}
121
112
122
113
fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> Result < ColumnarValue > {
@@ -154,7 +145,11 @@ impl ScalarUDFImpl for SparkArray {
154
145
155
146
// Empty array is a special case that is useful for many other array functions
156
147
pub ( super ) fn empty_array_type ( ) -> DataType {
157
- DataType :: List ( Arc :: new ( Field :: new_list_field ( DataType :: Int32 , true ) ) )
148
+ DataType :: List ( Arc :: new ( Field :: new (
149
+ ARRAY_FIELD_DEFAULT_NAME ,
150
+ DataType :: Int32 ,
151
+ true ,
152
+ ) ) )
158
153
}
159
154
160
155
/// `make_array_inner` is the implementation of the `make_array` function.
@@ -272,7 +267,7 @@ fn array_array<O: OffsetSizeTrait>(
272
267
let data = mutable. freeze ( ) ;
273
268
274
269
Ok ( Arc :: new ( GenericListArray :: < O > :: try_new (
275
- Arc :: new ( Field :: new_list_field ( data_type, true ) ) ,
270
+ Arc :: new ( Field :: new ( ARRAY_FIELD_DEFAULT_NAME , data_type, true ) ) ,
276
271
OffsetBuffer :: new ( offsets. into ( ) ) ,
277
272
make_array ( data) ,
278
273
None ,
0 commit comments