@@ -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 {
@@ -862,3 +871,22 @@ async fn test_fn_decode() -> Result<()> {
862871
863872 Ok ( ( ) )
864873}
874+
875+ #[ tokio:: test]
876+ async fn test_fn_array_to_string ( ) -> Result < ( ) > {
877+ let expr = array_to_string ( col ( "l" ) , lit ( "***" ) ) ;
878+
879+ let expected = [
880+ "+-------------------------------------+" ,
881+ "| array_to_string(test.l,Utf8(\" ***\" )) |" ,
882+ "+-------------------------------------+" ,
883+ "| 0***1***2 |" ,
884+ "| |" ,
885+ "| 3***5 |" ,
886+ "| 6***7 |" ,
887+ "+-------------------------------------+" ,
888+ ] ;
889+ assert_fn_batches ! ( expr, expected) ;
890+
891+ Ok ( ( ) )
892+ }
0 commit comments