diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 66589fe..699bb11 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -864,6 +864,7 @@ private ASTNode genValuesTempTable(ASTNode originalFrom, QB qb) throws SemanticE // this file. Path tablePath = null; FileSystem fs = null; + FSDataOutputStream out = null; try { if(dataDir == null) { tablePath = Warehouse.getDnsPath(new Path(ss.getTempTableSpace(), tableName), conf); @@ -876,7 +877,7 @@ private ASTNode genValuesTempTable(ASTNode originalFrom, QB qb) throws SemanticE fs = tablePath.getFileSystem(conf); fs.mkdirs(tablePath); Path dataFile = new Path(tablePath, "data_file"); - FSDataOutputStream out = fs.create(dataFile); + out = fs.create(dataFile); List fields = new ArrayList(); boolean firstRow = true; @@ -900,7 +901,6 @@ private ASTNode genValuesTempTable(ASTNode originalFrom, QB qb) throws SemanticE writeAsText("\n", out); firstRow = false; } - out.close(); // Step 2, create a temp table, using the created file as the data StorageFormat format = new StorageFormat(conf); @@ -924,6 +924,8 @@ private ASTNode genValuesTempTable(ASTNode originalFrom, QB qb) throws SemanticE } catch (IOException swallowIt) {} } throw new SemanticException(errMsg, e); + } finally { + IOUtils.closeStream(out); } // Step 3, return a new subtree with a from clause built around that temp table