@@ -20,6 +20,8 @@ use arrow::{
2020 array:: { Int32Array , StringArray } ,
2121 record_batch:: RecordBatch ,
2222} ;
23+ use arrow_array:: types:: Int32Type ;
24+ use arrow_array:: ListArray ;
2325use arrow_schema:: SchemaRef ;
2426use std:: sync:: Arc ;
2527
@@ -40,6 +42,7 @@ fn test_schema() -> SchemaRef {
4042 Arc :: new ( Schema :: new ( vec ! [
4143 Field :: new( "a" , DataType :: Utf8 , false ) ,
4244 Field :: new( "b" , DataType :: Int32 , false ) ,
45+ Field :: new( "l" , DataType :: new_list( DataType :: Int32 , true ) , true ) ,
4346 ] ) )
4447}
4548
@@ -57,6 +60,12 @@ async fn create_test_table() -> Result<DataFrame> {
5760 "123AbcDef" ,
5861 ] ) ) ,
5962 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+ ] ) ) ,
6069 ] ,
6170 ) ?;
6271
@@ -67,7 +76,7 @@ async fn create_test_table() -> Result<DataFrame> {
6776 ctx. table ( "test" ) . await
6877}
6978
70- /// Excutes an expression on the test dataframe as a select.
79+ /// Executes an expression on the test dataframe as a select.
7180/// Compares formatted output of a record batch with an expected
7281/// vector of strings, using the assert_batch_eq! macro
7382macro_rules! assert_fn_batches {
@@ -841,3 +850,22 @@ async fn test_fn_decode() -> Result<()> {
841850
842851 Ok ( ( ) )
843852}
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