Hotfix weight table, writeback, chunking test

Sorry I missed this earlier. It seems we don't need to use SQL conditions. Conditioning in Scala should already solve the problem, why struggling with SQL?

I will change this in Mysql branch.