PHOENIX-5111: Null Pointer exception fix in index tool due to outputpath being null...
authorGokcen Iskender <giskender@salesforce.com>
Mon, 28 Jan 2019 21:16:44 +0000 (13:16 -0800)
committerGeoffrey Jacoby <gjacoby@apache.org>
Wed, 6 Feb 2019 21:30:48 +0000 (13:30 -0800)
Signed-off-by: Geoffrey Jacoby <gjacoby@apache.org>
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java

index c7e7b88..a69fa47 100644 (file)
@@ -251,7 +251,7 @@ public class IndexTool extends Configured implements Tool {
             if (isPartialBuild) {
                 return configureJobForPartialBuild(schemaName, dataTable);
             } else {
-                return configureJobForAysncIndex(schemaName, indexTable, dataTable, useDirectApi, useSnapshot);
+                return configureJobForAsyncIndex(schemaName, indexTable, dataTable, useDirectApi, useSnapshot);
             }
         }
         
@@ -364,7 +364,7 @@ public class IndexTool extends Configured implements Tool {
             
         }
 
-        private Job configureJobForAysncIndex(String schemaName, String indexTable, String dataTable, boolean useDirectApi, boolean useSnapshot)
+        private Job configureJobForAsyncIndex(String schemaName, String indexTable, String dataTable, boolean useDirectApi, boolean useSnapshot)
                 throws Exception {
             final String qDataTable = SchemaUtil.getQualifiedTableName(schemaName, dataTable);
             final String qIndexTable;
@@ -411,14 +411,16 @@ public class IndexTool extends Configured implements Tool {
             final List<ColumnInfo> columnMetadataList =
                     PhoenixRuntime.generateColumnInfo(connection, qIndexTable, indexColumns);
             ColumnInfoToStringEncoderDecoder.encode(configuration, columnMetadataList);
-            fs = outputPath.getFileSystem(configuration);
-            fs.delete(outputPath, true);
+
             final String jobName = String.format(INDEX_JOB_NAME_TEMPLATE, schemaName, dataTable, indexTable);
             final Job job = Job.getInstance(configuration, jobName);
             job.setJarByClass(IndexTool.class);
             job.setMapOutputKeyClass(ImmutableBytesWritable.class);
-            FileOutputFormat.setOutputPath(job, outputPath);
+            if (outputPath != null) {
+                fs = outputPath.getFileSystem(configuration);
+                fs.delete(outputPath, true);
+                FileOutputFormat.setOutputPath(job, outputPath);
+            }
 
             if (!useSnapshot) {
                 PhoenixMapReduceUtil.setInput(job, PhoenixIndexDBWritable.class, qDataTable,