在配置单元窗口范围中使用表列

chy5wohz  于 2021-06-01  发布在  Hadoop
关注(0)|答案(1)|浏览(416)

我试图收集一个窗口上的\u列表,我想根据同一个表中的一列值动态限制窗口大小。

select concat_ws('->', collect_list(CASE WHEN b.colA IN ("bla", "blabla") THEN concat_ws("-", colB,colC) END) OVER (PARTITION BY colD ORDER BY time-stamp ROWS BETWEEN colE PRECEDING AND CURRENT ROW)) AS myCol from ( select colA,colB,colC,colD,colE from mytable) a

colA|colB|colC|colD|colE|time-stamp
bla|abc|pqr|INDIA|1|2017-12-10
bla|abc|pqr|CHINA|1|2017-12-11
bla|abc|pqr|INDIA|2|2017-12-12
bla|abc|pqr|INDIA|3|2017-12-13
bla|abc|pqr|CHINA|2|2017-12-14

这里的配置单元不接受具有有效numaric值的范围内的cole。我得到错误:

Error while compiling statement: FAILED: ParseException line 177:89 cannot recognize input near 'colE' 'preceding' 'AND' in windowframeboundary
xwbd5t1u

xwbd5t1u1#

从这里的文件。配置单元不排除单词之间后面的任何列。以下是可用的选项

(ROWS | RANGE) BETWEEN (UNBOUNDED | [num]) PRECEDING AND ([num] PRECEDING | CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN CURRENT ROW AND (CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN [num] FOLLOWING AND (UNBOUNDED | [num]) FOLLOWING

相关问题