Search in sources :

Example 66 with HiveException

use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.

the class HiveHBaseTableInputFormat method getTimestampVal.

private long getTimestampVal(IndexSearchCondition sc) throws IOException {
    long timestamp;
    try {
        ExprNodeConstantEvaluator eval = new ExprNodeConstantEvaluator(sc.getConstantDesc());
        ObjectInspector inspector = eval.initialize(null);
        Object value = eval.evaluate(null);
        if (inspector instanceof LongObjectInspector) {
            timestamp = ((LongObjectInspector) inspector).get(value);
        } else {
            PrimitiveObjectInspector primitive = (PrimitiveObjectInspector) inspector;
            timestamp = PrimitiveObjectInspectorUtils.getTimestamp(value, primitive).getTime();
        }
    } catch (HiveException e) {
        throw new IOException(e);
    }
    return timestamp;
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) LongObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector) LongObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) ExprNodeConstantEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeConstantEvaluator) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) IOException(java.io.IOException)

Example 67 with HiveException

use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.

the class ResourceMaps method setAuthorizerV2Config.

private void setAuthorizerV2Config() throws HiveException {
    // avoid processing the same config multiple times, check marker
    if (sessionConf.get(CONFIG_AUTHZ_SETTINGS_APPLIED_MARKER, "").equals(Boolean.TRUE.toString())) {
        return;
    }
    String metastoreHook = sessionConf.get(ConfVars.METASTORE_FILTER_HOOK.name());
    if (!ConfVars.METASTORE_FILTER_HOOK.getDefaultValue().equals(metastoreHook) && !AuthorizationMetaStoreFilterHook.class.getName().equals(metastoreHook)) {
        LOG.warn(ConfVars.METASTORE_FILTER_HOOK.name() + " will be ignored, since hive.security.authorization.manager" + " is set to instance of HiveAuthorizerFactory.");
    }
    sessionConf.setVar(ConfVars.METASTORE_FILTER_HOOK, AuthorizationMetaStoreFilterHook.class.getName());
    authorizerV2.applyAuthorizationConfigPolicy(sessionConf);
    // update config in Hive thread local as well and init the metastore client
    try {
        Hive.get(sessionConf).getMSC();
    } catch (Exception e) {
        // that would cause ClassNoFoundException otherwise
        throw new HiveException(e.getMessage(), e);
    }
    // set a marker that this conf has been processed.
    sessionConf.set(CONFIG_AUTHZ_SETTINGS_APPLIED_MARKER, Boolean.TRUE.toString());
}
Also used : AuthorizationMetaStoreFilterHook(org.apache.hadoop.hive.ql.security.authorization.plugin.AuthorizationMetaStoreFilterHook) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) URISyntaxException(java.net.URISyntaxException) LockException(org.apache.hadoop.hive.ql.lockmgr.LockException) CancellationException(java.util.concurrent.CancellationException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException)

Example 68 with HiveException

use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.

the class HiveV1Authorizer method getCurrentRoleNames.

@Override
public List<String> getCurrentRoleNames() throws HiveAuthzPluginException {
    String userName = SessionState.get().getUserName();
    if (userName == null) {
        userName = SessionState.getUserFromAuthenticator();
    }
    if (userName == null) {
        throw new HiveAuthzPluginException("Cannot resolve current user name");
    }
    try {
        Hive hive = Hive.getWithFastCheck(this.conf);
        List<String> roleNames = new ArrayList<String>();
        for (Role role : hive.listRoles(userName, PrincipalType.USER)) {
            roleNames.add(role.getRoleName());
        }
        return roleNames;
    } catch (HiveException e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : Role(org.apache.hadoop.hive.metastore.api.Role) Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) ArrayList(java.util.ArrayList)

Example 69 with HiveException

use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.

the class HiveV1Authorizer method dropRole.

@Override
public void dropRole(String roleName) throws HiveAuthzPluginException, HiveAccessControlException {
    try {
        Hive hive = Hive.getWithFastCheck(this.conf);
        hive.dropRole(roleName);
    } catch (HiveException e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Example 70 with HiveException

use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.

the class HiveV1Authorizer method createRole.

@Override
public void createRole(String roleName, HivePrincipal adminGrantor) throws HiveAuthzPluginException, HiveAccessControlException {
    try {
        Hive hive = Hive.getWithFastCheck(this.conf);
        hive.createRole(roleName, adminGrantor == null ? null : adminGrantor.getName());
    } catch (HiveException e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Aggregations

HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)451 IOException (java.io.IOException)172 ArrayList (java.util.ArrayList)81 Path (org.apache.hadoop.fs.Path)68 Table (org.apache.hadoop.hive.ql.metadata.Table)65 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)46 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)45 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)45 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)42 Partition (org.apache.hadoop.hive.ql.metadata.Partition)39 FileSystem (org.apache.hadoop.fs.FileSystem)31 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)29 LinkedHashMap (java.util.LinkedHashMap)28 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)28 InvalidTableException (org.apache.hadoop.hive.ql.metadata.InvalidTableException)28 FileNotFoundException (java.io.FileNotFoundException)27 URISyntaxException (java.net.URISyntaxException)27 HashMap (java.util.HashMap)26 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)23 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)23