S01067

错误代码

S01067

报错信息

The function specified in partitionColumns must return a vector/scalar when the input is a vector/scalar. RefId: S01067

错误原因

创建分布式分区表时,若对分区列应用了函数,则该函数的返回值必须是和分区列具有相同长度的向量,否则会出现该报错。

def mypartitionFunc(val) {
	return sum(val)
}

dbName = "dfs://db1"
tb = table(1..3 as value, `a`b`c as sym)
if(existsDatabase(dbName)){
	dropDatabase(dbName)
}
db = database(dbName, VALUE, 2024.02.01..2024.02.02)
pt = db.createPartitionedTable(tb, `pt, "mypartitionFunc(value)")
//the return value of partitionFunction must be vector.

解决办法

确保应用于分区列的函数返回值和分区列的形式和长度一致。