有没有办法使用ClickHouse的lambda,对两个整数执行max函数? 像这样:
SELECT
[0,1,2,3,4,5] as five,
arrayMap(i -> max(five[i], 3), arrayEnumerate(five)) as X
返回
five expected X
0,1,2,3,4,5 3,3,3,3,4,5
答案 0 :(得分:2)
不确定我是否理解您的示例(在语法上不正确),但是对于超过两个整数的max,ClickHouse具有函数great(x,y):
SELECT
[0, 1, 2, 3, 4, 5] AS five,
arrayMap(i -> greatest(i, 3), five) AS X
┌─five──────────┬─X─────────────┐
│ [0,1,2,3,4,5] │ [3,3,3,3,4,5] │
└───────────────┴───────────────┘