@Test
  public void testFallbackForMergeCompactionWhenDeleteDeltaPresent() throws Exception {
    conf.setBoolVar(HiveConf.ConfVars.HIVE_MERGE_COMPACTION_ENABLED, true);
    conf.setBoolVar(HiveConf.ConfVars.COMPACTOR_CRUD_QUERY_BASED, true);
    String dbName = "default";
    String tableName = "testOrcFallback";
    String partitionName = "bkt=1";
    dropTables(driver, tableName);
    executeStatementOnDriver("CREATE TABLE " + tableName + "(a INT, b STRING) " + " PARTITIONED BY(bkt INT)" +
            " STORED AS ORC TBLPROPERTIES ('transactional'='true')", driver);

    executeStatementOnDriver("INSERT INTO TABLE " + tableName + " PARTITION(bkt=1)" +
            " values(57, 'Budapest')", driver);
    executeStatementOnDriver("INSERT INTO TABLE " + tableName + " PARTITION(bkt=1)" +
            " values(58, 'Milano')", driver);
    executeStatementOnDriver("INSERT INTO TABLE " + tableName + " PARTITION(bkt=1)" +
            " values(59, 'Bangalore')", driver);
    executeStatementOnDriver("DELETE FROM " + tableName + " WHERE a = 57", driver);

    CompactorFactory compactorFactory = spy(CompactorFactory.getInstance());
    AtomicReference<Compactor> primary = new AtomicReference<>();
    AtomicReference<Compactor> secondary = new AtomicReference<>();
    doAnswer(invocationOnMock -> {
      Object result = invocationOnMock.callRealMethod();
      Assert.assertTrue(result instanceof CompactorPipeline);
      // Use reflection to fetch inner compactors
      CompactorPipeline compactorPipeline = (CompactorPipeline) result;
      Field field = compactorPipeline.getClass().getDeclaredField("compactor");
      field.setAccessible(true);
      Compactor compactor = (Compactor) field.get(compactorPipeline);
      Assert.assertTrue(compactor instanceof CompactorPipeline.FallbackCompactor);
      CompactorPipeline.FallbackCompactor fallbackCompactor = spy((CompactorPipeline.FallbackCompactor) compactor);
      field.set(compactorPipeline, fallbackCompactor);
      field = fallbackCompactor.getClass().getDeclaredField("primaryCompactor");
      field.setAccessible(true);
      Compactor compactor1 = (Compactor) field.get(fallbackCompactor);
      Assert.assertTrue(compactor1 instanceof MergeCompactor);
      compactor1 = spy(compactor1);
      field.set(fallbackCompactor, compactor1);
      field = fallbackCompactor.getClass().getDeclaredField("secondaryCompactor");
      field.setAccessible(true);
      Compactor compactor2 = (Compactor) field.get(fallbackCompactor);
      Assert.assertTrue(compactor2 instanceof MajorQueryCompactor);
      compactor2 = spy(compactor2);
      field.set(fallbackCompactor, compactor2);
      primary.set(compactor1);
      secondary.set(compactor2);
      return result;
    }).when(compactorFactory).getCompactorPipeline(any(), any(), any(), any());

    Worker worker = new Worker(compactorFactory);
    worker.setConf(conf);
    worker.init(new AtomicBoolean(true));
    TxnStore txnHandler = TxnUtils.getTxnStore(conf);
    CompactionRequest cr = new CompactionRequest(dbName, tableName, CompactionType.MAJOR);
    cr.setPartitionname(partitionName);
    txnHandler.compact(cr);
    worker.run();

    verify(primary.get(), times(1)).run(any());
    verify(secondary.get(), times(1)).run(any());
  }
Tests whether hive.llap.io.etl.skip.format config is handled properly whenever QueryCompactor#runCompactionQueries
is invoked.
@throws Exception
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCrudCompactorOnTez.java