【详述】SQL使用开窗函数在3.5.1版本异常
【背景】该SQL在3.3.8版本正常,迁移数据到3.5.1版本后无法执行。在3.5.1版本,查询的外层的t.rn<1 或者 t.rn<=1 或者t.rn=1 都是这个报错提示。如果是 t.rn>1 或t.rn>=1 则可以正常查询。
【业务影响】
【是否存算分离】否
【StarRocks版本】3.5.1
【集群规模】3fe(1 follower+2observer)+3be(fe与be独立部署)
【机器信息】40C/128G/万兆
SQL如下:
SELECT NAME,COUNT,rn
FROM (SELECT tradecode AS name, COUNT(*)over(PARTITION BY tradecode) AS COUNT,ROW NUMBER()over(PARTITION BYtradecode)As rn FROM tb_op_rpt_search_prc_v6 WHERE tOpFIag=1 AND NAME=‘马云’ GROUP BY personid,tradecode
)t
WHERE rn=1
ORDER BY t.count DESC>1064 -Invalid plan:
PHYSICAL WINDOW
PHYSICAL DECODE2->PhysicalTopNoperator {phase=FINAL, orderBy=[30: tradecode ASC NULLS FIRST],limit=-1, offset-0)->PhysicalDistributionOperator idistributionSpec=SHUFFLE_AGG[30(true)],globalDict=[30:com.starrocks.sql.optimizer.statistics.ColumnDict@3be@cffe]}->PhysicalTopNoperator {phase=PARTIAL, orderBy=[30: tradecode ASC NULLS FIRST],limit=-1, offset=0}PhysicalHashAgeregate itype=GL0BAL,groupBy=[2: personid, 30: tra