public Optional<TableDistribution> mergeDistribution(
            MergingStrategy mergingStrategy,
            Optional<TableDistribution> sourceTableDistribution,
            Optional<TableDistribution> derivedTabledDistribution) {

        if (derivedTabledDistribution.isPresent()
                && sourceTableDistribution.isPresent()
                && mergingStrategy != MergingStrategy.EXCLUDING) {
            throw new ValidationException(
                    "The base table already has a distribution defined. You might want to specify "
                            + "EXCLUDING DISTRIBUTION.");
        }

        if (derivedTabledDistribution.isPresent()) {
            return derivedTabledDistribution;
        }
        return sourceTableDistribution;
    }
@Test
    void mergeExcludingDistributionOnDuplicate() {
        Optional<TableDistribution> sourceDistribution =
                Optional.of(TableDistribution.ofHash(Collections.singletonList("a"), 3));
        Optional<TableDistribution> derivedDistribution =
                Optional.of(TableDistribution.ofHash(Collections.singletonList("b"), 3));

        Optional<TableDistribution> mergedPartitions =
                util.mergeDistribution(
                        MergingStrategy.EXCLUDING, sourceDistribution, derivedDistribution);

        assertThat(mergedPartitions).isEqualTo(derivedDistribution);
    }