CacheSerializableRunnable getCacheSerializableRunnableForPROrderByQueryAndCompareResults(
      final String regionName, final String localRegion) {
    SerializableRunnable PrRegion = new CacheSerializableRunnable("PRQuery") {
      @Override
      public void run2() throws CacheException {

        Cache cache = getCache();
        // Querying the localRegion and the PR region

        String[] queries =
            new String[] {"p.status from " + SEPARATOR + "REGION_NAME p order by p.status",
                "* from " + SEPARATOR + "REGION_NAME order by status, ID desc",
                "status, ID from " + SEPARATOR + "REGION_NAME order by status",
                "p.status, p.ID from " + SEPARATOR + "REGION_NAME p order by p.status",
                "p.position1.secId, p.ID from " + SEPARATOR
                    + "REGION_NAME p order by p.position1.secId",
                "key from " + SEPARATOR + "REGION_NAME.keys key order by key.status",
                "key.ID from " + SEPARATOR + "REGION_NAME.keys key order by key.ID",
                "key.ID, key.status from " + SEPARATOR + "REGION_NAME.keys key order by key.status",
                "key.ID, key.status from " + SEPARATOR
                    + "REGION_NAME.keys key order by key.status, key.ID",
                "key.ID, key.status from " + SEPARATOR
                    + "REGION_NAME.keys key order by key.status desc, key.ID",
                "key.ID, key.status from " + SEPARATOR
                    + "REGION_NAME.keys key order by key.status, key.ID desc",
                "p.status, p.ID from " + SEPARATOR + "REGION_NAME p order by p.status asc, p.ID",
                "* from " + SEPARATOR + "REGION_NAME p order by p.status, p.ID",
                "p.ID from " + SEPARATOR + "REGION_NAME p, p.positions.values order by p.ID",
                "* from " + SEPARATOR + "REGION_NAME p, p.positions.values order by p.ID",
                "p.ID, p.status from " + SEPARATOR
                    + "REGION_NAME p, p.positions.values order by p.status",
                "pos.secId from " + SEPARATOR
                    + "REGION_NAME p, p.positions.values pos order by pos.secId",
                "p.ID, pos.secId from " + SEPARATOR
                    + "REGION_NAME p, p.positions.values pos order by pos.secId",
                "* from " + SEPARATOR + "REGION_NAME p order by p.iD",
                "p.iD from " + SEPARATOR + "REGION_NAME p order by p.iD",
                "p.iD, p.status from " + SEPARATOR + "REGION_NAME p order by p.iD",
                "iD, status from " + SEPARATOR + "REGION_NAME order by iD",
                "* from " + SEPARATOR + "REGION_NAME p order by p.getID()",
                "p.getID() from " + SEPARATOR + "REGION_NAME p order by p.getID()",
                "* from " + SEPARATOR + "REGION_NAME p order by p.names[1]",
                "* from " + SEPARATOR + "REGION_NAME p order by p.getP1().secId",
                "* from " + SEPARATOR + "REGION_NAME p order by p.getP1().getSecId()",
                "* from " + SEPARATOR + "REGION_NAME p order by p.position1.secId",
                "p.ID, p.position1.secId from " + SEPARATOR
                    + "REGION_NAME p order by p.position1.secId",
                "p.position1.secId, p.ID from " + SEPARATOR
                    + "REGION_NAME p order by p.position1.secId",
                "e.key.ID from " + SEPARATOR + "REGION_NAME.entries e order by e.key.ID",
                "e.key.ID, e.value.status from " + SEPARATOR
                    + "REGION_NAME.entries e order by e.key.ID",
                "e.key.ID, e.value.status from " + SEPARATOR
                    + "REGION_NAME.entrySet e order by e.key.ID, e.value.status desc",
                "e.key, e.value from " + SEPARATOR
                    + "REGION_NAME.entrySet e order by e.key.ID, e.value.status desc",
                "e.key from " + SEPARATOR
                    + "REGION_NAME.entrySet e order by e.key.ID, e.key.pkid desc",
                "p, pos from " + SEPARATOR + "REGION_NAME p, p.positions.values pos order by p.ID",
                "p, pos from " + SEPARATOR
                    + "REGION_NAME p, p.positions.values pos order by pos.secId",
                "p, pos from " + SEPARATOR
                    + "REGION_NAME p, p.positions.values pos order by p.ID, pos.secId",};

        Object[][] r = new Object[queries.length][2];
        Region region = cache.getRegion(regionName);
        assertNotNull(region);

        final String[] expectedExceptions =
            new String[] {RegionDestroyedException.class.getName(), ReplyException.class.getName(),
                CacheClosedException.class.getName(), ForceReattemptException.class.getName(),
                QueryInvocationTargetException.class.getName()};

        for (final String expectedException : expectedExceptions) {
          getCache().getLogger()
              .info("<ExpectedException action=add>" + expectedException + "</ExpectedException>");
        }

        QueryService qs = getCache().getQueryService();
        Object[] params;


        try {
          String distinct = "SELECT DISTINCT ";
          for (int j = 0; j < queries.length; j++) {
            synchronized (region) {
              // Execute on local region.
              String qStr = (distinct + queries[j].replace("REGION_NAME", localRegion));
              r[j][0] = qs.newQuery(qStr).execute();

              // Execute on remote region.
              qStr = (distinct + queries[j].replace("REGION_NAME", regionName));
              r[j][1] = qs.newQuery(qStr).execute();
            }
          }

          LogWriterUtils.getLogWriter().info(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Queries Executed successfully on Local region & PR Region");

          StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
          ssORrs.CompareQueryResultsWithoutAndWithIndexes(r, queries.length, queries);

        } catch (QueryInvocationTargetException e) {
          // throw an unchecked exception so the controller can examine the cause and see whether or
          // not it's okay
          throw new TestException(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception",
              e);
        }

        catch (QueryException e) {
          LogWriterUtils.getLogWriter().error(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught QueryException while querying"
                  + e,
              e);
          throw new TestException(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception",
              e);
        }

        catch (RegionDestroyedException rde) {
          LogWriterUtils.getLogWriter().info(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a RegionDestroyedException while querying as expected ",
              rde);

        } catch (CancelException cce) {
          LogWriterUtils.getLogWriter().info(
              "PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a CancelException while querying as expected ",
              cce);

        } finally {
          for (final String expectedException : expectedExceptions) {
            getCache().getLogger().info(
                "<ExpectedException action=remove>" + expectedException + "</ExpectedException>");
          }
        }

      }

    };
    return (CacheSerializableRunnable) PrRegion;
  }
This function <br>
1. Creates & executes a query with Logical Operators on the given PR Region 2. Executes the
same query on the local region <br>
3. Compares the appropriate resultSet <br>
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java