public static Map<UUID, PartitionIdSet> createPartitionMap(
            NodeEngine nodeEngine,
            @Nullable MemberVersion localMemberVersion,
            boolean failOnUnassignedPartition
    ) {
        Collection<Partition> parts = nodeEngine.getHazelcastInstance().getPartitionService().getPartitions();

        int partCnt = parts.size();

        Map<UUID, PartitionIdSet> partMap = new LinkedHashMap<>();

        for (Partition part : parts) {
            Member owner = part.getOwner();

            if (owner == null) {
                if (failOnUnassignedPartition) {
                    throw QueryException.error(
                            SqlErrorCode.PARTITION_DISTRIBUTION,
                            "Partition is not assigned to any member: " + part.getPartitionId()
                    );
                } else {
                    continue;
                }
            }

            if (localMemberVersion != null) {
                if (!localMemberVersion.equals(owner.getVersion())) {
                    UUID localMemberId = nodeEngine.getLocalMember().getUuid();

                    throw QueryException.error("Cannot execute SQL query when members have different versions "
                            + "(make sure that all members have the same version) {localMemberId=" + localMemberId
                            + ", localMemberVersion=" + localMemberVersion + ", remoteMemberId=" + owner.getUuid()
                            + ", remoteMemberVersion=" + owner.getVersion() + "}");
                }
            }

            partMap.computeIfAbsent(owner.getUuid(), (key) -> new PartitionIdSet(partCnt)).add(part.getPartitionId());
        }

        return partMap;
    }
@Test
    public void testVersionMismatch() {
        HazelcastInstance member = factory.newHazelcastInstance();

        NodeEngine nodeEngine = Accessors.getNodeEngineImpl(member);
        String memberId = nodeEngine.getLocalMember().getUuid().toString();
        String memberVersion = nodeEngine.getLocalMember().getVersion().toString();

        try {
            QueryUtils.createPartitionMap(nodeEngine, new MemberVersion(0, 0, 0), false);

            fail("Must fail");
        } catch (QueryException e) {
            assertEquals(SqlErrorCode.GENERIC, e.getCode());
            assertEquals("Cannot execute SQL query when members have different versions (make sure that all members "
                + "have the same version) {localMemberId=" + memberId + ", localMemberVersion=0.0.0, remoteMemberId="
                + memberId + ", remoteMemberVersion=" + memberVersion + "}", e.getMessage());
        }
    }