Building advanced query from CaQL query.