@Test
  public void creationShouldThrowUnsupportedOperationExceptionForUnsupportedQueries() {
    CqAttributes attrs = new CqAttributesFactory().create();
    String[] unsupportedCQs = new String[] {
        // not "just" a select statement
        "(SELECT * FROM " + SEPARATOR + "region WHERE status = 'active').isEmpty",

        // cannot be DISTINCT
        "SELECT DISTINCT * FROM " + SEPARATOR + "region WHERE status = 'active'",

        // references more than one region
        "SELECT * FROM " + SEPARATOR + "region1 r1, " + SEPARATOR + "region2 r2 WHERE r1 = r2",

        // where clause refers to a region
        "SELECT * FROM " + SEPARATOR + "region r WHERE r.val = " + SEPARATOR + "region.size",

        // more than one iterator in FROM clause
        "SELECT * FROM " + SEPARATOR + "portfolios p1, p1.positions p2 WHERE p2.id = 'IBM'",

        // first iterator in FROM clause is not just a region path
        "SELECT * FROM " + SEPARATOR + "region.entries e WHERE e.value.id = 23",

        // has projections
        "SELECT id FROM " + SEPARATOR + "region WHERE status = 'active'",

        // has ORDER BY
        "SELECT * FROM " + SEPARATOR + "region WHERE status = 'active' ORDER BY id",

        // has aggregates
        "SELECT MIN(id) FROM " + SEPARATOR + "region WHERE status = 'active'",
        "SELECT MAX(id) FROM " + SEPARATOR + "region WHERE status = 'active'",
        "SELECT SUM(id) FROM " + SEPARATOR + "region WHERE status = 'active'",
        "SELECT AVG(id) FROM " + SEPARATOR + "region WHERE status = 'active'",
        "SELECT COUNT(id) FROM " + SEPARATOR + "region WHERE status = 'active'",
    };

    for (String queryString : unsupportedCQs) {
      assertThatThrownBy(() -> queryService.newCq(queryString, attrs))
          .as(String.format("Query creation succeeded for %s but should have failed.", queryString))
          .isInstanceOf(UnsupportedOperationException.class);
    }
  }
Test to make sure CQs that have invalid syntax throw QueryInvalidException, and CQs that have
unsupported CQ features throw UnsupportedOperationException
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/ContinuousQueryValidationDUnitTest.java