diff --git a/source-hive/src/main/java/org/apache/kylin/source/hive/GarbageCollectionStep.java b/source-hive/src/main/java/org/apache/kylin/source/hive/GarbageCollectionStep.java index ac25d07389a..7dc8260980c 100644 --- a/source-hive/src/main/java/org/apache/kylin/source/hive/GarbageCollectionStep.java +++ b/source-hive/src/main/java/org/apache/kylin/source/hive/GarbageCollectionStep.java @@ -60,16 +60,17 @@ private String cleanUpIntermediateFlatTable(KylinConfig config) throws IOExcepti StringBuffer output = new StringBuffer(); final HiveCmdBuilder hiveCmdBuilder = new HiveCmdBuilder(); final List hiveTables = this.getIntermediateTables(); - for (String hiveTable : hiveTables) { - if (config.isHiveKeepFlatTable() == false && StringUtils.isNotEmpty(hiveTable)) { - hiveCmdBuilder.addStatement("USE " + config.getHiveDatabaseForIntermediateTable() + ";"); - hiveCmdBuilder.addStatement("DROP TABLE IF EXISTS " + hiveTable + ";"); - - output.append("Hive table " + hiveTable + " is dropped. \n"); + if (!config.isHiveKeepFlatTable()){ + for (String hiveTable : hiveTables) { + if (StringUtils.isNotEmpty(hiveTable)) { + hiveCmdBuilder.addStatement("USE " + config.getHiveDatabaseForIntermediateTable() + ";"); + hiveCmdBuilder.addStatement("DROP TABLE IF EXISTS " + hiveTable + ";"); + output.append("Hive table " + hiveTable + " is dropped. \n"); + } } + rmdirOnHDFS(getExternalDataPaths()); } config.getCliCommandExecutor().execute(hiveCmdBuilder.build()); - rmdirOnHDFS(getExternalDataPaths()); output.append("Path " + getExternalDataPaths() + " is deleted. \n"); return output.toString();