diff --git metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java index d165fc8..e15ccc5 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -5930,11 +5931,13 @@ public UpdatePropURIRetVal updateMStorageDescriptorTblPropURI(URI oldLoc, URI ne public class UpdateMStorageDescriptorTblURIRetVal { private List badRecords; private Map updateLocations; + private int numNullRecords; UpdateMStorageDescriptorTblURIRetVal(List badRecords, - Map updateLocations) { + Map updateLocations, int numNullRecords) { this.badRecords = badRecords; this.updateLocations = updateLocations; + this.numNullRecords = numNullRecords; } public List getBadRecords() { @@ -5952,6 +5955,14 @@ public void setBadRecords(List badRecords) { public void setUpdateLocations(Map updateLocations) { this.updateLocations = updateLocations; } + + public int getNumNullRecords() { + return numNullRecords; + } + + public void setNumNullRecords(int numNullRecords) { + this.numNullRecords = numNullRecords; + } } /** The following APIs @@ -5967,6 +5978,7 @@ public UpdateMStorageDescriptorTblURIRetVal updateMStorageDescriptorTblURI(URI o Query query = null; Map updateLocations = new HashMap(); List badRecords = new ArrayList(); + int numNullRecords = 0; UpdateMStorageDescriptorTblURIRetVal retVal = null; try { openTransaction(); @@ -5976,6 +5988,10 @@ public UpdateMStorageDescriptorTblURIRetVal updateMStorageDescriptorTblURI(URI o for (MStorageDescriptor mSDS : mSDSs) { URI locationURI = null; String location = mSDS.getLocation(); + if (location == null) { // This can happen for View or Index + numNullRecords++; + continue; + } try { locationURI = new Path(location).toUri(); } catch (IllegalArgumentException e) { @@ -5995,7 +6011,7 @@ public UpdateMStorageDescriptorTblURIRetVal updateMStorageDescriptorTblURI(URI o } committed = commitTransaction(); if (committed) { - retVal = new UpdateMStorageDescriptorTblURIRetVal(badRecords, updateLocations); + retVal = new UpdateMStorageDescriptorTblURIRetVal(badRecords, updateLocations, numNullRecords); } return retVal; } finally { diff --git metastore/src/java/org/apache/hadoop/hive/metastore/tools/HiveMetaTool.java metastore/src/java/org/apache/hadoop/hive/metastore/tools/HiveMetaTool.java index 411ac21..e4e9e3a 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/tools/HiveMetaTool.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/tools/HiveMetaTool.java @@ -222,6 +222,11 @@ private void printTblURIUpdateSummary(ObjectStore.UpdateMStorageDescriptorTblURI System.err.println("bad location URI: " + badRecord); } } + int numNullRecords = retVal.getNumNullRecords(); + if (numNullRecords != 0) { + LOG.debug("Number of NULL location URI: " + numNullRecords + + ". This can happen for View or Index."); + } } }