def get_query_type(query):
    """Get the type of a query (sequence/join/event).

    :param ast.PipedQuery|ast.Analytic query: The parsed query AST to analyze
    :rtype: str
    """
    from . import ast
    if isinstance(query, ast.EqlAnalytic):
        query = query.query
    elif not isinstance(query, ast.PipedQuery):
        raise TypeError(
            'unsupported type {} to eql.utils.get_query_type. Expected {}'.
            format(type(query), ast.EqlNode))
    if isinstance(query.first, ast.Sequence):
        return 'sequence'
    elif isinstance(query.first, ast.Join):
        return 'join'
    elif isinstance(query.first, ast.EventQuery):
        return 'event'
    else:
        raise TypeError('Unknown query type: {}'.format(type(query.first)))
