diff --git ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java index a883124..7f2106a 100755 --- ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java @@ -423,7 +423,6 @@ private void addSplitsForGroup(List dirs, TableScanOperator tableScan, Job for (Path dir : dirs) { PartitionDesc part = getPartitionDescFromPath(pathToPartitionInfo, dir); Class inputFormatClass = part.getInputFileFormatClass(); - TableDesc table = part.getTableDesc(); TableScanOperator tableScan = null; List aliases = @@ -446,12 +445,17 @@ private void addSplitsForGroup(List dirs, TableScanOperator tableScan, Job } } - if (!currentDirs.isEmpty() && - inputFormatClass.equals(currentInputFormatClass) && - table.equals(currentTable) && - tableScan == currentTableScan) { - currentDirs.add(dir); - continue; + // Obtain the lock of TableDesc in order to fix HIVE-11749 + // in case of multiple table scan stage. + TableDesc table = part.getTableDesc(); + synchronized (table) { + if (!currentDirs.isEmpty() && + inputFormatClass.equals(currentInputFormatClass) && + table.equals(currentTable) && + tableScan == currentTableScan) { + currentDirs.add(dir); + continue; + } } if (!currentDirs.isEmpty()) {