出现问题的情况是这样的,首先维度表是一个9列的表,然后第一次插入的数据是6列(前6列,少于9列),如果第二次插入的数据小于6列且数据内容和前面插入的数据有重复,就会出现上述问题。如果插入的数据大于等于6列就不会出现问题。如果第二次插入的数据5列(小于6列)且数据内容和前面插入的数据不重复,就会写入成功,后面再写入5列的(且与前面写如果的6列的重复的数据)就可以成功写入了。
if(existsDatabase("dfs://Import")){ dropDatabase("dfs://Import") } db = database("dfs://Import", VALUE, 1..100, , "TSDB") schema=table(1:0,[`ImportDate,`ImportType,`UpdateTime,`TimeUse,`RecordCount,`CheckTime,`InsertCount,`IsPassCheck,`CheckDetail],[ `DATE,`SYMBOL,`DATETIME,`DOUBLE,`INT,`DATETIME,`INT,`BOOL,`STRING]) db.createTable(schema, `ImportLog,,`ImportType`ImportDate,keepDuplicates=LAST) ImportLog=loadTable("dfs://Import","ImportLog") timeuse = 3.1 count = 3 //插入语句,第二和第三条完全相同,第二条必错,第三条成功 //成功 ImportLog.append!(table(2020.01.01 as ImportDate, 'queue' as ImportType,now() as UpdateTime, timeuse as TimeUse, count as RecordCount, now() as checkTime)) select top 10 * from ImportLog //失败 ImportLog.append!(table(2020.01.01 as ImportDate, 'queue' as ImportType,now() as UpdateTime,timeuse as TimeUse,count as RecordCount)) /** Server response: '::append!(ImportLog, table(2020.01.01 as ImportDate, "queue" as ImportType, now() as UpdateTime, timeuse as TimeU se, count as RecordCount)) => The data to append contains fewer columns than the schema.' */ //成功 ImportLog.append!(table(2020.01.02 as ImportDate, 'queue' as ImportType,now() as UpdateTime,timeuse as TimeUse,count as RecordCount)) select top 10 * from ImportLog //成功 ImportLog.append!(table(2020.01.01 as ImportDate, 'queue' as ImportType,now() as UpdateTime,timeuse as TimeUse,count as RecordCount)) select top 10 * from ImportLog
上述场景的测试DolphinDB版本是2.00.9.1,这个使用上的限制,DolphinDB会在后续版本做优化,提高上述场景的易用性。