@DisplayName("TestSQL: INSERT OVERWRITE optimize write works")
  @ParameterizedTest()
  @MethodSource
  public void testOptimizeWrite(
      TableFormat format,
      PrimaryKeySpec keySpec,
      PartitionSpec ptSpec,
      String mode,
      int bucket,
      boolean optimizeWriteEnable) {
    spark().conf().set(SparkSQLProperties.OPTIMIZE_WRITE_ENABLED, optimizeWriteEnable);
    spark().conf().set(OVERWRITE_MODE_KEY, mode);

    this.table =
        createTarget(
            SCHEMA,
            builder ->
                builder
                    .withPrimaryKeySpec(keySpec)
                    .withProperty(
                        TableProperties.BASE_FILE_INDEX_HASH_BUCKET, String.valueOf(bucket))
                    .withPartitionSpec(ptSpec));

    String[] ptValues = {"AAA", "BBB", "CCC", "DDD"};
    List<Record> source =
        IntStream.range(1, 100)
            .boxed()
            .map(
                i ->
                    RecordGenerator.newRecord(
                        SCHEMA, i, "index" + i, ptValues[i % ptValues.length]))
            .collect(Collectors.toList());
    createViewSource(SCHEMA, source);

    sql("INSERT OVERWRITE " + target() + " SELECT * FROM " + source());

    boolean shouldOptimized =
        optimizeWriteEnable && (keySpec.primaryKeyExisted() || ptSpec.isPartitioned());

    if (shouldOptimized) {
      table.refresh();
      TableFiles files = TestTableUtil.files(table);
      int expectFiles = ExpectResultUtil.expectOptimizeWriteFileCount(source, table, bucket);

      Assertions.assertEquals(expectFiles, files.baseDataFiles.size());
    }
  }
1. dynamic insert overwrite 2. static insert overwrite 3. for un-partitioned table 3. duplicate
check for insert overwrite 4. optimize write is work for insert overwrite
amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/src/test/java/org/apache/amoro/spark/test/suites/sql/TestInsertOverwriteSQL.java