with tmp as( select array(1,3,2,5,4) as a1, map('1','a','2','b','3','c') as m1, struct(1,'X',array('Y','Z')) as s1 ) select a1[0], m1['2'], s1.col3, size(a1), map_keys(m1), array_contains(a1, 0), sort_array(a1) from tmp;
index( [array | map], int)
select index(array(1,2,3,4,5), 2), index(map('1','a','2','b','3','c'), 2), index(map('1','a','22','b','3','c'), 2);
sort_array_by
sort_array_by(array(struct1, struct2,...),'f1'[,'f2',...][,'ASC','DESC'])
对 array(<struct>) 进行排序
array(<struct>)
with tmp as( select array( struct('g',100), struct('b',200), struct('v',300), struct('b',400) ) as a1 ) SELECT chr(10), a1, chr(10), sort_array_by(a1, 'col1'), chr(10), sort_array_by(a1, 'col1', 'asc'), chr(10), sort_array_by(a1, 'col1', 'desc'), chr(10), sort_array_by(a1, 'col1', 'col2', 'desc') from tmp;