public Schema mergeTables(
            Map<FeatureOption, MergingStrategy> mergingStrategies,
            Schema sourceSchema,
            List<SqlNode> derivedColumns,
            List<SqlWatermark> derivedWatermarkSpecs,
            SqlTableConstraint derivedPrimaryKey) {

        SchemaBuilder schemaBuilder =
                new SchemaBuilder(
                        mergingStrategies,
                        sourceSchema,
                        (FlinkTypeFactory) validator.getTypeFactory(),
                        dataTypeFactory,
                        validator,
                        escapeExpression);
        schemaBuilder.appendDerivedColumns(mergingStrategies, derivedColumns);
        schemaBuilder.appendDerivedWatermarks(mergingStrategies, derivedWatermarkSpecs);
        schemaBuilder.appendDerivedPrimaryKey(derivedPrimaryKey);

        return schemaBuilder.build();
    }
@Test
    void mergeIncludingConstraintsFailsOnDuplicate() {
        Schema sourceSchema =
                Schema.newBuilder()
                        .column("one", DataTypes.INT().notNull())
                        .column("two", DataTypes.STRING().notNull())
                        .column("three", DataTypes.FLOAT())
                        .primaryKeyNamed("constraint-42", new String[] {"one", "two"})
                        .build();

        assertThatThrownBy(
                        () ->
                                util.mergeTables(
                                        getDefaultMergingStrategies(),
                                        sourceSchema,
                                        Collections.emptyList(),
                                        Collections.emptyList(),
                                        primaryKey("one", "two")))
                .isInstanceOf(ValidationException.class)
                .hasMessage(
                        "The base table already has a primary key. You might want to specify "
                                + "EXCLUDING CONSTRAINTS.");
    }