use of org.apache.hadoop.hive.ql.parse.ASTNode in project hive by apache.
the class AbortTransactionsAnalyzer method analyzeInternal.
@Override
public void analyzeInternal(ASTNode root) throws SemanticException {
List<Long> transactionIds = new ArrayList<Long>();
for (Node child : root.getChildren()) {
transactionIds.add(Long.parseLong(((Tree) child).getText()));
}
AbortTransactionsDesc desc = new AbortTransactionsDesc(transactionIds);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
}
use of org.apache.hadoop.hive.ql.parse.ASTNode in project hive by apache.
the class KillQueriesAnalyzer method analyzeInternal.
@Override
public void analyzeInternal(ASTNode root) throws SemanticException {
List<String> queryIds = new ArrayList<String>();
for (Node child : root.getChildren()) {
queryIds.add(stripQuotes(((Tree) child).getText()));
}
KillQueriesDesc desc = new KillQueriesDesc(queryIds);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
DDLUtils.addServiceOutput(conf, outputs);
}
use of org.apache.hadoop.hive.ql.parse.ASTNode in project hive by apache.
the class ExplainSQRewriteTask method addRewrites.
void addRewrites(TokenRewriteStream stream, QB qb, String program, PrintStream out) {
QBSubQuery sqW = qb.getWhereClauseSubQueryPredicate();
QBSubQuery sqH = qb.getHavingClauseSubQueryPredicate();
if (sqW != null || sqH != null) {
ASTNode sqNode = sqW != null ? sqW.getOriginalSubQueryASTForRewrite() : sqH.getOriginalSubQueryASTForRewrite();
ASTNode tokQry = getQueryASTNode(sqNode);
ASTNode tokFrom = (ASTNode) tokQry.getChild(0);
StringBuilder addedJoins = new StringBuilder();
if (sqW != null) {
addRewrites(stream, sqW, program, out, qb.getId(), true, addedJoins);
}
if (sqH != null) {
addRewrites(stream, sqH, program, out, qb.getId(), false, addedJoins);
}
stream.insertAfter(program, tokFrom.getTokenStopIndex(), addedJoins);
}
Set<String> sqAliases = qb.getSubqAliases();
for (String sqAlias : sqAliases) {
addRewrites(stream, qb.getSubqForAlias(sqAlias).getQB(), program, out);
}
}
use of org.apache.hadoop.hive.ql.parse.ASTNode in project hive by apache.
the class HiveAuthorizationTaskFactoryImpl method createShowGrantTask.
@Override
public Task<?> createShowGrantTask(ASTNode ast, Path resultFile, Set<ReadEntity> inputs, Set<WriteEntity> outputs) throws SemanticException {
PrincipalDesc principalDesc = null;
PrivilegeObjectDesc privHiveObj = null;
ASTNode param = null;
if (ast.getChildCount() > 0) {
param = (ASTNode) ast.getChild(0);
principalDesc = AuthorizationParseUtils.getPrincipalDesc(param);
if (principalDesc != null) {
// shift one
param = (ASTNode) ast.getChild(1);
}
}
if (param != null) {
if (param.getType() == HiveParser.TOK_RESOURCE_ALL) {
privHiveObj = new PrivilegeObjectDesc(true, null, null, null);
} else if (param.getType() == HiveParser.TOK_PRIV_OBJECT_COL) {
privHiveObj = parsePrivObject(param);
}
}
ShowGrantDesc showGrant = new ShowGrantDesc(resultFile.toString(), principalDesc, privHiveObj);
return TaskFactory.get(new DDLWork(inputs, outputs, showGrant));
}
use of org.apache.hadoop.hive.ql.parse.ASTNode in project hive by apache.
the class HiveAuthorizationTaskFactoryImpl method analyzeGrantRevokeRole.
private Task<?> analyzeGrantRevokeRole(boolean isGrant, ASTNode ast, Set<ReadEntity> inputs, Set<WriteEntity> outputs) {
List<PrincipalDesc> principalDesc = AuthorizationParseUtils.analyzePrincipalListDef((ASTNode) ast.getChild(0));
// check if admin option has been specified
int rolesStartPos = 1;
ASTNode wAdminOption = (ASTNode) ast.getChild(1);
boolean isAdmin = false;
if ((isGrant && wAdminOption.getToken().getType() == HiveParser.TOK_GRANT_WITH_ADMIN_OPTION) || (!isGrant && wAdminOption.getToken().getType() == HiveParser.TOK_ADMIN_OPTION_FOR)) {
// start reading role names from next position
rolesStartPos = 2;
isAdmin = true;
}
List<String> roles = new ArrayList<String>();
for (int i = rolesStartPos; i < ast.getChildCount(); i++) {
roles.add(BaseSemanticAnalyzer.unescapeIdentifier(ast.getChild(i).getText()));
}
String roleOwnerName = SessionState.getUserFromAuthenticator();
if (isGrant) {
GrantRoleDesc grantRoleDesc = new GrantRoleDesc(roles, principalDesc, roleOwnerName, isAdmin);
return TaskFactory.get(new DDLWork(inputs, outputs, grantRoleDesc));
} else {
RevokeRoleDesc revokeRoleDesc = new RevokeRoleDesc(roles, principalDesc, roleOwnerName, isAdmin);
return TaskFactory.get(new DDLWork(inputs, outputs, revokeRoleDesc));
}
}
Aggregations