some comparison function fixes and updates to support ref engine sql testing