private Object deserializePdxForLocalDistinctQuery(ExecutionContext context, Object value)
      throws QueryInvocationTargetException {

    if (!((DefaultQuery) context.getQuery()).isRemoteQuery()) {
      if (context.isDistinct() && value instanceof PdxInstance
          && !region.getCache().getPdxReadSerialized()) {
        try {
          value = ((PdxInstance) value).getObject();
        } catch (Exception ex) {
          throw new QueryInvocationTargetException(
              "Unable to retrieve domain object from PdxInstance while building the ResultSet. "
                  + ex.getMessage());
        }
      } else if (value instanceof PdxString) {
        value = value.toString();
      }
    }
    return value;
  }
For local queries with distinct, deserialize all PdxInstances as we do not have a way to
compare Pdx and non Pdx objects in case the cache has a mix of pdx and non pdx objects. We
still have to honor the cache level readSerialized flag in case of all Pdx objects in cache.
Also always convert PdxString to String before adding to resultSet for remote queries
geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java