neighbor
获取某一列前后相邻的数据,第二个参数控制前后相邻的距离
示例1:
SELECT a, neighbor( a,-1 ) from (SELECT arrayJoin( [1,2,3,6,34,3,11] ) as a,'u' as b)
arrayJoin
行变列,对数组进行展开操作
示例2:
SELECT a, neighbor( a,-1 ) from (SELECT arrayJoin( [1,2,3,6,34,3,11] ) as a,'u' as b)
arraySort
对数组进行排序,降序的话用这个 arrayReverseSort
示例3:
SELECT a, neighbor( a,-1 ) from (SELECT arrayJoin( arraySort([1,2,3,6,34,3,11]) ) as a,'u' as b)
arrayFilter
过滤出数组中满足条件的数据
示例4:
SELECT a, neighbor( a,-1 ) from (SELECT arrayJoin( arraySort(arrayFilter(x->x%2=0, [1,2,3,6,34,3,11])) ) as a,'u' as b)
arrayEnumerate
返回数组下标
示例5:
SELECT arrayEnumerate( [1,2,3,6,34,3,11] )
arrayDifference
计算数组中前后两个值的差值部分
示例6:
SELECT arrayDifference( [1,2,3,6,34,3,11] )
arrayReduce
对数组进行聚合操作,min 、max、avg 等
示例7:
SELECT arrayReduce('avg', [1,2,3,6,34,3,11] )
arrayEnumerateDense
标记出数组中相同的元素
示例8:
SELECT arrayEnumerateDense( [1,2,3,6,34,3,11] )
arraySlice
对数组进行切割 ,后面两个参数分别是切割的offset和切割长度
示例9:
SELECT arraySlice( [1,2,3,6,34,3,11] , -3, 2)
hasAny
判断数组中是否包含某些值,包含其一返回1 ,否则0 ;如果判断全部包含 用hasAll
示例10:
SELECT hasAny( [1,2,3,6,34,3,11] , [3,1])
arrayStringConcat
将数组元素按照给定分隔符进行拼接,返回拼接后的字符串
示例11:
SELECT arrayStringConcat( [1,2,3,6,34,3,11] , '-')
arrayPushFront
向数组首位置最加value ;同理向数组末尾最加为arrayPushBack
示例12:
SELECT arrayPushFront( [1,2,3,6,34,3,11] , 8)
arrayPopFront
移除数组下标为1的值;同理,移除数组最后一个值用arrayPopBack
示例13:
SELECT arrayPopFront( [1,2,3,6,34,3,11] )
arrayWithConstant
生成一个指定长度的数组
示例14:
#生成长度为3 的数组
SELECT arrayWithConstant( 3, 'a')
#返回为['a','a','a']
arrayUniq
计算数组中有多少个不重复的值;如进行数组去重操作 用arrayDistinct
示例15:
SELECT arrayUniq( [1,2,3,6,34,3,11])
runningDifference
计算某一列前后数值的差值
示例16:
select a,runningDifference(a) from (SELECT arrayJoin( [1,2,3,6,34,3,11] ) as a,'u' as b)
arrayCompact
对数组内数据实现相邻去重
示例17:
SELECT arrayCompact([1, 2, 2, 3, 2, 3, 3])