IMPALA-3606: Fix Java NPE when trying to add an existing partition A NPE is also encountered when trying to drop a partition which does not exist.
Currently, catalogd sends a response to impalad that contains a dummy TCatalogObject of type "TABLE" but contains nulls for all other fields. This causes a null pointer exception when impalad tries to access those null fields. The exception never gets exposed to the user as it was caught and ignored. In this case, the fix is that catalogd responds with an empty TCatalogUpdateResult that contains no dummy TCatalogObject objects. No testing was added since the NPE never gets exposed to the user. Change-Id: Ic829e8580c14ed88adf7a0d1571381526b18a206 Reviewed-on: http://gerrit.cloudera.org:8080/3324 Reviewed-by: Dimitris Tsirogiannis <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/144cc68c Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/144cc68c Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/144cc68c Branch: refs/heads/master Commit: 144cc68cc12e713824f5b9c7269dda4b70385557 Parents: 26266fd Author: Bikramjeet Vig <[email protected]> Authored: Mon Jun 6 18:00:48 2016 -0700 Committer: Taras Bobrovytsky <[email protected]> Committed: Thu Jul 14 19:04:45 2016 +0000 ---------------------------------------------------------------------- .../impala/service/CatalogOpExecutor.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/144cc68c/fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java ---------------------------------------------------------------------- diff --git a/fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java b/fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java index 602f65a..a63427a 100644 --- a/fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java +++ b/fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java @@ -366,12 +366,14 @@ public class CatalogOpExecutor { // Create and add HdfsPartition object to the corresponding HdfsTable and load // its block metadata. Get the new table object with an updated catalog // version. If the partition already exists in Hive and "IfNotExists" is true, - // then null is returned. + // then return without populating the response object. Table refreshedTable = alterTableAddPartition(tbl, addPartParams.getPartition_spec(), addPartParams.isIf_not_exists(), addPartParams.getLocation(), addPartParams.getCache_op()); - if (refreshedTable != null) refreshedTable.setCatalogVersion(newCatalogVersion); - addTableToCatalogUpdate(refreshedTable, response.result); + if (refreshedTable != null) { + refreshedTable.setCatalogVersion(newCatalogVersion); + addTableToCatalogUpdate(refreshedTable, response.result); + } return; case DROP_COLUMN: TAlterTableDropColParams dropColParams = params.getDrop_col_params(); @@ -389,13 +391,16 @@ public class CatalogOpExecutor { params.getDrop_partition_params(); // Drop the partition from the corresponding table. Get the table object // with an updated catalog version. If the partition does not exist and - // "IfExists" is true, null is returned. If "purge" option is specified - // partition data is purged by skipping Trash, if configured. + // "IfExists" is true, then return without populating the response object. + // If "purge" option is specified partition data is purged by skipping + // Trash, if configured. refreshedTable = alterTableDropPartition(tbl, dropPartParams.getPartition_spec(), dropPartParams.isIf_exists(), dropPartParams.isPurge()); - if (refreshedTable != null) refreshedTable.setCatalogVersion(newCatalogVersion); - addTableToCatalogUpdate(refreshedTable, response.result); + if (refreshedTable != null) { + refreshedTable.setCatalogVersion(newCatalogVersion); + addTableToCatalogUpdate(refreshedTable, response.result); + } return; case RENAME_TABLE: case RENAME_VIEW:
