diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index a1826fa259d424c9f3d5a2f58a18f617355d586f..fcd0d44acd9caa2468422e1142ad35aa47c4121e 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -2506,8 +2506,11 @@ private HiveMetaHook getHook(Table tbl) throws MetaException { private void checkDbAndTableFilters(final String catName, final String dbName, final String tblName) throws NoSuchObjectException, MetaException { + // HIVE-20776 causes view access regression + // Therefore, do not do filtering here. Call following function only to check + // if dbName and tblName is valid FilterUtils.checkDbAndTableFilters( - isClientFilterEnabled, filterHook, catName, dbName, tblName); + false, filterHook, catName, dbName, tblName); } @Override diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java index 6a0d0aa8840d9fc6799c16463a70ed6f0cc2c354..49c7d88fcb082d421b454c13690de492ca9c9f95 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java @@ -278,7 +278,7 @@ public void testHMSServerWithFilter() throws Exception { testFilterForDb(true); testFilterForTables(true); - testFilterForPartition(); + testFilterForPartition(true); } /** @@ -321,7 +321,7 @@ public void testHMSClientWithFilter() throws Exception { testFilterForDb(false); testFilterForTables(false); - testFilterForPartition(); + testFilterForPartition(false); } protected void testFilterForDb(boolean filterAtServer) throws Exception { @@ -360,7 +360,7 @@ protected void testFilterForTables(boolean filterAtServer) throws Exception { assertEquals(0, client.getTables(DBNAME1, TAB2).size()); } - protected void testFilterForPartition() throws Exception { + protected void testFilterForPartition(boolean filterAtServer) throws Exception { try { assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); fail("getPartition() should fail with blocking mode"); @@ -368,11 +368,21 @@ protected void testFilterForPartition() throws Exception { // Excepted } - try { - client.getPartitionsByNames(DBNAME1, TAB2, - Lists.newArrayList("name=value1")).size(); - } catch (NoSuchObjectException e) { - // Excepted + if (filterAtServer) { + // at HMS server, the table of the partitions should be filtered out and result in + // NoSuchObjectException + try { + client.getPartitionsByNames(DBNAME1, TAB2, + Lists.newArrayList("name=value1")).size(); + fail("getPartitionsByNames() should fail with blocking mode at server side"); + } catch (NoSuchObjectException e) { + // Excepted + } + } else { + // at HMS client, we cannot filter the table of the partitions due to + // HIVE-21227: HIVE-20776 causes view access regression + assertEquals(0, client.getPartitionsByNames(DBNAME1, TAB2, + Lists.newArrayList("name=value1")).size()); } } }