Skip to content

Commit

Permalink
RANGER-4952: Add support for Hive 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Simhadri Govindappa committed Oct 7, 2024
1 parent 4713488 commit aa25aad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
10 changes: 10 additions & 0 deletions hive-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
<artifactId>commons-lang</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax.validation}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,8 +1805,7 @@ private HiveAccessType getAccessType(HivePrivilegeObject hiveObj, HiveOperationT
case ALTERDATABASE:
case ALTERDATABASE_LOCATION:
case ALTERDATABASE_OWNER:
case ALTERINDEX_PROPS:
case ALTERINDEX_REBUILD:
// Refer - HIVE-21968
case ALTERPARTITION_BUCKETNUM:
case ALTERPARTITION_FILEFORMAT:
case ALTERPARTITION_LOCATION:
Expand Down Expand Up @@ -1845,24 +1844,19 @@ private HiveAccessType getAccessType(HivePrivilegeObject hiveObj, HiveOperationT
case ALTERVIEW_PROPERTIES:
case ALTERVIEW_RENAME:
case ALTER_MATERIALIZED_VIEW_REWRITE:
case DROPVIEW_PROPERTIES:
// HIVE-22188
case MSCK:
accessType = HiveAccessType.ALTER;
break;

case DROPFUNCTION:
case DROPINDEX:
case DROPTABLE:
case DROPVIEW:
case DROP_MATERIALIZED_VIEW:
case DROPDATABASE:
accessType = HiveAccessType.DROP;
break;

case CREATEINDEX:
accessType = HiveAccessType.INDEX;
break;

// HIVE-21968
case IMPORT:
/*
This can happen during hive IMPORT command IFF a table is also being created as part of IMPORT.
Expand Down Expand Up @@ -1895,7 +1889,6 @@ private HiveAccessType getAccessType(HivePrivilegeObject hiveObj, HiveOperationT
case QUERY:
case SHOW_TABLESTATUS:
case SHOW_CREATETABLE:
case SHOWINDEXES:
case SHOWPARTITIONS:
case SHOW_TBLPROPERTIES:
case ANALYZE_TABLE:
Expand Down Expand Up @@ -2042,7 +2035,6 @@ private FsAction getURIAccessType(HiveOperationType hiveOpType) {
case ALTERTABLE_PROTECTMODE:
case ALTERTABLE_FILEFORMAT:
case ALTERTABLE_LOCATION:
case ALTERINDEX_PROPS:
case ALTERTABLE_MERGEFILES:
case ALTERTABLE_SKEWED:
case ALTERTABLE_COMPACT:
Expand Down Expand Up @@ -2082,7 +2074,6 @@ private FsAction getURIAccessType(HiveOperationType hiveOpType) {
case SHOW_CREATETABLE:
case SHOWFUNCTIONS:
case SHOWVIEWS:
case SHOWINDEXES:
case SHOWPARTITIONS:
case SHOWLOCKS:
case SHOWCONF:
Expand All @@ -2091,11 +2082,7 @@ private FsAction getURIAccessType(HiveOperationType hiveOpType) {
case CREATEVIEW:
case DROPVIEW:
case CREATE_MATERIALIZED_VIEW:
case CREATEINDEX:
case DROPINDEX:
case ALTERINDEX_REBUILD:
case ALTERVIEW_PROPERTIES:
case DROPVIEW_PROPERTIES:
case DROP_MATERIALIZED_VIEW:
case ALTER_MATERIALIZED_VIEW_REWRITE:
case LOCKTABLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.List;

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider;
import org.apache.hadoop.hive.ql.security.authorization.plugin.AbstractHiveAuthorizer;
import org.apache.hadoop.hive.ql.security.authorization.plugin.DisallowTransformHook;
Expand Down Expand Up @@ -100,14 +99,14 @@ public void applyAuthorizationConfigPolicy(HiveConf hiveConf) throws HiveAuthzPl
// from SQLStdHiveAccessController.applyAuthorizationConfigPolicy()
if (mSessionContext != null && mSessionContext.getClientType() == CLIENT_TYPE.HIVESERVER2) {
// Configure PREEXECHOOKS with DisallowTransformHook to disallow transform queries
String hooks = hiveConf.getVar(ConfVars.PREEXECHOOKS).trim();
String hooks = hiveConf.getVar(HiveConf.getConfVars("hive.exec.pre.hooks")).trim();
if (hooks.isEmpty()) {
hooks = DisallowTransformHook.class.getName();
} else {
hooks = hooks + "," + DisallowTransformHook.class.getName();
}

hiveConf.setVar(ConfVars.PREEXECHOOKS, hooks);
hiveConf.setVar(HiveConf.getConfVars("hive.exec.pre.hooks"), hooks);

SettableConfigUpdater.setHiveConfWhiteList(hiveConf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void setup() throws Exception {

// Warehouse
File warehouseDir = new File("./target/hdfs/warehouse").getAbsoluteFile();
conf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, warehouseDir.getPath());
conf.set(HiveConf.getConfVars("hive.metastore.warehouse.dir").varname, warehouseDir.getPath());

// Scratchdir
File scratchDir = new File("./target/hdfs/scratchdir").getAbsoluteFile();
Expand All @@ -90,7 +90,7 @@ public static void setup() throws Exception {

// Create a temporary directory for the Hive metastore
File metastoreDir = new File("./metastore_db/").getAbsoluteFile();
conf.set(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname,
conf.set(HiveConf.getConfVars("javax.jdo.option.ConnectionURL").varname,
String.format("jdbc:derby:;databaseName=%s;create=true", metastoreDir.getPath()));

conf.set(HiveConf.ConfVars.METASTORE_AUTO_CREATE_ALL.varname, "true");
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<ozone.version>1.4.0</ozone.version>
<hamcrest.version>2.2</hamcrest.version>
<hbase.version>2.6.0</hbase.version>
<hive.version>3.1.3</hive.version>
<hive.version>4.0.0</hive.version>
<hive.storage-api.version>2.7.2</hive.storage-api.version>
<orc.version>1.5.8</orc.version>
<aircompressor.version>0.27</aircompressor.version>
Expand All @@ -145,6 +145,7 @@
<javax-inject.version>1</javax-inject.version>
<javax.annotation-api>1.3.2</javax.annotation-api>
<javax.el.version>3.0.1-b12</javax.el.version>
<javax.validation>2.0.1.Final</javax.validation>
<jaxb.api.version>2.3.1</jaxb.api.version>
<jericho.html.version>3.3</jericho.html.version>
<jersey-bundle.version>1.19.4</jersey-bundle.version>
Expand Down

0 comments on commit aa25aad

Please sign in to comment.