prevent sql data case where group_by is none but keys is not empty