@@ -28,6 +28,16 @@ def test_stop_property
2828 assert_equal ( nil , @options . stop )
2929 end
3030
31+ def test_return_fixed_size_list_property
32+ assert_equal ( nil , @options . return_fixed_size_list )
33+ @options . return_fixed_size_list = true
34+ assert_equal ( true , @options . return_fixed_size_list )
35+ @options . return_fixed_size_list = false
36+ assert_equal ( false , @options . return_fixed_size_list )
37+ @options . return_fixed_size_list = nil
38+ assert_equal ( nil , @options . return_fixed_size_list )
39+ end
40+
3141 def test_list_slice_function_without_stop
3242 args = [
3343 Arrow ::ArrayDatum . new ( Arrow ::ListArray . new ( [ :list , :int8 ] , [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ) ) ,
@@ -39,4 +49,42 @@ def test_list_slice_function_without_stop
3949 assert_equal ( Arrow ::ListArray . new ( [ :list , :int8 ] , [ [ 2 , 3 ] , [ 5 ] ] ) ,
4050 result )
4151 end
52+
53+ def test_list_slice_function_with_return_fixed_size_list_auto
54+ args = [
55+ Arrow ::ArrayDatum . new ( Arrow ::FixedSizeListArray . new ( [ :fixed_size_list , :int8 , 2 ] ,
56+ [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ) ,
57+ ]
58+ @options . start = 1
59+ list_slice_function = Arrow ::Function . find ( "list_slice" )
60+ result = list_slice_function . execute ( args , @options ) . value
61+ assert_equal ( Arrow ::FixedSizeListArray . new ( [ :fixed_size_list , :int8 , 1 ] , [ [ 2 ] , [ 4 ] ] ) ,
62+ result )
63+ end
64+
65+ def test_list_slice_function_with_return_fixed_size_list_true
66+ args = [
67+ Arrow ::ArrayDatum . new ( Arrow ::ListArray . new ( [ :list , :int8 ] , [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ) ) ,
68+ ]
69+ @options . start = 1
70+ @options . stop = 3
71+ @options . return_fixed_size_list = true
72+ list_slice_function = Arrow ::Function . find ( "list_slice" )
73+ result = list_slice_function . execute ( args , @options ) . value
74+ assert_equal ( Arrow ::FixedSizeListArray . new ( [ :fixed_size_list , :int8 , 2 ] , [ [ 2 , 3 ] , [ 5 , nil ] ] ) ,
75+ result )
76+ end
77+
78+ def test_list_slice_function_with_return_fixed_size_list_false
79+ args = [
80+ Arrow ::ArrayDatum . new ( Arrow ::FixedSizeListArray . new ( [ :fixed_size_list , :int8 , 2 ] ,
81+ [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ) ,
82+ ]
83+ @options . start = 1
84+ @options . return_fixed_size_list = false
85+ list_slice_function = Arrow ::Function . find ( "list_slice" )
86+ result = list_slice_function . execute ( args , @options ) . value
87+ assert_equal ( Arrow ::ListArray . new ( [ :list , :int8 ] , [ [ 2 ] , [ 4 ] ] ) ,
88+ result )
89+ end
4290end
0 commit comments