Search in sources :

Example 1 with ResourceType

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;
}
Also used : ResourceUri(org.apache.hadoop.hive.metastore.api.ResourceUri) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) ResourceType(org.apache.hadoop.hive.metastore.api.ResourceType) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Example 2 with ResourceType

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;
}
Also used : ResourceUri(org.apache.hadoop.hive.metastore.api.ResourceUri) ResourceType(org.apache.hadoop.hive.metastore.api.ResourceType)

Aggregations

ResourceType (org.apache.hadoop.hive.metastore.api.ResourceType)2 ResourceUri (org.apache.hadoop.hive.metastore.api.ResourceUri)2 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1