12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use itertools:: Itertools ;
15
+ use itertools:: Either ;
16
16
use risingwave_common:: array:: { ListRef , ListValue } ;
17
17
use risingwave_common:: types:: ScalarRefImpl ;
18
18
use risingwave_expr:: { Result , function} ;
@@ -40,11 +40,21 @@ use risingwave_expr::{Result, function};
40
40
/// {1,2,3,4}
41
41
///
42
42
/// query T
43
+ /// select array_flatten(array[array[array[1], array[2, null]], array[array[3, 4], null::int[]]]);
44
+ /// ----
45
+ /// {{1},{2,NULL},{3,4},NULL}
46
+ ///
47
+ /// query T
43
48
/// select array_flatten(array[[]]::int[][]);
44
49
/// ----
45
50
/// {}
46
51
///
47
52
/// query T
53
+ /// select array_flatten(array[[null, 1]]::int[][]);
54
+ /// ----
55
+ /// {NULL,1}
56
+ ///
57
+ /// query T
48
58
/// select array_flatten(array[]::int[][]);
49
59
/// ----
50
60
/// {}
@@ -71,10 +81,10 @@ fn array_flatten(array: ListRef<'_>) -> Result<ListValue> {
71
81
// Flatten all inner arrays
72
82
. flat_map ( |inner_array| {
73
83
if let ScalarRefImpl :: List ( inner_list) = inner_array {
74
- inner_list. iter ( ) . collect_vec ( )
84
+ Either :: Left ( inner_list. iter ( ) )
75
85
} else {
76
86
// This shouldn't happen but handle it gracefully
77
- vec ! [ ]
87
+ Either :: Right ( std :: iter :: empty ( ) )
78
88
}
79
89
} ) ,
80
90
) )
0 commit comments