S02038

错误代码

S02038

报错信息

Order-sensitive or user-defined functions are not allowed in the order by clause […] for a query over a partitioned table. RefId:S02038

错误原因

查询分布式表时不允许在 order by 子句中使用序列相关函数或用户定义函数。以下两个查询都会导致该错误:

dbName = "dfs://test"
if (existsDatabase(dbName)) {
    dropDatabase(dbName)
}
t = table(1..3 as id)
db = database(dbName, VALUE, 1..3)
pt = db.createPartitionedTable(t, `pt, `id)
pt.append!(t)
def udf(col) {
    return prev(col)
}
select * from pt order by prev(id)
select * from pt order by udf(id)

解决办法

对分布式表的查询中,是否在 order by 子句中使用了序列相关函数或用户定义函数。