@Test
  public void testBugResultMismatch() throws Exception {
    Region region = CacheUtils.createRegion("portfolios", Portfolio.class);
    QueryService qs = CacheUtils.getQueryService();
    region.put("0", new Portfolio(0));
    region.put("1", new Portfolio(1));
    region.put("2", new Portfolio(2));
    region.put("3", new Portfolio(3));
    qs.createIndex("index1", IndexType.FUNCTIONAL, "status", SEPARATOR + "portfolios pf");
    String query1 =
        "SELECT   DISTINCT iD as portfolio_id, pos.secId as sec_id from " + SEPARATOR
            + "portfolios p , p.positions.values pos  where p.status= 'active'";
    String query2 = "select  DISTINCT * from  "
        + "( SELECT   DISTINCT iD as portfolio_id, pos.secId as sec_id from " + SEPARATOR
        + "portfolios p , p.positions.values pos where p.status= 'active')";

    Query q1 = CacheUtils.getQueryService().newQuery(query1);
    Query q2 = CacheUtils.getQueryService().newQuery(query2);
    SelectResults rs1 = (SelectResults) q1.execute();
    SelectResults rs2 = (SelectResults) q2.execute();

    assertThatCode(() -> QueryUtils.union(rs1, rs2, null)).doesNotThrowAnyException();
  }
This bug was occurring in simulation of Outer Join query
geode-core/src/integrationTest/java/org/apache/geode/cache/query/QueryServiceRegressionTest.java