在定义函数时碰到不能覆盖已存在函数的异常

我想在DolphinDB database中实现历史数据回放功能,然后写了如下所示的代码:

// 定义回放函数
def replayData(productCode, startTime, length, rate){
   // 登录以获取权限
   login("admin", "123456")
    // 载入数据创建表
   sw = loadTable('dfs://huobiDB', 'sw');
   //获取表结构中的两列构成新表
   schSw = select col1,col3 as type from sw.schema().colDefs;
   //创建流数据表,并共享   
   share(streamTable(100:0, schSw.col1, schSw.col3), `outSw);
   //停止持久化,然后删除磁盘上表的内容,但是保留表的结构。
   //如果新建的共享表在硬盘上已经有持久化的数据,则自动读入
   clearTablePersistence(objByName(`outSw));
   // 把共享的流计算表持久化到硬盘上
   enableTablePersistence(objByName(`outSw), true,true, 100000);
   // 计算结束时间
   endTime = temporalAdd(startTime, length, "m")
   //sql语句
   sqlSw = sql(sqlCol("*"), tick,  [<product=productCode>, <server_time between timestamp(pair(startTime, endTime))>]);
   cutCount = length * 60 / 20
   // 构建Range分区方式
   trs = cutPoints(timestamp(startTime..endTime), cutCount);
   // 构建回放数据源
   rds = replayDS(sqlSw, `col2 , , trs);
   // 提交批处理任务
   return submitJob('replay_shuiwen',  replay, rds,  `outSw,`col2 ,, rate);
}
// 授予执行该函数的权限
addFunctionView(replayData)

我在GUI中调试上述代码时,系统提示:Not allowed to overwrite existing functions/procedures by system users.请问这是怎么一回事?谢谢!

请先 登录 后评论

1 个回答

logger

这个是因为replayData这个函数视图已存在,你可以用getFunctionViews()查询一下。若要重新定义函数视图,请先用dropFunctionView函数删除。例子如下:

dropFunctionView(`replayData)


请先 登录 后评论