@DisplayName("TestSQL: INSERT INTO duplicate source check")
  @ParameterizedTest(name = "{index} {0} {1} source-is-duplicate: {2} expect-exception: {3}")
  @MethodSource
  public void testDuplicateSourceCheck(
      TableFormat format,
      PrimaryKeySpec keySpec,
      boolean duplicateSource,
      boolean expectException) {
    spark().conf().set(SparkSQLProperties.CHECK_SOURCE_DUPLICATES_ENABLE, "true");
    createTarget(SCHEMA, tableBuilder -> tableBuilder.withPrimaryKeySpec(keySpec));

    List<Record> source = duplicateSource ? this.duplicateSource : this.source;
    createViewSource(SCHEMA, source);

    boolean getException = false;

    try {
      sql("INSERT INTO " + target() + " SELECT * FROM " + source());
    } catch (Exception e) {
      getException = true;
    }
    Assertions.assertEquals(expectException, getException, "expect exception assert failed.");
  }
test 1. upsert not enabled test 2. upsert enabled test 3. upsert source duplicate check test 4.
upsert optimize write
amoro-format-mixed/amoro-mixed-spark/v3.5/amoro-mixed-spark-3.5/src/test/java/org/apache/amoro/spark/test/suites/sql/TestInsertIntoSQL.java