use of org.apache.hadoop.hive.metastore.api.ResourceType in project hive by apache.
the class CreateFunctionAnalyzer method getResourceList.
private List<ResourceUri> getResourceList(ASTNode ast) throws SemanticException {
List<ResourceUri> resources = null;
ASTNode resourcesNode = (ASTNode) ast.getFirstChildWithType(HiveParser.TOK_RESOURCE_LIST);
if (resourcesNode != null) {
resources = new ArrayList<ResourceUri>();
for (int idx = 0; idx < resourcesNode.getChildCount(); ++idx) {
// ^(TOK_RESOURCE_URI $resType $resPath)
ASTNode node = (ASTNode) resourcesNode.getChild(idx);
if (node.getToken().getType() != HiveParser.TOK_RESOURCE_URI) {
throw new SemanticException("Expected token type TOK_RESOURCE_URI but found " + node.getToken().toString());
}
if (node.getChildCount() != 2) {
throw new SemanticException("Expected 2 child nodes of TOK_RESOURCE_URI but found " + node.getChildCount());
}
ASTNode resourceTypeNode = (ASTNode) node.getChild(0);
ASTNode resourceUriNode = (ASTNode) node.getChild(1);
ResourceType resourceType = TOKEN_TYPE_TO_RESOURCE_TYPE.get(resourceTypeNode.getType());
if (resourceType == null) {
throw new SemanticException("Unexpected token " + resourceTypeNode);
}
resources.add(new ResourceUri(resourceType, PlanUtils.stripQuotes(resourceUriNode.getText())));
}
}
return resources;
}
use of org.apache.hadoop.hive.metastore.api.ResourceType in project hive by apache.
the class FunctionSemanticAnalyzer method getResourceList.
private List<ResourceUri> getResourceList(ASTNode ast) throws SemanticException {
List<ResourceUri> resources = null;
ASTNode resourcesNode = (ASTNode) ast.getFirstChildWithType(HiveParser.TOK_RESOURCE_LIST);
if (resourcesNode != null) {
resources = new ArrayList<ResourceUri>();
for (int idx = 0; idx < resourcesNode.getChildCount(); ++idx) {
// ^(TOK_RESOURCE_URI $resType $resPath)
ASTNode resNode = (ASTNode) resourcesNode.getChild(idx);
if (resNode.getToken().getType() != HiveParser.TOK_RESOURCE_URI) {
throw new SemanticException("Expected token type TOK_RESOURCE_URI but found " + resNode.getToken().toString());
}
if (resNode.getChildCount() != 2) {
throw new SemanticException("Expected 2 child nodes of TOK_RESOURCE_URI but found " + resNode.getChildCount());
}
ASTNode resTypeNode = (ASTNode) resNode.getChild(0);
ASTNode resUriNode = (ASTNode) resNode.getChild(1);
ResourceType resourceType = getResourceType(resTypeNode);
resources.add(new ResourceUri(resourceType, PlanUtils.stripQuotes(resUriNode.getText())));
}
}
return resources;
}
Aggregations