def get_resource_type(policy):
    """
    Return resource type of the policy.
    :param policy: Policy structure.
    :return: Resource type used in policy (database, tag, path).
    """
    if policy['policyType'] != 0:
        raise AttributeError(
            'PolicyType must be 0 to support option expandHiveResourceToHdfs. Policy: {}'
            .format(policy['name']))
    resources = policy['resources']
    if 'database' in resources:
        return 'database'
    if 'tag' in resources:
        return 'tag'
    if 'path' in resources:
        return 'path'
    return 'unknown'
