@@ -20,6 +20,8 @@ use arrow::{
20
20
array:: { Int32Array , StringArray } ,
21
21
record_batch:: RecordBatch ,
22
22
} ;
23
+ use arrow_array:: types:: Int32Type ;
24
+ use arrow_array:: ListArray ;
23
25
use arrow_schema:: SchemaRef ;
24
26
use std:: sync:: Arc ;
25
27
@@ -40,6 +42,7 @@ fn test_schema() -> SchemaRef {
40
42
Arc :: new ( Schema :: new ( vec ! [
41
43
Field :: new( "a" , DataType :: Utf8 , false ) ,
42
44
Field :: new( "b" , DataType :: Int32 , false ) ,
45
+ Field :: new( "l" , DataType :: new_list( DataType :: Int32 , true ) , true ) ,
43
46
] ) )
44
47
}
45
48
@@ -57,6 +60,12 @@ async fn create_test_table() -> Result<DataFrame> {
57
60
"123AbcDef" ,
58
61
] ) ) ,
59
62
Arc :: new( Int32Array :: from( vec![ 1 , 10 , 10 , 100 ] ) ) ,
63
+ Arc :: new( ListArray :: from_iter_primitive:: <Int32Type , _, _>( vec![
64
+ Some ( vec![ Some ( 0 ) , Some ( 1 ) , Some ( 2 ) ] ) ,
65
+ None ,
66
+ Some ( vec![ Some ( 3 ) , None , Some ( 5 ) ] ) ,
67
+ Some ( vec![ Some ( 6 ) , Some ( 7 ) ] ) ,
68
+ ] ) ) ,
60
69
] ,
61
70
) ?;
62
71
@@ -67,7 +76,7 @@ async fn create_test_table() -> Result<DataFrame> {
67
76
ctx. table ( "test" ) . await
68
77
}
69
78
70
- /// Excutes an expression on the test dataframe as a select.
79
+ /// Executes an expression on the test dataframe as a select.
71
80
/// Compares formatted output of a record batch with an expected
72
81
/// vector of strings, using the assert_batch_eq! macro
73
82
macro_rules! assert_fn_batches {
@@ -841,3 +850,22 @@ async fn test_fn_decode() -> Result<()> {
841
850
842
851
Ok ( ( ) )
843
852
}
853
+
854
+ #[ tokio:: test]
855
+ async fn test_fn_array_to_string ( ) -> Result < ( ) > {
856
+ let expr = array_to_string ( col ( "l" ) , lit ( "***" ) ) ;
857
+
858
+ let expected = [
859
+ "+-------------------------------------+" ,
860
+ "| array_to_string(test.l,Utf8(\" ***\" )) |" ,
861
+ "+-------------------------------------+" ,
862
+ "| 0***1***2 |" ,
863
+ "| |" ,
864
+ "| 3***5 |" ,
865
+ "| 6***7 |" ,
866
+ "+-------------------------------------+" ,
867
+ ] ;
868
+ assert_fn_batches ! ( expr, expected) ;
869
+
870
+ Ok ( ( ) )
871
+ }
0 commit comments