Raise ValueError if query type is not valid